Review the behaviour when delete locally a keep_in_sync_file.Clear etag to force...
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / FileActivity.java
index d38d69d..6b8fa43 100644 (file)
@@ -58,6 +58,7 @@ import com.owncloud.android.operations.UnshareLinkOperation;
 import com.owncloud.android.services.OperationsService;
 import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
 import com.owncloud.android.ui.dialog.LoadingDialog;
 import com.owncloud.android.services.OperationsService;
 import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
 import com.owncloud.android.ui.dialog.LoadingDialog;
+import com.owncloud.android.utils.ErrorMessageAdapter;
 import com.owncloud.android.utils.Log_OC;
 
 
 import com.owncloud.android.utils.Log_OC;
 
 
@@ -446,6 +447,13 @@ implements OnRemoteOperationListener, ComponentsGetter {
                 )) {
             
             requestCredentialsUpdate();
                 )) {
             
             requestCredentialsUpdate();
+            
+            if (result.getCode() == ResultCode.UNAUTHORIZED) {
+                dismissLoadingDialog();
+                Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), 
+                        Toast.LENGTH_LONG);
+                t.show();
+            }
 
         } else if (operation instanceof CreateShareOperation) {
             onCreateShareOperationFinish((CreateShareOperation) operation, result);
 
         } else if (operation instanceof CreateShareOperation) {
             onCreateShareOperationFinish((CreateShareOperation) operation, result);
@@ -475,14 +483,11 @@ implements OnRemoteOperationListener, ComponentsGetter {
             Intent sendIntent = operation.getSendIntent();
             startActivity(sendIntent);
             
             Intent sendIntent = operation.getSendIntent();
             startActivity(sendIntent);
             
-        } else if (result.getCode() == ResultCode.SHARE_NOT_FOUND)  {        // Error --> SHARE_NOT_FOUND
-                Toast t = Toast.makeText(this, getString(R.string.share_link_file_no_exist), Toast.LENGTH_LONG);
-                t.show();
-        } else {    // Generic error
-            // Show a Message, operation finished without success
-            Toast t = Toast.makeText(this, getString(R.string.share_link_file_error), Toast.LENGTH_LONG);
+        } else { 
+            Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), 
+                    Toast.LENGTH_LONG);
             t.show();
             t.show();
-        }
+        } 
     }
     
     
     }
     
     
@@ -492,15 +497,11 @@ implements OnRemoteOperationListener, ComponentsGetter {
         if (result.isSuccess()){
             updateFileFromDB();
             
         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 {    // Generic error
-            // Show a Message, operation finished without success
-            Toast t = Toast.makeText(this, getString(R.string.unshare_link_file_error), Toast.LENGTH_LONG);
+        } else {
+            Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), 
+                    Toast.LENGTH_LONG);
             t.show();
             t.show();
-        }
-        
+        } 
     }
     
     
     }
     
     
@@ -540,7 +541,10 @@ implements OnRemoteOperationListener, ComponentsGetter {
         mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler);
         long waitingForOpId = mFileOperationsHelper.getOpIdWaitingFor();
         if (waitingForOpId <= Integer.MAX_VALUE) {
         mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler);
         long waitingForOpId = mFileOperationsHelper.getOpIdWaitingFor();
         if (waitingForOpId <= Integer.MAX_VALUE) {
-            mOperationsServiceBinder.dispatchResultIfFinished((int)waitingForOpId, this);
+            boolean wait = mOperationsServiceBinder.dispatchResultIfFinished((int)waitingForOpId, this);
+            if (!wait ) {
+                dismissLoadingDialog();
+            }
         }
     }
 
         }
     }