Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the crashes in UploadUtilsWrapper caused by null snackbarAttachView #21011

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1394,10 +1394,11 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
break;
}

if (site != null && post != null) {
View snackbarAttachView = findViewById(R.id.coordinator);
if (site != null && post != null && snackbarAttachView != null) {
mUploadUtilsWrapper.handleEditPostResultSnackbars(
this,
findViewById(R.id.coordinator),
snackbarAttachView,
data,
post,
site,
Expand Down Expand Up @@ -1805,21 +1806,24 @@ public void onPostUploaded(OnPostUploaded event) {
}
}

mUploadUtilsWrapper.onPostUploadedSnackbarHandler(
this,
findViewById(R.id.coordinator),
event.isError(),
event.isFirstTimePublish,
event.post,
null,
targetSite,
isFirstTimePublishing -> {
mBloggingRemindersViewModel.onPublishingPost(targetSite.getId(), isFirstTimePublishing);
if (isFirstTimePublishing) {
AppReviewManager.INSTANCE.onPostPublished();
View snackbarAttachView = findViewById(R.id.coordinator);
if (snackbarAttachView != null) {
mUploadUtilsWrapper.onPostUploadedSnackbarHandler(
this,
snackbarAttachView,
event.isError(),
event.isFirstTimePublish,
event.post,
null,
targetSite,
isFirstTimePublishing -> {
mBloggingRemindersViewModel.onPublishingPost(targetSite.getId(), isFirstTimePublishing);
if (isFirstTimePublishing) {
AppReviewManager.INSTANCE.onPostPublished();
}
}
}
);
);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,25 +328,21 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
return;
}

if (site != null && post != null) {
View snackbarAttachView = findViewById(R.id.coordinator);
if (site != null && post != null && snackbarAttachView != null) {
mUploadUtilsWrapper.handleEditPostResultSnackbars(
this,
findViewById(R.id.coordinator),
snackbarAttachView,
data,
post,
site,
mUploadActionUseCase.getUploadAction(post),
new View.OnClickListener() {
@Override
public void onClick(View v) {
UploadUtils.publishPost(
ReaderPostListActivity.this,
post,
site,
mDispatcher
);
}
});
v -> UploadUtils.publishPost(
ReaderPostListActivity.this,
post,
site,
mDispatcher
));
}
}
break;
Expand All @@ -357,10 +353,11 @@ public void onClick(View v) {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPostUploaded(OnPostUploaded event) {
SiteModel site = mSiteStore.getSiteByLocalId(mSelectedSiteRepository.getSelectedSiteLocalId());
if (site != null && event.post != null) {
View snackbarAttachView = findViewById(R.id.coordinator);
if (site != null && event.post != null && snackbarAttachView != null) {
mUploadUtilsWrapper.onPostUploadedSnackbarHandler(
this,
findViewById(R.id.coordinator),
snackbarAttachView,
event.isError(),
event.isFirstTimePublish,
event.post,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1091,10 +1091,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
break;
}

if (site != null && post != null) {
View snackbarAttachView = findViewById(R.id.coordinator);
if (site != null && post != null && snackbarAttachView != null) {
mUploadUtilsWrapper.handleEditPostResultSnackbars(
this,
findViewById(R.id.coordinator),
snackbarAttachView,
data,
post,
site,
Expand All @@ -1119,10 +1120,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPostUploaded(OnPostUploaded event) {
SiteModel site = mSiteStore.getSiteByLocalId(mSelectedSiteRepository.getSelectedSiteLocalId());
if (site != null && event.post != null) {
View snackbarAttachView = findViewById(R.id.coordinator);
if (site != null && event.post != null && snackbarAttachView != null) {
mUploadUtilsWrapper.onPostUploadedSnackbarHandler(
this,
findViewById(R.id.coordinator),
snackbarAttachView,
event.isError(),
event.isFirstTimePublish,
event.post,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class UploadUtilsWrapper @Inject constructor(
@Suppress("LongParameterList")
fun onMediaUploadedSnackbarHandler(
activity: Activity?,
snackbarAttachView: View?,
snackbarAttachView: View,
isError: Boolean,
mediaList: List<MediaModel?>?,
site: SiteModel?,
Expand All @@ -53,7 +53,7 @@ class UploadUtilsWrapper @Inject constructor(
@Suppress("LongParameterList")
fun onPostUploadedSnackbarHandler(
activity: Activity?,
snackbarAttachView: View?,
snackbarAttachView: View,
isError: Boolean,
isFirstTimePublish: Boolean,
post: PostModel?,
Expand Down
Loading