From 55af125dfeb6a187dcd114164bd8690114eb5c84 Mon Sep 17 00:00:00 2001 From: Docile-Alligator Date: Tue, 19 Jul 2022 10:30:59 +0800 Subject: Fix changing post layout not working in HistoryActivity. --- .../infinityforreddit/activities/HistoryActivity.java | 6 +++--- .../infinityforreddit/fragments/HistoryPostFragment.java | 4 ++-- .../infinityforreddit/utils/SharedPreferencesUtils.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java index 19a0849b..020d0396 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java @@ -242,7 +242,7 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte @Override public void postLayoutSelected(int postLayout) { if (sectionsPagerAdapter != null) { - mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + mAccountName, postLayout).apply(); + mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, postLayout).apply(); sectionsPagerAdapter.changePostLayout(postLayout); } } @@ -311,8 +311,8 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte public void changePostLayout(int postLayout) { Fragment fragment = getCurrentFragment(); - if (fragment instanceof PostFragment) { - ((PostFragment) fragment).changePostLayout(postLayout); + if (fragment instanceof HistoryPostFragment) { + ((HistoryPostFragment) fragment).changePostLayout(postLayout); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java index 89b2531c..e7114c59 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java @@ -336,7 +336,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato Locale locale = getResources().getConfiguration().locale; if (historyType == HISTORY_TYPE_READ_POSTS) { - postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout); + postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, defaultPostLayout); mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale, @@ -813,7 +813,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato if (!temporary) { switch (postType) { case HistoryPostPagingSource.TYPE_READ_POSTS: - mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply(); + mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, postLayout).apply(); } } 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 cadb24cd..3b431a42 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -68,7 +68,7 @@ public class SharedPreferencesUtils { public static final String POST_LAYOUT_MULTI_REDDIT_POST_BASE = "post_layout_multi_reddit_post_"; public static final String POST_LAYOUT_USER_POST_BASE = "post_layout_user_post_"; public static final String POST_LAYOUT_SEARCH_POST = "post_layout_search_post"; - public static final String HISTORY_POST_LAYOUT_FRONT_PAGE_POST = "history_post_layout_read_post"; + public static final String HISTORY_POST_LAYOUT_READ_POST = "history_post_layout_read_post"; public static final int POST_LAYOUT_CARD = 0; public static final int POST_LAYOUT_COMPACT = 1; public static final int POST_LAYOUT_GALLERY = 2; -- cgit v1.2.3