diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java index 25f82e1e..bdfb619f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java @@ -124,20 +124,21 @@ import static ml.docilealligator.infinityforreddit.activities.CommentActivity.WR public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter implements CacheManager { private static final int VIEW_TYPE_POST_DETAIL_VIDEO_AUTOPLAY = 1; private static final int VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW = 2; - private static final int VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY = 3; - private static final int VIEW_TYPE_POST_DETAIL_LINK = 4; - private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 5; - private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 6; - private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 7; - private static final int VIEW_TYPE_FIRST_LOADING = 8; - private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 9; - private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 10; - private static final int VIEW_TYPE_COMMENT = 11; - private static final int VIEW_TYPE_COMMENT_FULLY_COLLAPSED = 12; - private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 13; - private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 14; - private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 15; - private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 16; + private static final int VIEW_TYPE_POST_DETAIL_IMAGE = 3; + private static final int VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY = 4; + private static final int VIEW_TYPE_POST_DETAIL_LINK = 5; + private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 6; + private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 7; + private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 8; + private static final int VIEW_TYPE_FIRST_LOADING = 9; + private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 10; + private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 11; + private static final int VIEW_TYPE_COMMENT = 12; + private static final int VIEW_TYPE_COMMENT_FULLY_COLLAPSED = 13; + private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 14; + private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 15; + private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 16; + private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 17; private AppCompatActivity mActivity; private Retrofit mRetrofit; @@ -178,6 +179,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter previews = post.getPreviews(); if (previews != null && !previews.isEmpty()) { + if (post.getPostType() != Post.GIF_TYPE && post.getPostType() != Post.VIDEO_TYPE) { + ((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.VISIBLE); + ((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.VISIBLE); + } loadImage(holder, post, previews.get(0)); } } @@ -960,15 +966,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { @@ -35,5 +37,12 @@ public class DataSavingModePreferenceFragment extends PreferenceFragmentCompat { return true; }); } + + if (onlyDisablePreviewInVideoAndGifPostsPreference != null) { + onlyDisablePreviewInVideoAndGifPostsPreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeOnlyDisablePreviewInVideoAndGifPostsEvent((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 8cfd5ce5..c288bb15 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -149,6 +149,7 @@ public class SharedPreferencesUtils { public static final String LANGUAGE_DEFAULT_VALUE = "auto"; public static final String ENABLE_SEARCH_HISTORY = "enable_search_history"; public static final String POST_FILTER = "post_filter"; + public static final String ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS = "only_disable_preview_in_video_and_gif_posts"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index aebcb892..ae44cf19 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ Infinity Login - Search + Send Comment Reply Text Post @@ -517,6 +517,7 @@ UFO Capturing Animation Hide Subreddit Description Disable Image Preview in Data Saving Mode + Only Disable Preview in Video and Gif Posts Swipe Left Swipe Right Not applicable to post feed with more than 1 column or post detail. diff --git a/app/src/main/res/xml/data_saving_mode_preferences.xml b/app/src/main/res/xml/data_saving_mode_preferences.xml index e635f2db..6ff3f04a 100644 --- a/app/src/main/res/xml/data_saving_mode_preferences.xml +++ b/app/src/main/res/xml/data_saving_mode_preferences.xml @@ -20,4 +20,9 @@ app:key="disable_image_preview" android:title="@string/settings_disable_image_preview_title" /> + + \ No newline at end of file