Disable marking posts as read in AccountPostsActivity and AccountSavedThingActivity.

This commit is contained in:
Alex Ning 2020-12-09 14:22:00 +08:00
parent b38025882d
commit 459f75b749
3 changed files with 16 additions and 9 deletions

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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);
}