1
0
Fork 0
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:
Nikolay Pultsin 2011-12-30 09:56:43 +00:00
parent 70afcac495
commit 9ea6823984

View file

@ -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;