Fix changing post layout not working in HistoryActivity.

This commit is contained in:
Docile-Alligator 2022-07-19 10:30:59 +08:00
parent a8d8e08323
commit 55af125dfe
3 changed files with 6 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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;