소스 검색

Commit previous to fix bug about refresh share status in filelist, OC-2887

masensio 11 년 전
부모
커밋
04f5cf170f

+ 1 - 6
src/com/owncloud/android/operations/UnshareLinkOperation.java

@@ -26,7 +26,6 @@ import com.owncloud.android.lib.operations.common.RemoteOperationResult;
 import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode;
 import com.owncloud.android.lib.operations.remote.ExistenceCheckRemoteOperation;
 import com.owncloud.android.lib.operations.remote.RemoveRemoteShareOperation;
-import com.owncloud.android.lib.utils.FileUtils;
 import com.owncloud.android.operations.common.SyncOperation;
 import com.owncloud.android.utils.Log_OC;
 
@@ -54,11 +53,7 @@ public class UnshareLinkOperation extends SyncOperation {
         RemoteOperationResult result  = null;
         
         // Get Share for a file
-        String path = mRemotePath;
-        if (path.endsWith(FileUtils.PATH_SEPARATOR)) {
-           path = path.substring(0, path.length()-1); // Remove last /
-        }
-        OCShare share = getStorageManager().getShareByPath(path);
+        OCShare share = getStorageManager().getShareByPath(mRemotePath);
         
         if (share != null) {
             RemoveRemoteShareOperation operation = new RemoveRemoteShareOperation((int) share.getIdRemoteShared());

+ 2 - 4
src/com/owncloud/android/services/OperationsService.java

@@ -19,15 +19,12 @@ package com.owncloud.android.services;
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 import com.owncloud.android.datamodel.FileDataStorageManager;
 
-import com.owncloud.android.lib.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.network.OwnCloudClientFactory;
 import com.owncloud.android.lib.network.OwnCloudClient;
 import com.owncloud.android.operations.CreateShareOperation;
@@ -202,6 +199,7 @@ public class OperationsService extends Service {
         
         
         public void clearListeners() {
+            
             mBoundListeners.clear();
         }
 
@@ -233,7 +231,7 @@ public class OperationsService extends Service {
          * @return  'True' when an operation that enforces the user to wait for completion is in process.
          */
         public boolean isPerformingBlockingOperation() {
-            return (mPendingOperations.size() > 0);
+            return (!mPendingOperations.isEmpty());
         }
 
     }

+ 15 - 2
src/com/owncloud/android/ui/activity/FileActivity.java

@@ -393,6 +393,8 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp
     private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
         dismissLoadingDialog();
         if (result.isSuccess()) {
+            updateFileFromDB();
+            
             Intent sendIntent = operation.getSendIntent();
             startActivity(sendIntent);
             
@@ -410,10 +412,13 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp
     private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
         dismissLoadingDialog();
         
-        if (result.getCode() == ResultCode.SHARE_NOT_FOUND)  {        // Error --> SHARE_NOT_FOUND
+        if (result.isSuccess()){
+            updateFileFromDB();
+            
+        } else if (result.getCode() == ResultCode.SHARE_NOT_FOUND)  {        // Error --> SHARE_NOT_FOUND
             Toast t = Toast.makeText(this, getString(R.string.unshare_link_file_no_exist), Toast.LENGTH_LONG);
             t.show();
-        } else if (!result.isSuccess()){    // Generic error
+        } else {    // Generic error
             // Show a Message, operation finished without success
             Toast t = Toast.makeText(this, getString(R.string.unshare_link_file_error), Toast.LENGTH_LONG);
             t.show();
@@ -421,6 +426,14 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp
         
     }
     
+    
+    private void updateFileFromDB(){
+      OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
+      if (file != null) {
+          setFile(file);
+      }
+    }
+    
     /**
      * Show loading dialog 
      */

+ 0 - 8
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1348,10 +1348,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
     
     private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
         if (result.isSuccess()) {
-            OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
-            if (file != null) {
-                setFile(file);
-            }
             refreshShowDetails();
             refeshListOfFilesFragment();
         }
@@ -1360,10 +1356,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
     
     private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
         if (result.isSuccess()) {
-            OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
-            if (file != null) {
-                setFile(file);
-            }
             refreshShowDetails();
             refeshListOfFilesFragment();
         } else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) {