mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Split reaction view updates to separate width from adding views.
This commit is contained in:
committed by
Nicholas Tinsley
parent
f37568b050
commit
c45e79c588
@@ -63,24 +63,16 @@ public class ReactionsConversationView extends LinearLayout {
|
||||
removeAllViews();
|
||||
}
|
||||
|
||||
public boolean setReactions(@NonNull List<ReactionRecord> records, int bubbleWidth) {
|
||||
if (records.equals(this.records) && this.bubbleWidth == bubbleWidth) {
|
||||
public boolean setBubbleWidth(int bubbleWidth) {
|
||||
if (bubbleWidth == this.bubbleWidth) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.records.clear();
|
||||
this.records.addAll(records);
|
||||
|
||||
this.bubbleWidth = bubbleWidth;
|
||||
|
||||
List<Reaction> reactions = buildSortedReactionsList(records);
|
||||
|
||||
removeAllViews();
|
||||
|
||||
for (Reaction reaction : reactions) {
|
||||
View pill = buildPill(getContext(), this, reaction);
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View pill = getChildAt(i);
|
||||
pill.setVisibility(bubbleWidth == 0 ? INVISIBLE : VISIBLE);
|
||||
addView(pill);
|
||||
}
|
||||
|
||||
measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
||||
@@ -106,6 +98,26 @@ public class ReactionsConversationView extends LinearLayout {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setReactions(@NonNull List<ReactionRecord> records) {
|
||||
if (records.equals(this.records)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.records.clear();
|
||||
this.records.addAll(records);
|
||||
|
||||
List<Reaction> reactions = buildSortedReactionsList(records);
|
||||
|
||||
removeAllViews();
|
||||
|
||||
for (Reaction reaction : reactions) {
|
||||
View pill = buildPill(getContext(), this, reaction);
|
||||
addView(pill);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static @NonNull List<Reaction> buildSortedReactionsList(@NonNull List<ReactionRecord> records) {
|
||||
Map<String, Reaction> counters = new LinkedHashMap<>();
|
||||
RecipientId selfId = Recipient.self().getId();
|
||||
|
||||
Reference in New Issue
Block a user