mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
synchronization with callback-api branch
This commit is contained in:
parent
70afcac495
commit
9ea6823984
1 changed files with 20 additions and 0 deletions
|
@ -22,6 +22,26 @@ public class ApiClientImplementation implements ServiceConnection, Api, ApiMetho
|
|||
private ConnectionListener myListener;
|
||||
private volatile ApiInterface myInterface;
|
||||
|
||||
private final List<ApiListener> myApiListeners =
|
||||
Collections.synchronizedList(new LinkedList<ApiListener>());
|
||||
|
||||
private final BroadcastReceiver myEventReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (myInterface == null || myApiListeners.size() == 0) {
|
||||
return;
|
||||
}
|
||||
final int code = intent.getIntExtra(EVENT_TYPE, -1);
|
||||
if (code != -1) {
|
||||
synchronized (myApiListeners) {
|
||||
for (ApiListener l : myApiListeners) {
|
||||
l.onEvent(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public ApiClientImplementation(Context context, ConnectionListener listener) {
|
||||
myContext = context;
|
||||
myListener = listener;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue