Browse Source

Fixed bad update of details view for an uploading file when it finishes, resulting in a renamed file due to other file in the server with the same name ; and subsequent crash got by pressing 'Cancel'

David A. Velasco 12 years ago
parent
commit
afa58b8ac6
1 changed files with 7 additions and 7 deletions
  1. 7 7
      src/com/owncloud/android/ui/fragment/FileDetailFragment.java

+ 7 - 7
src/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -155,10 +155,6 @@ public class FileDetailFragment extends SherlockFragment implements
         mAccount = ocAccount;
         mAccount = ocAccount;
         mStorageManager = null; // we need a context to init this; the container activity is not available yet at this moment 
         mStorageManager = null; // we need a context to init this; the container activity is not available yet at this moment 
         mLayout = R.layout.file_details_empty;
         mLayout = R.layout.file_details_empty;
-        
-        if(fileToDetail != null && ocAccount != null) {
-            mLayout = R.layout.file_details_fragment;
-        }
     }
     }
     
     
     
     
@@ -179,6 +175,10 @@ public class FileDetailFragment extends SherlockFragment implements
             mAccount = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_ACCOUNT);
             mAccount = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_ACCOUNT);
         }
         }
         
         
+        if(mFile != null && mAccount != null) {
+            mLayout = R.layout.file_details_fragment;
+        }
+        
         View view = null;
         View view = null;
         view = inflater.inflate(mLayout, container, false);
         view = inflater.inflate(mLayout, container, false);
         mView = view;
         mView = view;
@@ -461,7 +461,7 @@ public class FileDetailFragment extends SherlockFragment implements
      * @return  True when the fragment was created with the empty layout.
      * @return  True when the fragment was created with the empty layout.
      */
      */
     public boolean isEmpty() {
     public boolean isEmpty() {
-        return mLayout == R.layout.file_details_empty;
+        return (mLayout == R.layout.file_details_empty || mFile == null || mAccount == null);
     }
     }
 
 
     
     
@@ -736,14 +736,14 @@ public class FileDetailFragment extends SherlockFragment implements
                 if (mFile.getRemotePath().equals(uploadRemotePath) ||
                 if (mFile.getRemotePath().equals(uploadRemotePath) ||
                     renamedInUpload) {
                     renamedInUpload) {
                     if (uploadWasFine) {
                     if (uploadWasFine) {
-                        mFile = mStorageManager.getFileByPath(mFile.getRemotePath());
+                        mFile = mStorageManager.getFileByPath(uploadRemotePath);
                     }
                     }
                     if (renamedInUpload) {
                     if (renamedInUpload) {
                         String newName = (new File(uploadRemotePath)).getName();
                         String newName = (new File(uploadRemotePath)).getName();
                         Toast msg = Toast.makeText(getActivity().getApplicationContext(), String.format(getString(R.string.filedetails_renamed_in_upload_msg), newName), Toast.LENGTH_LONG);
                         Toast msg = Toast.makeText(getActivity().getApplicationContext(), String.format(getString(R.string.filedetails_renamed_in_upload_msg), newName), Toast.LENGTH_LONG);
                         msg.show();
                         msg.show();
-                        getSherlockActivity().removeStickyBroadcast(intent);    // not the best place to do this; a small refactorization of BroadcastReceivers should be done
                     }
                     }
+                    getSherlockActivity().removeStickyBroadcast(intent);    // not the best place to do this; a small refactorization of BroadcastReceivers should be done
                     updateFileDetails(false);    // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server
                     updateFileDetails(false);    // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server
                 }
                 }
             }
             }