From 6aacf1945fa87d8ec42fa3ad83b477e9103d87aa Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sun, 17 Jan 2021 23:15:03 +0900 Subject: [PATCH] Fix weird layout behavior due to async binding --- .../DirectItemActionLogViewHolder.java | 5 +++++ .../DirectItemVideoCallEventViewHolder.java | 5 +++++ .../directmessages/DirectItemViewHolder.java | 17 ++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java index 1e195d3c..45c83805 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java @@ -78,6 +78,11 @@ public class DirectItemActionLogViewHolder extends DirectItemViewHolder { return false; } + @Override + protected boolean showUserDetailsInGroup() { + return false; + } + @Override protected boolean showMessageInfo() { return false; diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java index c33c346e..77a43a5a 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java @@ -68,6 +68,11 @@ public class DirectItemVideoCallEventViewHolder extends DirectItemViewHolder { return false; } + @Override + protected boolean showUserDetailsInGroup() { + return false; + } + @Override protected boolean showMessageInfo() { return false; diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java index 3e360503..9ce5d14b 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java @@ -112,12 +112,13 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple public void bind(final int position, final DirectItem item) { this.item = item; messageDirection = isSelf(item) ? MessageDirection.OUTGOING : MessageDirection.INCOMING; - itemView.post(() -> bindBase(item, messageDirection, position)); - itemView.post(() -> bindItem(item, messageDirection)); - itemView.post(() -> setupLongClickListener(position, messageDirection)); - // bindBase(item, messageDirection); - // bindItem(item, messageDirection); - // setupLongClickListener(position); + // Asynchronous binding causes some weird behaviour + // itemView.post(() -> bindBase(item, messageDirection, position)); + // itemView.post(() -> bindItem(item, messageDirection)); + // itemView.post(() -> setupLongClickListener(position, messageDirection)); + bindBase(item, messageDirection, position); + bindItem(item, messageDirection); + setupLongClickListener(position, messageDirection); } private void bindBase(final DirectItem item, final MessageDirection messageDirection, final int position) { @@ -134,7 +135,9 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple if (itemType == DirectItemType.TEXT || itemType == DirectItemType.LINK) { binding.messageInfo.setPadding(0, 0, dmRadius, dmRadiusSmall); } else { - binding.messageInfo.setPadding(0, 0, messageInfoPaddingSmall, dmRadiusSmall); + if (showMessageInfo()) { + binding.messageInfo.setPadding(0, 0, messageInfoPaddingSmall, dmRadiusSmall); + } } setupReply(item, messageDirection); setReactions(item, position);