Check that fragment is added to activity to prevent crash

This commit is contained in:
misaochan 2018-01-25 03:35:12 +10:00 committed by maskara
parent 6cdf153bc1
commit 1167837b9f

View file

@ -70,6 +70,9 @@ public class ContributionController {
requestWritePermission(fragment.getContext(), takePictureIntent, lastGeneratedCaptureUri); requestWritePermission(fragment.getContext(), takePictureIntent, lastGeneratedCaptureUri);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, lastGeneratedCaptureUri); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, lastGeneratedCaptureUri);
if (!fragment.isAdded()) {
return;
}
fragment.startActivityForResult(takePictureIntent, SELECT_FROM_CAMERA); fragment.startActivityForResult(takePictureIntent, SELECT_FROM_CAMERA);
} }
@ -79,6 +82,9 @@ public class ContributionController {
pickImageIntent.setType("image/*"); pickImageIntent.setType("image/*");
Timber.d("startGalleryPick() called with pickImageIntent"); Timber.d("startGalleryPick() called with pickImageIntent");
//TODO Add fix for IllegalStateException here //TODO Add fix for IllegalStateException here
if (!fragment.isAdded()) {
return;
}
fragment.startActivityForResult(pickImageIntent, SELECT_FROM_GALLERY); fragment.startActivityForResult(pickImageIntent, SELECT_FROM_GALLERY);
} }