aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDocile-Alligator <chineseperson5@gmail.com>2022-02-28 08:45:30 +0000
committerDocile-Alligator <chineseperson5@gmail.com>2022-02-28 08:45:30 +0000
commit405317b4cb51fb389d86e63dbc9f1c028ca9b1c1 (patch)
treec29aec616b632b1ab9c763a82b44a9393411731f
parent5e0b2662d758e3401030ef5955e12f33eec69b23 (diff)
downloadinfinity-for-reddit-405317b4cb51fb389d86e63dbc9f1c028ca9b1c1.tar
infinity-for-reddit-405317b4cb51fb389d86e63dbc9f1c028ca9b1c1.tar.gz
infinity-for-reddit-405317b4cb51fb389d86e63dbc9f1c028ca9b1c1.tar.bz2
infinity-for-reddit-405317b4cb51fb389d86e63dbc9f1c028ca9b1c1.tar.lz
infinity-for-reddit-405317b4cb51fb389d86e63dbc9f1c028ca9b1c1.tar.xz
infinity-for-reddit-405317b4cb51fb389d86e63dbc9f1c028ca9b1c1.tar.zst
infinity-for-reddit-405317b4cb51fb389d86e63dbc9f1c028ca9b1c1.zip
Fix changing default post layout not working.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java48
1 files changed, 27 insertions, 21 deletions
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 dc8232e3..22071f55 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -1555,23 +1555,29 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void changePostLayout(int postLayout) {
+ changePostLayout(postLayout, false);
+ }
+
+ public void changePostLayout(int postLayout, boolean temporary) {
this.postLayout = postLayout;
- switch (postType) {
- case PostPagingSource.TYPE_FRONT_PAGE:
- mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply();
- break;
- case PostPagingSource.TYPE_SUBREDDIT:
- mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, postLayout).apply();
- break;
- case PostPagingSource.TYPE_USER:
- mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, postLayout).apply();
- break;
- case PostPagingSource.TYPE_SEARCH:
- mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, postLayout).apply();
- break;
- case PostPagingSource.TYPE_MULTI_REDDIT:
- mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, postLayout).apply();
- break;
+ if (!temporary) {
+ switch (postType) {
+ case PostPagingSource.TYPE_FRONT_PAGE:
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply();
+ break;
+ case PostPagingSource.TYPE_SUBREDDIT:
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, postLayout).apply();
+ break;
+ case PostPagingSource.TYPE_USER:
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, postLayout).apply();
+ break;
+ case PostPagingSource.TYPE_SEARCH:
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, postLayout).apply();
+ break;
+ case PostPagingSource.TYPE_MULTI_REDDIT:
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, postLayout).apply();
+ break;
+ }
}
int previousPosition = -1;
@@ -1802,27 +1808,27 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
switch (postType) {
case PostPagingSource.TYPE_SUBREDDIT:
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + bundle.getString(EXTRA_NAME))) {
- changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
+ changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout, true);
}
break;
case PostPagingSource.TYPE_USER:
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + bundle.getString(EXTRA_USER_NAME))) {
- changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
+ changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout, true);
}
break;
case PostPagingSource.TYPE_MULTI_REDDIT:
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + bundle.getString(EXTRA_NAME))) {
- changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
+ changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout, true);
}
break;
case PostPagingSource.TYPE_SEARCH:
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST)) {
- changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
+ changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout, true);
}
break;
case PostPagingSource.TYPE_FRONT_PAGE:
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST)) {
- changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
+ changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout, true);
}
break;
}