Fixed flicker on rebinding body

pull/175/head
M66B 5 years ago
parent ee37f1febd
commit e5911a5284

@ -1475,8 +1475,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bindBody(message); bindBody(message);
db.attachment().liveAttachments(message.id).observe(cowner, new Observer<List<EntityAttachment>>() { db.attachment().liveAttachments(message.id).observe(cowner, new Observer<List<EntityAttachment>>() {
private int lastInlineImages = 0;
@Override @Override
public void onChanged(@Nullable List<EntityAttachment> attachments) { public void onChanged(@Nullable List<EntityAttachment> attachments) {
bindAttachments(message, attachments); bindAttachments(message, attachments);
@ -1487,10 +1485,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (attachment.available && attachment.isInline() && attachment.isImage()) if (attachment.available && attachment.isInline() && attachment.isImage())
inlineImages++; inlineImages++;
if (inlineImages != lastInlineImages) { int lastInlineImages = 0;
lastInlineImages = inlineImages; List<EntityAttachment> lastAttachments = properties.getAttachments(message.id);
if (lastAttachments != null)
for (EntityAttachment attachment : lastAttachments)
if (attachment.available && attachment.isInline() && attachment.isImage())
lastInlineImages++;
if (inlineImages != lastInlineImages)
bindBody(message); bindBody(message);
}
properties.setAttachments(message.id, attachments);
if (scroll) if (scroll)
properties.scrollTo(getAdapterPosition()); properties.scrollTo(getAdapterPosition());

Loading…
Cancel
Save