Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/operations_service' into operations_service

David A. Velasco 11 anni fa
parent
commit
8f5ab8df08

+ 2 - 2
src/com/owncloud/android/files/FileOperationsHelper.java

@@ -115,7 +115,7 @@ public class FileOperationsHelper {
             service.putExtra(OperationsService.EXTRA_ACCOUNT, callerActivity.getAccount());
             service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
             service.putExtra(OperationsService.EXTRA_SEND_INTENT, sendIntent);
-            callerActivity.startService(service);
+            callerActivity.getOperationsServiceBinder().newOperation(service);
             
         } else {
             Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
@@ -154,7 +154,7 @@ public class FileOperationsHelper {
             service.setAction(OperationsService.ACTION_UNSHARE);
             service.putExtra(OperationsService.EXTRA_ACCOUNT, callerActivity.getAccount());
             service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
-            callerActivity.startService(service);
+            callerActivity.getOperationsServiceBinder().newOperation(service);
             
             callerActivity.showLoadingDialog();
             

+ 5 - 3
src/com/owncloud/android/services/OperationsService.java

@@ -443,12 +443,11 @@ public class OperationsService extends Service {
             } finally {
                 synchronized(mPendingOperations) {
                     mPendingOperations.poll();
-                    mOperationResults.put(mCurrentOperation.hashCode(), result);
                 }
             }
             
             //sendBroadcastOperationFinished(mLastTarget, mCurrentOperation, result);
-            callbackOperationListeners(mLastTarget, mCurrentOperation, result);
+            dispatchOperationListeners(mLastTarget, mCurrentOperation, result);
         }
     }
 
@@ -506,7 +505,7 @@ public class OperationsService extends Service {
      * @param operation         Finished operation.
      * @param result            Result of the operation.
      */
-    private void callbackOperationListeners(
+    private void dispatchOperationListeners(
             Target target, final RemoteOperation operation, final RemoteOperationResult result) {
         int count = 0;
         Iterator<OnRemoteOperationListener> listeners = mBinder.mBoundListeners.keySet().iterator();
@@ -523,6 +522,9 @@ public class OperationsService extends Service {
                 count += 1;
             }
         }
+        if (count == 0) {
+            mOperationResults.put(operation.hashCode(), result);
+        }
         Log_OC.d(TAG, "Called " + count + " listeners");
     }
     

+ 5 - 0
src/com/owncloud/android/ui/activity/FileActivity.java

@@ -306,6 +306,11 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp
     }
     
     
+    public OperationsServiceBinder getOperationsServiceBinder() {
+        return mOperationsServiceBinder;
+    }
+
+
     /**
      * Helper class handling a callback from the {@link AccountManager} after the creation of
      * a new ownCloud {@link Account} finished, successfully or not.