Browse Source

Fix weird layout behavior due to async binding

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
6aacf1945f
  1. 5
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java
  2. 5
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java
  3. 15
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java

5
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemActionLogViewHolder.java

@ -78,6 +78,11 @@ public class DirectItemActionLogViewHolder extends DirectItemViewHolder {
return false; return false;
} }
@Override
protected boolean showUserDetailsInGroup() {
return false;
}
@Override @Override
protected boolean showMessageInfo() { protected boolean showMessageInfo() {
return false; return false;

5
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemVideoCallEventViewHolder.java

@ -68,6 +68,11 @@ public class DirectItemVideoCallEventViewHolder extends DirectItemViewHolder {
return false; return false;
} }
@Override
protected boolean showUserDetailsInGroup() {
return false;
}
@Override @Override
protected boolean showMessageInfo() { protected boolean showMessageInfo() {
return false; return false;

15
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) { public void bind(final int position, final DirectItem item) {
this.item = item; this.item = item;
messageDirection = isSelf(item) ? MessageDirection.OUTGOING : MessageDirection.INCOMING; 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) { private void bindBase(final DirectItem item, final MessageDirection messageDirection, final int position) {
@ -134,8 +135,10 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
if (itemType == DirectItemType.TEXT || itemType == DirectItemType.LINK) { if (itemType == DirectItemType.TEXT || itemType == DirectItemType.LINK) {
binding.messageInfo.setPadding(0, 0, dmRadius, dmRadiusSmall); binding.messageInfo.setPadding(0, 0, dmRadius, dmRadiusSmall);
} else { } else {
if (showMessageInfo()) {
binding.messageInfo.setPadding(0, 0, messageInfoPaddingSmall, dmRadiusSmall); binding.messageInfo.setPadding(0, 0, messageInfoPaddingSmall, dmRadiusSmall);
} }
}
setupReply(item, messageDirection); setupReply(item, messageDirection);
setReactions(item, position); setReactions(item, position);
if (item.getRepliedToMessage() == null && item.showForwardAttribution()) { if (item.getRepliedToMessage() == null && item.showForwardAttribution()) {

Loading…
Cancel
Save