Hide read posts in ViewSubredditDetailActivity.

This commit is contained in:
Alex Ning 2020-12-08 15:26:22 +08:00
parent a6975f2489
commit 59baa9c51c
2 changed files with 23 additions and 0 deletions

View File

@ -711,6 +711,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM:
fab.setImageResource(R.drawable.ic_random_24dp);
break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
break;
default:
fab.setImageResource(R.drawable.ic_add_day_night_24dp);
break;
@ -746,6 +749,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM:
random();
break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.hideReadPosts();
}
break;
default:
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
break;
@ -1125,6 +1133,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
random();
break;
}
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.hideReadPosts();
}
}
}
}
@ -1314,6 +1327,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
}
void hideReadPosts() {
if (fragmentManager != null) {
Fragment fragment = fragmentManager.findFragmentByTag("f0");
if (fragment instanceof PostFragment) {
((PostFragment) fragment).hideReadPosts();
}
}
}
@Override
public int getItemCount() {
return 2;

View File

@ -208,6 +208,7 @@ public class SharedPreferencesUtils {
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT = 5;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_USER = 6;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM = 7;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS = 8;
public static final String NSFW_AND_SPOILER_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.nsfw_and_spoiler";
public static final String NSFW_BASE = "_nsfw";