Possible fix to loading videos on home page

This commit is contained in:
Bazsalanszky 2023-08-05 14:21:08 +02:00
parent d25137020f
commit feeeefa2d2

View File

@ -913,15 +913,15 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
int width = resource.getIntrinsicWidth(); int width = resource.getIntrinsicWidth();
int height = resource.getIntrinsicHeight(); int height = resource.getIntrinsicHeight();
((PostVideoAutoplayViewHolder) holder).previewImageView.setImageDrawable(resource); ((PostCard2VideoAutoplayViewHolder) holder).previewImageView.setImageDrawable(resource);
if (preview.getPreviewHeight() <= 0 || preview.getPreviewWidth() <= 0) { if (preview.getPreviewHeight() <= 0 || preview.getPreviewWidth() <= 0) {
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) height / width); ((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) height / width);
((PostVideoAutoplayViewHolder) holder).previewImageView.getLayoutParams().height = height; ((PostCard2VideoAutoplayViewHolder) holder).previewImageView.getLayoutParams().height = height;
preview.setPreviewHeight(height); preview.setPreviewHeight(height);
preview.setPreviewWidth(width); preview.setPreviewWidth(width);
} else { } else {
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); ((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
((PostVideoAutoplayViewHolder) holder).previewImageView.getLayoutParams().height = height; ((PostCard2VideoAutoplayViewHolder) holder).previewImageView.getLayoutParams().height = height;
} }
} }