use of com.owncloud.android.lib.common.operations.OnRemoteOperationListener in project android by owncloud.
the class OperationsService method dispatchResultToOperationListeners.
/**
* Notifies the currently subscribed listeners about the end of an operation.
*
* @param operation Finished operation.
* @param result Result of the operation.
*/
protected void dispatchResultToOperationListeners(final RemoteOperation operation, final RemoteOperationResult result) {
int count = 0;
Iterator<OnRemoteOperationListener> listeners = mOperationsBinder.mBoundListeners.keySet().iterator();
while (listeners.hasNext()) {
final OnRemoteOperationListener listener = listeners.next();
final Handler handler = mOperationsBinder.mBoundListeners.get(listener);
if (handler != null) {
handler.post(new Runnable() {
@Override
public void run() {
listener.onRemoteOperationFinish(operation, result);
}
});
count += 1;
}
}
if (count == 0) {
Pair<RemoteOperation, RemoteOperationResult> undispatched = new Pair<RemoteOperation, RemoteOperationResult>(operation, result);
mUndispatchedFinishedOperations.put(((Runnable) operation).hashCode(), undispatched);
}
Log_OC.d(TAG, "Called " + count + " listeners");
}
Aggregations