From 459f75b749865ed8501b22dcb5f9a600fb9ad950 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 9 Dec 2020 14:22:00 +0800 Subject: Disable marking posts as read in AccountPostsActivity and AccountSavedThingActivity. --- .../activities/AccountPostsActivity.java | 1 + .../activities/AccountSavedThingActivity.java | 1 + .../infinityforreddit/fragments/PostFragment.java | 23 +++++++++++++--------- 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java index 27292222..8c340208 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java @@ -201,6 +201,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); + bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true); mFragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java index 9be885d1..5069d2e4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java @@ -361,6 +361,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); + bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true); fragment.setArguments(bundle); return fragment; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index 415bff31..91e2ca0f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -131,6 +131,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { public static final int EXTRA_NO_FILTER = -2; public static final String EXTRA_ACCESS_TOKEN = "EAT"; public static final String EXTRA_ACCOUNT_NAME = "EAN"; + public static final String EXTRA_DISABLE_READ_POSTS = "EDRP"; private static final String IS_IN_LAZY_MODE_STATE = "IILMS"; private static final String RECYCLER_VIEW_POSITION_STATE = "RVPS"; @@ -674,15 +675,19 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (accountName != null && !accountName.equals("")) { if (readPosts == null) { - FetchReadPosts.fetchReadPosts(mRedditDataRoomDatabase, accountName, - postType == PostDataSource.TYPE_SUBREDDIT && subredditName != null && (subredditName.equals("all") || subredditName.equals("popular")), - (readPosts, subredditFilters) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { - this.readPosts = readPosts; - this.subredditFilterList = subredditFilters; - initializeAndBindPostViewModel(accessToken, locale, filter, nsfw); - } - }); + if (getArguments().getBoolean(EXTRA_DISABLE_READ_POSTS, false)) { + initializeAndBindPostViewModel(accessToken, locale, filter, nsfw); + } else { + FetchReadPosts.fetchReadPosts(mRedditDataRoomDatabase, accountName, + postType == PostDataSource.TYPE_SUBREDDIT && subredditName != null && (subredditName.equals("all") || subredditName.equals("popular")), + (readPosts, subredditFilters) -> { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + this.readPosts = readPosts; + this.subredditFilterList = subredditFilters; + initializeAndBindPostViewModel(accessToken, locale, filter, nsfw); + } + }); + } } else { initializeAndBindPostViewModel(accessToken, locale, filter, nsfw); } -- cgit v1.2.3