diff options
author | Alex Ning <chineseperson5@gmail.com> | 2022-01-17 04:01:12 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2022-01-17 04:01:12 +0000 |
commit | 9ab1e6904c7b8a03449648eda3816a8c02d6e1fa (patch) | |
tree | 1b8bd44a17c6515c9ca8892ef77bfb3be08c6643 /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | 85a51d7dc8e0d36563f7a3e1f5ec40a68967c835 (diff) | |
download | infinity-for-reddit-9ab1e6904c7b8a03449648eda3816a8c02d6e1fa.tar infinity-for-reddit-9ab1e6904c7b8a03449648eda3816a8c02d6e1fa.tar.gz infinity-for-reddit-9ab1e6904c7b8a03449648eda3816a8c02d6e1fa.tar.bz2 infinity-for-reddit-9ab1e6904c7b8a03449648eda3816a8c02d6e1fa.tar.lz infinity-for-reddit-9ab1e6904c7b8a03449648eda3816a8c02d6e1fa.tar.xz infinity-for-reddit-9ab1e6904c7b8a03449648eda3816a8c02d6e1fa.tar.zst infinity-for-reddit-9ab1e6904c7b8a03449648eda3816a8c02d6e1fa.zip |
Fix IllegalStateException in ViewPostDetailFragment.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 675c8b87..eabcb073 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -626,10 +626,10 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic if (mPost.isHidden()) { hideItem.setVisible(true); - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, hideItem, getString(R.string.action_unhide_post)); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, hideItem, activity.getString(R.string.action_unhide_post)); } else { hideItem.setVisible(true); - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, hideItem, getString(R.string.action_hide_post)); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, hideItem, activity.getString(R.string.action_hide_post)); } } else { saveItem.setVisible(false); @@ -645,17 +645,17 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic MenuItem nsfwItem = mMenu.findItem(R.id.action_nsfw_view_post_detail_fragment); nsfwItem.setVisible(true); if (mPost.isNSFW()) { - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, nsfwItem, getString(R.string.action_unmark_nsfw)); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, nsfwItem, activity.getString(R.string.action_unmark_nsfw)); } else { - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, nsfwItem, getString(R.string.action_mark_nsfw)); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, nsfwItem, activity.getString(R.string.action_mark_nsfw)); } MenuItem spoilerItem = mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment); spoilerItem.setVisible(true); if (mPost.isSpoiler()) { - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, spoilerItem, getString(R.string.action_unmark_spoiler)); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, spoilerItem, activity.getString(R.string.action_unmark_spoiler)); } else { - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, spoilerItem, getString(R.string.action_mark_spoiler)); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, spoilerItem, activity.getString(R.string.action_mark_spoiler)); } mMenu.findItem(R.id.action_edit_flair_view_post_detail_fragment).setVisible(true); @@ -953,21 +953,17 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic HidePost.unhidePost(mOauthRetrofit, mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() { @Override public void success() { - if (isAdded()) { - mPost.setHidden(false); - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_hide_post)); - showMessage(R.string.post_unhide_success); - } + mPost.setHidden(false); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, activity.getString(R.string.action_hide_post)); + showMessage(R.string.post_unhide_success); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); } @Override public void failed() { - if (isAdded()) { - mPost.setHidden(true); - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_unhide_post)); - showMessage(R.string.post_unhide_failed); - } + mPost.setHidden(true); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, activity.getString(R.string.action_unhide_post)); + showMessage(R.string.post_unhide_failed); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); } }); @@ -977,21 +973,17 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic HidePost.hidePost(mOauthRetrofit, mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() { @Override public void success() { - if (isAdded()) { - mPost.setHidden(true); - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_unhide_post)); - showMessage(R.string.post_hide_success); - } + mPost.setHidden(true); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, activity.getString(R.string.action_unhide_post)); + showMessage(R.string.post_hide_success); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); } @Override public void failed() { - if (isAdded()) { - mPost.setHidden(false); - Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_hide_post)); - showMessage(R.string.post_hide_failed); - } + mPost.setHidden(false); + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, activity.getString(R.string.action_hide_post)); + showMessage(R.string.post_hide_failed); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); } }); |