fix NPE (and unnecessary auto-boxing)

This commit is contained in:
Andy Scherzinger 2016-08-15 14:21:54 +02:00
parent 63b52c1d92
commit 15a2439769

View file

@ -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( mCurrentDir = new File(savedInstanceState.getString(UploadFilesActivity.KEY_DIRECTORY_PATH, Environment
UploadFilesActivity.KEY_DIRECTORY_PATH)); .getExternalStorageDirectory().getAbsolutePath()));
mSelectAll = savedInstanceState.getBoolean( mSelectAll = savedInstanceState.getBoolean(UploadFilesActivity.KEY_ALL_SELECTED, false);
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(); if(mCurrentDialog != null) {
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);