From 03b5170b97c2836222da264e6b09e4c0cba22216 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Fri, 14 Apr 2023 13:46:00 -0300 Subject: [PATCH] Add logging around in-thread image sizing. --- .../securesms/components/ThumbnailView.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/ThumbnailView.java b/app/src/main/java/org/thoughtcrime/securesms/components/ThumbnailView.java index a09727f3d8..36e4137b63 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ThumbnailView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/ThumbnailView.java @@ -290,12 +290,20 @@ public class ThumbnailView extends FrameLayout { } public void setBounds(int minWidth, int maxWidth, int minHeight, int maxHeight) { + final int oldMinWidth = bounds[MIN_WIDTH]; + final int oldMaxWidth = bounds[MAX_WIDTH]; + final int oldMinHeight = bounds[MIN_HEIGHT]; + final int oldMaxHeight = bounds[MAX_HEIGHT]; + bounds[MIN_WIDTH] = minWidth; bounds[MAX_WIDTH] = maxWidth; bounds[MIN_HEIGHT] = minHeight; bounds[MAX_HEIGHT] = maxHeight; - forceLayout(); + if (oldMinWidth != minWidth || oldMaxWidth != maxWidth || oldMinHeight != minHeight || oldMaxHeight != maxHeight) { + Log.d(TAG, "setBounds: update {minW" + minWidth + ",maxW" + maxWidth + ",minH" + minHeight + ",maxH" + maxHeight + "}"); + forceLayout(); + } } public void setImageDrawable(@NonNull GlideRequests glideRequests, @Nullable Drawable drawable) { @@ -452,9 +460,7 @@ public class ThumbnailView extends FrameLayout { request = request.transition(withCrossFade()); } - if (width > 0 && height > 0) { - request = request.override(width, height); - } + request = override(request, width, height); GlideDrawableListeningTarget target = new GlideDrawableListeningTarget(image, future); Request previousRequest = target.getRequest(); @@ -482,9 +488,7 @@ public class ThumbnailView extends FrameLayout { .placeholder(model.getPlaceholder()) .transition(withCrossFade()); - if (width > 0 && height > 0) { - request = request.override(width, height); - } + request = override(request, width, height); request.into(new GlideDrawableListeningTarget(image, future)); blurHash.setImageDrawable(null); @@ -492,6 +496,16 @@ public class ThumbnailView extends FrameLayout { return future; } + private GlideRequest override(@NonNull GlideRequest request, int width, int height) { + if (width > 0 && height > 0) { + Log.d(TAG, "override: apply w" + width + "xh" + height); + return request.override(width, height); + } else { + Log.d(TAG, "override: skip w" + width + "xh" + height); + return request; + } + } + public void setThumbnailClickListener(SlideClickListener listener) { this.thumbnailClickListener = listener; } @@ -572,7 +586,7 @@ public class ThumbnailView extends FrameLayout { size[HEIGHT] = getDefaultHeight(); } - return request.override(size[WIDTH], size[HEIGHT]); + return override(request, size[WIDTH], size[HEIGHT]); } private int getDefaultWidth() {