From 840383b30ff7e8a0573af696bcf5b1ac5052d4b7 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 16 Jul 2021 23:09:12 +0800 Subject: Redirect user to ViewPostDetailActivity after submitting a gallery post. --- .../activities/PostGalleryActivity.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java index 1e0e7084..91ec10df 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java @@ -68,6 +68,7 @@ import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIcon; import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.SelectOrCaptureImageBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.events.SubmitGalleryPostEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.services.SubmitPostService; import ml.docilealligator.infinityforreddit.utils.JSONUtils; @@ -684,4 +685,25 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee public void onAccountSwitchEvent(SwitchAccountEvent event) { finish(); } + + @Subscribe + public void onSubmitGalleryPostEvent(SubmitGalleryPostEvent submitGalleryPostEvent) { + isPosting = false; + mPostingSnackbar.dismiss(); + if (submitGalleryPostEvent.postSuccess) { + Intent intent = new Intent(this, LinkResolverActivity.class); + intent.setData(Uri.parse(submitGalleryPostEvent.postUrl)); + startActivity(intent); + finish(); + } else { + mMemu.findItem(R.id.action_send_post_gallery_activity).setEnabled(true); + mMemu.findItem(R.id.action_send_post_gallery_activity).getIcon().setAlpha(255); + if (submitGalleryPostEvent.errorMessage == null || submitGalleryPostEvent.errorMessage.equals("")) { + Snackbar.make(coordinatorLayout, R.string.post_failed, Snackbar.LENGTH_SHORT).show(); + } else { + Snackbar.make(coordinatorLayout, submitGalleryPostEvent.errorMessage.substring(0, 1).toUpperCase() + + submitGalleryPostEvent.errorMessage.substring(1), Snackbar.LENGTH_SHORT).show(); + } + } + } } \ No newline at end of file -- cgit v1.2.3