mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Set max image height to 2000px in PostRecyclerViewAdapter and PostDetailRecyclerViewAdapter.
This commit is contained in:
parent
326cbd4064
commit
22c47fd10b
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user