Browse Source

fix NPE (and unnecessary auto-boxing)

Andy Scherzinger 8 years ago
parent
commit
15a2439769
1 changed files with 11 additions and 18 deletions
  1. 11 18
      src/com/owncloud/android/ui/activity/UploadFilesActivity.java

+ 11 - 18
src/com/owncloud/android/ui/activity/UploadFilesActivity.java

@@ -94,11 +94,9 @@ public class UploadFilesActivity extends FileActivity implements
         super.onCreate(savedInstanceState);
         super.onCreate(savedInstanceState);
 
 
         if(savedInstanceState != null) {
         if(savedInstanceState != null) {
-            mCurrentDir = new File(savedInstanceState.getString(
-                    UploadFilesActivity.KEY_DIRECTORY_PATH));
-            mSelectAll = savedInstanceState.getBoolean(
-                    UploadFilesActivity.KEY_ALL_SELECTED, false);
-
+            mCurrentDir = new File(savedInstanceState.getString(UploadFilesActivity.KEY_DIRECTORY_PATH, Environment
+                    .getExternalStorageDirectory().getAbsolutePath()));
+            mSelectAll = savedInstanceState.getBoolean(UploadFilesActivity.KEY_ALL_SELECTED, false);
         } else {
         } else {
             mCurrentDir = Environment.getExternalStorageDirectory();
             mCurrentDir = Environment.getExternalStorageDirectory();
         }
         }
@@ -354,8 +352,7 @@ public class UploadFilesActivity extends FileActivity implements
         ActionBar actionBar = getSupportActionBar();
         ActionBar actionBar = getSupportActionBar();
         actionBar.setDisplayHomeAsUpEnabled(true);
         actionBar.setDisplayHomeAsUpEnabled(true);
     }
     }
-    
-    
+
     /**
     /**
      * {@inheritDoc}
      * {@inheritDoc}
      */
      */
@@ -372,7 +369,6 @@ public class UploadFilesActivity extends FileActivity implements
         return mCurrentDir;
         return mCurrentDir;
     }
     }
 
 
-
     /**
     /**
      * Performs corresponding action when user presses 'Cancel' or 'Upload' button
      * Performs corresponding action when user presses 'Cancel' or 'Upload' button
      * 
      * 
@@ -390,7 +386,6 @@ public class UploadFilesActivity extends FileActivity implements
         }
         }
     }
     }
 
 
-
     /**
     /**
      * Asynchronous task checking if there is space enough to copy all the files chosen
      * Asynchronous task checking if there is space enough to copy all the files chosen
      * to upload into the ownCloud local folder.
      * to upload into the ownCloud local folder.
@@ -409,7 +404,6 @@ public class UploadFilesActivity extends FileActivity implements
             mCurrentDialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);
             mCurrentDialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);
         }
         }
         
         
-        
         /**
         /**
          * Checks the available space
          * Checks the available space
          * 
          * 
@@ -424,21 +418,23 @@ public class UploadFilesActivity extends FileActivity implements
                 File localFile = new File(localPath);
                 File localFile = new File(localPath);
                 total += localFile.length();
                 total += localFile.length();
             }
             }
-            return (new Boolean(FileStorageUtils.getUsableSpace(mAccountOnCreation.name) >= total));
+            return FileStorageUtils.getUsableSpace(mAccountOnCreation.name) >= total;
         }
         }
 
 
         /**
         /**
          * Updates the activity UI after the check of space is done.
          * Updates the activity UI after the check of space is done.
-         * 
+         *
          * If there is not space enough. shows a new dialog to query the user if wants to move the
          * If there is not space enough. shows a new dialog to query the user if wants to move the
          * files instead of copy them.
          * files instead of copy them.
-         * 
+         *
          * @param result        'True' when there is space enough to copy all the selected files.
          * @param result        'True' when there is space enough to copy all the selected files.
          */
          */
         @Override
         @Override
         protected void onPostExecute(Boolean result) {
         protected void onPostExecute(Boolean result) {
-            mCurrentDialog.dismiss();
-            mCurrentDialog = null;
+            if(mCurrentDialog != null) {
+                mCurrentDialog.dismiss();
+                mCurrentDialog = null;
+            }
             
             
             if (result) {
             if (result) {
                 // return the list of selected files (success)
                 // return the list of selected files (success)
@@ -480,20 +476,17 @@ public class UploadFilesActivity extends FileActivity implements
         }
         }
     }
     }
 
 
-
     @Override
     @Override
     public void onNeutral(String callerTag) {
     public void onNeutral(String callerTag) {
         Log_OC.d(TAG, "Phantom neutral button in dialog was clicked; dialog tag is " + callerTag);
         Log_OC.d(TAG, "Phantom neutral button in dialog was clicked; dialog tag is " + callerTag);
     }
     }
 
 
-
     @Override
     @Override
     public void onCancel(String callerTag) {
     public void onCancel(String callerTag) {
         /// nothing to do; don't finish, let the user change the selection
         /// nothing to do; don't finish, let the user change the selection
         Log_OC.d(TAG, "Negative button in dialog was clicked; dialog tag is " + callerTag);
         Log_OC.d(TAG, "Negative button in dialog was clicked; dialog tag is " + callerTag);
     }
     }
 
 
-
     @Override
     @Override
     protected void onAccountSet(boolean stateWasRecovered) {
     protected void onAccountSet(boolean stateWasRecovered) {
         super.onAccountSet(stateWasRecovered);
         super.onAccountSet(stateWasRecovered);