diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java index 368c18fbe8a2..8235a7c84dd6 100755 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java @@ -1203,10 +1203,11 @@ public void onSiteChanged(OnSiteChanged event) { @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEventMainThread(UploadService.UploadErrorEvent event) { EventBus.getDefault().removeStickyEvent(event); - if (event.mediaModelList != null && !event.mediaModelList.isEmpty()) { + View snackbarAttachView = findViewById(R.id.tab_layout); + if (event.mediaModelList != null && !event.mediaModelList.isEmpty() && snackbarAttachView != null) { mUploadUtilsWrapper.onMediaUploadedSnackbarHandler( this, - findViewById(R.id.tab_layout), + snackbarAttachView, true, !TextUtils.isEmpty(event.errorMessage) && event.errorMessage.contains(getString(R.string.error_media_quota_exceeded)) @@ -1223,10 +1224,10 @@ public void onEventMainThread(UploadService.UploadErrorEvent event) { @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEventMainThread(UploadService.UploadMediaSuccessEvent event) { EventBus.getDefault().removeStickyEvent(event); - if (event.mediaModelList != null && !event.mediaModelList.isEmpty()) { - mUploadUtilsWrapper.onMediaUploadedSnackbarHandler(this, - findViewById(R.id.tab_layout), false, - event.mediaModelList, mSite, event.successMessage); + View snackbarAttachView = findViewById(R.id.tab_layout); + if (event.mediaModelList != null && !event.mediaModelList.isEmpty() && snackbarAttachView != null) { + mUploadUtilsWrapper.onMediaUploadedSnackbarHandler(this, snackbarAttachView, false, event.mediaModelList, + mSite, event.successMessage); updateMediaGridForTheseMedia(event.mediaModelList); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtilsWrapper.kt b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtilsWrapper.kt index 3c1b56e62ea7..c37622f5e226 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtilsWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtilsWrapper.kt @@ -34,7 +34,7 @@ class UploadUtilsWrapper @Inject constructor( @Suppress("LongParameterList") fun onMediaUploadedSnackbarHandler( activity: Activity?, - snackbarAttachView: View?, + snackbarAttachView: View, isError: Boolean, mediaList: List?, site: SiteModel?,