aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-03-28 10:08:55 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-03-28 10:08:55 +0000
commit01b2a0405734b4f40256015b8423b07bcd6699f4 (patch)
tree46b21779eccfe966ed9c501519df9b8fb2d8e80e
parent3adac8a0743a44018ce8509124a7c6506d92839c (diff)
downloadinfinity-for-reddit-01b2a0405734b4f40256015b8423b07bcd6699f4.tar
infinity-for-reddit-01b2a0405734b4f40256015b8423b07bcd6699f4.tar.gz
infinity-for-reddit-01b2a0405734b4f40256015b8423b07bcd6699f4.tar.bz2
infinity-for-reddit-01b2a0405734b4f40256015b8423b07bcd6699f4.tar.lz
infinity-for-reddit-01b2a0405734b4f40256015b8423b07bcd6699f4.tar.xz
infinity-for-reddit-01b2a0405734b4f40256015b8423b07bcd6699f4.tar.zst
infinity-for-reddit-01b2a0405734b4f40256015b8423b07bcd6699f4.zip
Changing individual sort types of subreddits and users is now available.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java8
4 files changed, 12 insertions, 16 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index f62fbc2e..daddd979 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -735,10 +735,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override
public void sortTypeSelected(SortType sortType) {
- mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST, sortType.getType().name()).apply();
- if(sortType.getTime() != null) {
- mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST, sortType.getTime().name()).apply();
- }
sectionsPagerAdapter.changeSortType(sortType);
}
@@ -918,9 +914,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
public void changeSortType(SortType sortType) {
if (postFragment != null) {
- mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST, sortType.getType().name()).apply();
+ mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).apply();
if(sortType.getTime() != null) {
- mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_POST, sortType.getTime().name()).apply();
+ mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, sortType.getTime().name()).apply();
}
postFragment.changeSortType(sortType);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
index e7a6876a..95ce79e1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
@@ -811,9 +811,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
public void changeSortType(SortType sortType) {
if (viewPager.getCurrentItem() == 0) {
if (postFragment != null) {
- mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST, sortType.getType().name()).apply();
+ mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().name()).apply();
if(sortType.getTime() != null) {
- mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_POST, sortType.getTime().name()).apply();
+ mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, sortType.getTime().name()).apply();
}
postFragment.changeSortType(sortType);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 40b10116..25a850bc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -386,9 +386,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, defaultPostLayout);
}
} else {
- sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST, SortType.Type.HOT.name());
+ sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, SortType.Type.HOT.name());
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
- sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST, SortType.Time.ALL.name());
+ sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, SortType.Time.ALL.name());
}
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
}
@@ -487,10 +487,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mFetchPostInfoLinearLayout.setLayoutParams(params);
}
- String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST, SortType.Type.NEW.name());
+ String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, SortType.Type.NEW.name());
SortType sortType;
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
- String sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST, SortType.Time.ALL.name());
+ String sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, SortType.Time.ALL.name());
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
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 08f55dfe..11613fdb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -41,12 +41,12 @@ public class SharedPreferencesUtils {
public static final String SORT_TIME_POPULAR_POST = "sort_time_popular_post";
public static final String SORT_TYPE_SEARCH_POST = "sort_type_search_post";
public static final String SORT_TIME_SEARCH_POST = "sort_time_search_post";
- public static final String SORT_TYPE_SUBREDDIT_POST = "sort_type_subreddit_post";
- public static final String SORT_TIME_SUBREDDIT_POST = "sort_time_subreddit_post";
+ public static final String SORT_TYPE_SUBREDDIT_POST_BASE = "sort_type_subreddit_post_";
+ public static final String SORT_TIME_SUBREDDIT_POST_BASE = "sort_time_subreddit_post_";
public static final String SORT_TYPE_MULTI_REDDIT_POST_BASE = "sort_type_multi_reddit_post_";
public static final String SORT_TIME_MULTI_REDDIT_POST_BASE = "sort_time_multi_reddit_post_";
- public static final String SORT_TYPE_USER_POST = "sort_type_user_post";
- public static final String SORT_TIME_USER_POST = "sort_time_user_post";
+ public static final String SORT_TYPE_USER_POST_BASE = "sort_type_user_post_";
+ public static final String SORT_TIME_USER_POST_BASE = "sort_time_user_post_";
public static final String SORT_TYPE_USER_COMMENT = "sort_type_user_comment";
public static final String SORT_TIME_USER_COMMENT = "sort_time_user_comment";
public static final String SORT_TYPE_SEARCH_SUBREDDIT = "sort_type_search_subreddit";