+ public class OperationsServiceBinder extends Binder /* implements OnRemoteOperationListener */ {
+
+ /**
+ * Map of listeners that will be reported about the end of operations from a {@link OperationsServiceBinder} instance
+ */
+ private Map<OnRemoteOperationListener, Handler> mBoundListeners = new HashMap<OnRemoteOperationListener, Handler>();
+
+ /**
+ * Cancels an operation
+ *
+ * TODO
+ */
+ public void cancel() {
+ // TODO
+ }
+
+
+ public void clearListeners() {
+
+ mBoundListeners.clear();
+ }
+
+
+ /**
+ * Adds a listener interested in being reported about the end of operations.
+ *
+ * @param listener Object to notify about the end of operations.
+ * @param callbackHandler {@link Handler} to access the listener without breaking Android threading protection.
+ */
+ public void addOperationListener (OnRemoteOperationListener listener, Handler callbackHandler) {
+ mBoundListeners.put(listener, callbackHandler);
+ }
+
+
+ /**
+ * Removes a listener from the list of objects interested in the being reported about the end of operations.
+ *
+ * @param listener Object to notify about progress of transfer.
+ */
+ public void removeOperationListener (OnRemoteOperationListener listener) {
+ mBoundListeners.remove(listener);
+ }
+
+
+ /**
+ * TODO - IMPORTANT: update implementation when more operations are moved into the service
+ *
+ * @return 'True' when an operation that enforces the user to wait for completion is in process.
+ */
+ public boolean isPerformingBlockingOperation() {
+ return (!mPendingOperations.isEmpty());
+ }
+