From 85a51d7dc8e0d36563f7a3e1f5ec40a68967c835 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sun, 16 Jan 2022 15:19:55 +0800 Subject: New option: Fixed height preview in card. --- .../adapters/PostRecyclerViewAdapter.java | 28 +++++++++++++--------- .../ChangeFixedHeightPreviewInCardEvent.java | 9 +++++++ .../infinityforreddit/fragments/PostFragment.java | 9 +++++++ .../settings/PostPreferenceFragment.java | 9 +++++++ .../utils/SharedPreferencesUtils.java | 1 + 5 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeFixedHeightPreviewInCardEvent.java (limited to 'app/src/main/java') 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 cec20a29..82ccc212 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -206,6 +206,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { @@ -142,5 +144,12 @@ public class PostPreferenceFragment extends CustomFontPreferenceFragmentCompat { } }); } + + if (fixedHeightPreviewInCardSwitch != null) { + fixedHeightPreviewInCardSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeFixedHeightPreviewInCardEvent((Boolean) newValue)); + return true; + }); + } } } \ No newline at end of file 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 fad3a640..e5713e4f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -200,6 +200,7 @@ public class SharedPreferencesUtils { public static final String DEFAULT_PLAYBACK_SPEED = "default_playback_speed"; public static final String LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI = "legacy_autoplay_video_controller_ui"; public static final String PINCH_TO_ZOOM_VIDEO = "pinch_to_zoom_video"; + public static final String FIXED_HEIGHT_PREVIEW_IN_CARD = "fixed_height_preview_in_card"; 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