From e3efc53b6465ffe70ae176a90185a7cc9ddee48d Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Thu, 22 Jan 2026 11:29:58 -0400 Subject: [PATCH] Squelch resize calls while in a resize loop. --- .../reactions/ReactionsConversationView.java | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/reactions/ReactionsConversationView.java b/app/src/main/java/org/thoughtcrime/securesms/reactions/ReactionsConversationView.java index a19c8d056f..8ca55125d9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/reactions/ReactionsConversationView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/reactions/ReactionsConversationView.java @@ -37,6 +37,7 @@ public class ReactionsConversationView extends LinearLayout { private boolean outgoing; private List records; private int bubbleWidth; + private boolean isSettingBubbleWidth; public ReactionsConversationView(Context context) { super(context); @@ -65,7 +66,7 @@ public class ReactionsConversationView extends LinearLayout { @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { - if (w != oldw) { + if (w != oldw && !isSettingBubbleWidth) { int bubbleWidth = this.bubbleWidth; this.bubbleWidth = -1; @@ -78,38 +79,43 @@ public class ReactionsConversationView extends LinearLayout { return false; } - this.bubbleWidth = bubbleWidth; + isSettingBubbleWidth = true; + try { + this.bubbleWidth = bubbleWidth; - for (int i = 0; i < getChildCount(); i++) { - View pill = getChildAt(i); - pill.setVisibility(bubbleWidth == 0 ? INVISIBLE : VISIBLE); - } - - measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); - - int railWidth = getMeasuredWidth(); - - if (railWidth < (bubbleWidth - OUTER_MARGIN)) { - int margin = (bubbleWidth - railWidth - OUTER_MARGIN); - - if (outgoing) { - setEndMargin(margin); - } else { - setStartMargin(margin); + for (int i = 0; i < getChildCount(); i++) { + View pill = getChildAt(i); + pill.setVisibility(bubbleWidth == 0 ? INVISIBLE : VISIBLE); } - } else { - if (outgoing) { - setEndMargin(OUTER_MARGIN); + + measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); + + int railWidth = getMeasuredWidth(); + + if (railWidth < (bubbleWidth - OUTER_MARGIN)) { + int margin = (bubbleWidth - railWidth - OUTER_MARGIN); + + if (outgoing) { + setEndMargin(margin); + } else { + setStartMargin(margin); + } } else { - setStartMargin(OUTER_MARGIN); + if (outgoing) { + setEndMargin(OUTER_MARGIN); + } else { + setStartMargin(OUTER_MARGIN); + } } - } - if (!isInLayout()) { - requestLayout(); - } + if (!isInLayout()) { + requestLayout(); + } - return true; + return true; + } finally { + isSettingBubbleWidth = false; + } } public boolean setReactions(@NonNull List records) {