From 67f2ba955f8f94ec8b72c1fb963b618ba5c32788 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 2 Mar 2021 17:08:11 +0800 Subject: Add more options for tabs in MainActivity. --- .../infinityforreddit/activities/MainActivity.java | 27 ++++++++++++++++++++++ .../utils/SharedPreferencesUtils.java | 5 ++++ 2 files changed, 32 insertions(+) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 18955498..98e2306b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -1455,6 +1455,33 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_SUBMITTED); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); + fragment.setArguments(bundle); + return fragment; + } else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_UPVOTED + || postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_DOWNVOTED + || postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HIDDEN + || postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SAVED + || postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_GILDED) { + PostFragment fragment = new PostFragment(); + Bundle bundle = new Bundle(); + bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); + bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName); + bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); + bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); + bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true); + + if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_UPVOTED) { + bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_UPVOTED); + } else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_DOWNVOTED) { + bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_DOWNVOTED); + } else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HIDDEN) { + bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_HIDDEN); + } else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SAVED) { + bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_SAVED); + } else { + bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_GILDED); + } + fragment.setArguments(bundle); return fragment; } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index be8489a9..5670b82f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -188,6 +188,11 @@ public class SharedPreferencesUtils { public static final int MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT = 3; public static final int MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT = 4; public static final int MAIN_PAGE_TAB_POST_TYPE_USER = 5; + public static final int MAIN_PAGE_TAB_POST_TYPE_UPVOTED = 6; + public static final int MAIN_PAGE_TAB_POST_TYPE_DOWNVOTED = 7; + public static final int MAIN_PAGE_TAB_POST_TYPE_HIDDEN = 8; + public static final int MAIN_PAGE_TAB_POST_TYPE_SAVED = 9; + public static final int MAIN_PAGE_TAB_POST_TYPE_GILDED = 10; public static final String MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS = "_main_page_show_subscribed_subreddits"; public static final String MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS = "_main_page_show_favorite_subscribed_subreddits"; -- cgit v1.2.3