mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
synchronization with callback-api branch
This commit is contained in:
parent
3098622b3e
commit
70afcac495
4 changed files with 31 additions and 5 deletions
|
@ -21,6 +21,9 @@ package org.geometerplus.android.fbreader.api;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
||||
import org.geometerplus.zlibrary.core.config.ZLConfig;
|
||||
|
||||
|
@ -29,6 +32,13 @@ import org.geometerplus.zlibrary.text.view.*;
|
|||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
|
||||
public class ApiServerImplementation extends ApiInterface.Stub implements Api, ApiMethods {
|
||||
public static void sendEvent(ContextWrapper context, String eventType) {
|
||||
context.sendBroadcast(
|
||||
new Intent(ApiClientImplementation.ACTION_API_CALLBACK)
|
||||
.putExtra(ApiClientImplementation.EVENT_TYPE, eventType)
|
||||
);
|
||||
}
|
||||
|
||||
private final FBReaderApp myReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
|
||||
private ApiObject.Error unsupportedMethodError(int method) {
|
||||
|
@ -96,7 +106,7 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
}
|
||||
} catch (Throwable e) {
|
||||
return new ApiObject.Error("Exception in method " + method + ": " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ApiObject> requestList(int method, ApiObject[] parameters) {
|
||||
|
@ -115,7 +125,7 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
}
|
||||
} catch (Throwable e) {
|
||||
return Collections.<ApiObject>singletonList(exceptionInMethodError(method, e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<ApiObject,ApiObject> errorMap(ApiObject.Error error) {
|
||||
|
@ -130,7 +140,7 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
|
|||
}
|
||||
} catch (Throwable e) {
|
||||
return errorMap(exceptionInMethodError(method, e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// information about fbreader
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue