Fixed NPE when uploading

This commit is contained in:
misaochan 2018-05-26 00:17:16 +10:00
parent bc1adca999
commit d34ddf3379
2 changed files with 6 additions and 8 deletions

View file

@ -65,7 +65,7 @@ public class FileProcessor {
*/ */
@Nullable @Nullable
String getPathOfMediaOrCopy() { String getPathOfMediaOrCopy() {
filePath = FileUtils.getPath(getApplicationContext(), mediaUri); filePath = FileUtils.getPath(context, mediaUri);
Timber.d("Filepath: " + filePath); Timber.d("Filepath: " + filePath);
if (filePath == null) { if (filePath == null) {
String copyPath = null; String copyPath = null;

View file

@ -268,6 +268,7 @@ public class ShareActivity
finish(); finish();
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -312,13 +313,6 @@ public class ShareActivity
ContentResolver contentResolver = this.getContentResolver(); ContentResolver contentResolver = this.getContentResolver();
fileObj = new FileProcessor(mediaUri, contentResolver, prefs, this);
String filePath = fileObj.getPathOfMediaOrCopy();
checkIfFileExists();
fileObj.getFileCoordinates(locationPermitted);
SingleUploadFragment shareView = (SingleUploadFragment) getSupportFragmentManager().findFragmentByTag("shareView"); SingleUploadFragment shareView = (SingleUploadFragment) getSupportFragmentManager().findFragmentByTag("shareView");
categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization"); categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization");
if (shareView == null && categorizationFragment == null) { if (shareView == null && categorizationFragment == null) {
@ -329,6 +323,10 @@ public class ShareActivity
.commitAllowingStateLoss(); .commitAllowingStateLoss();
} }
uploadController.prepareService(); uploadController.prepareService();
fileObj = new FileProcessor(mediaUri, contentResolver, prefs, this);
checkIfFileExists();
fileObj.getFileCoordinates(locationPermitted);
} }
/** /**