From 568aa7a78f37f7dd4c4c027e9701467887da799f Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 20 Jul 2021 20:13:11 +0800 Subject: New option: Default Link Post Layout. --- .../adapters/PostRecyclerViewAdapter.java | 55 +++++++++++++++++++++- .../events/ChangeDefaultLinkPostLayoutEvent.java | 9 ++++ .../infinityforreddit/fragments/PostFragment.java | 9 ++++ .../settings/PostPreferenceFragment.java | 9 ++++ .../utils/SharedPreferencesUtils.java | 1 + 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeDefaultLinkPostLayoutEvent.java (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index c0f29cce..ff3ff317 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -148,6 +148,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { + EventBus.getDefault().post(new ChangeDefaultLinkPostLayoutEvent(Integer.parseInt((String) newValue))); + return true; + }); + } + if (showDividerInCompactLayoutSwitch != null) { showDividerInCompactLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ShowDividerInCompactLayoutPreferenceEvent((Boolean) newValue)); 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 a9a75626..470aad37 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -184,6 +184,7 @@ public class SharedPreferencesUtils { public static final String APPLY_MATERIAL_YOU = "apply_material_you"; public static final String VIDEO_PLAYER_AUTOMATIC_LANDSCAPE_ORIENTATION = "video_player_automatic_landscape_orientation"; public static final String REMEMBER_MUTING_OPTION_IN_POST_FEED = "remember_muting_option_in_post_feed"; + public static final String DEFAULT_LINK_POST_LAYOUT_KEY = "default_link_post_layout"; public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; -- cgit v1.2.3