diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-08-06 12:59:13 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-08-06 12:59:13 +0000 |
commit | 22c47fd10b464b509ceb6700b42583607c362b31 (patch) | |
tree | bfc956bf01691870df2960a3acb4ad84aac53128 /app/src/main | |
parent | 326cbd406461b727f9afd9ffe519732e2a20d1b3 (diff) | |
download | infinity-for-reddit-22c47fd10b464b509ceb6700b42583607c362b31.tar infinity-for-reddit-22c47fd10b464b509ceb6700b42583607c362b31.tar.gz infinity-for-reddit-22c47fd10b464b509ceb6700b42583607c362b31.tar.bz2 infinity-for-reddit-22c47fd10b464b509ceb6700b42583607c362b31.tar.lz infinity-for-reddit-22c47fd10b464b509ceb6700b42583607c362b31.tar.xz infinity-for-reddit-22c47fd10b464b509ceb6700b42583607c362b31.tar.zst infinity-for-reddit-22c47fd10b464b509ceb6700b42583607c362b31.zip |
Set max image height to 2000px in PostRecyclerViewAdapter and PostDetailRecyclerViewAdapter.
Diffstat (limited to '')
2 files changed, 20 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 16f505c1..98a74bb0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -1,5 +1,7 @@ package ml.docilealligator.infinityforreddit.adapters; +import static ml.docilealligator.infinityforreddit.activities.CommentActivity.WRITE_COMMENT_REQUEST_CODE; + import android.content.Intent; import android.content.SharedPreferences; import android.content.res.ColorStateList; @@ -115,8 +117,6 @@ import ml.docilealligator.infinityforreddit.utils.Utils; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; -import static ml.docilealligator.infinityforreddit.activities.CommentActivity.WRITE_COMMENT_REQUEST_CODE; - public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> 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; @@ -126,6 +126,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler 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 MAX_IMAGE_HEIGHT = 2000; private AppCompatActivity mActivity; private ViewPostDetailFragment mFragment; @@ -720,8 +721,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler Post.Preview preview = getSuitablePreview(mPost.getPreviews()); if (preview != null) { - if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { - int height = (int) (400 * mScale); + if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 || preview.getPreviewHeight() > MAX_IMAGE_HEIGHT) { + int height = preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 ? (int) (400 * mScale) : (int) (MAX_IMAGE_HEIGHT * mScale); ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height; preview.setPreviewWidth(mImageViewWidth); 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 9d08d880..184b3991 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -116,6 +116,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView private static final int VIEW_TYPE_POST_CARD_2_TEXT_TYPE = 8; private static final int VIEW_TYPE_ERROR = 9; private static final int VIEW_TYPE_LOADING = 10; + private static final int MAX_IMAGE_HEIGHT = 2000; private static final DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() { @Override @@ -810,8 +811,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post.Preview preview = getSuitablePreview(post.getPreviews()); if (preview != null) { ((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE); - if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { - int height = (int) (400 * mScale); + if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 || preview.getPreviewHeight() > MAX_IMAGE_HEIGHT) { + int height = preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 ? (int) (400 * mScale) : (int) (MAX_IMAGE_HEIGHT * mScale); ((PostWithPreviewTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height; preview.setPreviewWidth(mImageViewWidth); @@ -944,8 +945,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post.Preview preview = getSuitablePreview(post.getPreviews()); if (preview != null) { ((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.VISIBLE); - if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { - int height = (int) (400 * mScale); + if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 || preview.getPreviewHeight() > MAX_IMAGE_HEIGHT) { + int height = preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 ? (int) (400 * mScale) : (int) (MAX_IMAGE_HEIGHT * mScale); ((PostCard2WithPreviewViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((PostCard2WithPreviewViewHolder) holder).imageView.getLayoutParams().height = height; preview.setPreviewWidth(mImageViewWidth); @@ -1339,8 +1340,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post.Preview preview = getSuitablePreview(post.getPreviews()); if (preview != null) { - if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { - int height = (int) (400 * mScale); + if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 || preview.getPreviewHeight() > MAX_IMAGE_HEIGHT) { + int height = preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 ? (int) (400 * mScale) : (int) (MAX_IMAGE_HEIGHT * mScale); ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height; preview.setPreviewWidth(mImageViewWidth); @@ -1374,8 +1375,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post.Preview preview = getSuitablePreview(post.getPreviews()); if (preview != null) { - if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { - int height = (int) (400 * mScale); + if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 || preview.getPreviewHeight() > MAX_IMAGE_HEIGHT) { + int height = preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 ? (int) (400 * mScale) : (int) (MAX_IMAGE_HEIGHT * mScale); ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height; preview.setPreviewWidth(mImageViewWidth); @@ -1399,8 +1400,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post.Preview preview = getSuitablePreview(post.getPreviews()); if (preview != null) { - if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { - int height = (int) (400 * mScale); + if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 || preview.getPreviewHeight() > MAX_IMAGE_HEIGHT) { + int height = preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 ? (int) (400 * mScale) : (int) (MAX_IMAGE_HEIGHT * mScale); ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height; preview.setPreviewWidth(mImageViewWidth); @@ -1424,8 +1425,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post.Preview preview = getSuitablePreview(post.getPreviews()); if (preview != null) { - if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { - int height = (int) (400 * mScale); + if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 || preview.getPreviewHeight() > MAX_IMAGE_HEIGHT) { + int height = preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 ? (int) (400 * mScale) : (int) (MAX_IMAGE_HEIGHT * mScale); ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height; preview.setPreviewWidth(mImageViewWidth); @@ -1459,8 +1460,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post.Preview preview = getSuitablePreview(post.getPreviews()); if (preview != null) { - if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { - int height = (int) (400 * mScale); + if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 || preview.getPreviewHeight() > MAX_IMAGE_HEIGHT) { + int height = preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0 ? (int) (400 * mScale) : (int) (MAX_IMAGE_HEIGHT * mScale); ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height; preview.setPreviewWidth(mImageViewWidth); |