mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Continue adding Gallery Layout.
This commit is contained in:
parent
3fab4fd90d
commit
83ffdb5511
@ -1057,7 +1057,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
Post post = getItem(position);
|
||||
if (post != null) {
|
||||
switch (post.getPostType()) {
|
||||
case Post.IMAGE_TYPE:
|
||||
case Post.IMAGE_TYPE: {
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -1080,39 +1080,121 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
|
||||
} else if (post.getPostType() == Post.IMAGE_TYPE || post.getPostType() == Post.GIF_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
|
||||
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
|
||||
} else if (post.getPostType() == Post.LINK_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
|
||||
} else if (post.getPostType() == Post.GALLERY_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
|
||||
}
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
|
||||
}
|
||||
break;
|
||||
case Post.GIF_TYPE:
|
||||
}
|
||||
case Post.GIF_TYPE: {
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
|
||||
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
if (preview != null) {
|
||||
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
preview.setPreviewWidth(mImageViewWidth);
|
||||
preview.setPreviewHeight(height);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
loadImage(holder, post, preview);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
|
||||
}
|
||||
break;
|
||||
case Post.VIDEO_TYPE:
|
||||
}
|
||||
case Post.VIDEO_TYPE: {
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
|
||||
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
if (preview != null) {
|
||||
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
preview.setPreviewWidth(mImageViewWidth);
|
||||
preview.setPreviewHeight(height);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
loadImage(holder, post, preview);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
|
||||
}
|
||||
break;
|
||||
case Post.LINK_TYPE:
|
||||
}
|
||||
case Post.LINK_TYPE: {
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
if (preview != null) {
|
||||
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
preview.setPreviewWidth(mImageViewWidth);
|
||||
preview.setPreviewHeight(height);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
loadImage(holder, post, preview);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
|
||||
}
|
||||
break;
|
||||
case Post.NO_PREVIEW_LINK_TYPE:
|
||||
}
|
||||
case Post.NO_PREVIEW_LINK_TYPE: {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
|
||||
break;
|
||||
case Post.TEXT_TYPE:
|
||||
}
|
||||
case Post.TEXT_TYPE: {
|
||||
((PostGalleryViewHolder) holder).titleTextView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).titleTextView.setText(post.getTitle());
|
||||
break;
|
||||
case Post.GALLERY_TYPE:
|
||||
}
|
||||
case Post.GALLERY_TYPE: {
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
if (preview != null) {
|
||||
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
preview.setPreviewWidth(mImageViewWidth);
|
||||
preview.setPreviewHeight(height);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
loadImage(holder, post, preview);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user