mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Scroll after loading images
This commit is contained in:
parent
6242348d32
commit
da1cf00c57
1 changed files with 29 additions and 34 deletions
|
@ -965,7 +965,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
//tvFrom.setText(info.getDisplayName(name_email));
|
||||
}
|
||||
|
||||
private void bindExpanded(final TupleMessageEx message, boolean scroll) {
|
||||
private void bindExpanded(final TupleMessageEx message, final boolean scroll) {
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
boolean show_addresses = !properties.getValue("addresses", message.id);
|
||||
|
@ -1091,26 +1091,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
// Attachments
|
||||
bindAttachments(message, properties.getAttachments(message.id));
|
||||
cowner.recreate();
|
||||
db.attachment().liveAttachments(message.id).observe(cowner, new Observer<List<EntityAttachment>>() {
|
||||
private int lastInlineImages = 0;
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAttachment> attachments) {
|
||||
bindAttachments(message, attachments);
|
||||
|
||||
int inlineImages = 0;
|
||||
if (attachments != null)
|
||||
for (EntityAttachment attachment : attachments)
|
||||
if (attachment.available && attachment.isInline() && attachment.isImage())
|
||||
inlineImages++;
|
||||
|
||||
if (inlineImages != lastInlineImages) {
|
||||
lastInlineImages = inlineImages;
|
||||
loadText(message, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Setup actions
|
||||
Bundle sargs = new Bundle();
|
||||
|
@ -1193,12 +1173,32 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvBody.setMovementMethod(null);
|
||||
tvBody.setVisibility(View.VISIBLE);
|
||||
|
||||
if (scroll && body != null) {
|
||||
properties.scrollTo(getAdapterPosition());
|
||||
scroll = false;
|
||||
}
|
||||
cowner.recreate();
|
||||
|
||||
loadText(message, scroll);
|
||||
loadText(message);
|
||||
|
||||
db.attachment().liveAttachments(message.id).observe(cowner, new Observer<List<EntityAttachment>>() {
|
||||
private int lastInlineImages = 0;
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAttachment> attachments) {
|
||||
bindAttachments(message, attachments);
|
||||
|
||||
int inlineImages = 0;
|
||||
if (attachments != null)
|
||||
for (EntityAttachment attachment : attachments)
|
||||
if (attachment.available && attachment.isInline() && attachment.isImage())
|
||||
inlineImages++;
|
||||
|
||||
if (inlineImages != lastInlineImages) {
|
||||
lastInlineImages = inlineImages;
|
||||
loadText(message);
|
||||
}
|
||||
|
||||
if (scroll)
|
||||
properties.scrollTo(getAdapterPosition());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void bindAttachments(final TupleMessageEx message, @Nullable List<EntityAttachment> attachments) {
|
||||
|
@ -2117,7 +2117,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
ibImages.setVisibility(View.GONE);
|
||||
|
||||
loadText(message, false);
|
||||
loadText(message);
|
||||
|
||||
// Download inline images
|
||||
Bundle args = new Bundle();
|
||||
|
@ -2501,7 +2501,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
popupMenu.show();
|
||||
}
|
||||
|
||||
private void loadText(TupleMessageEx message, boolean scroll) {
|
||||
private void loadText(TupleMessageEx message) {
|
||||
if (message.content) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (message.from != null)
|
||||
|
@ -2518,7 +2518,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("message", message);
|
||||
args.putBoolean("scroll", scroll);
|
||||
args.putBoolean("show_images", show_images);
|
||||
args.putBoolean("show_quotes", show_quotes);
|
||||
args.putInt("zoom", zoom);
|
||||
|
@ -2638,7 +2637,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
if (!show_expanded)
|
||||
return;
|
||||
|
||||
boolean scroll = args.getBoolean("scroll");
|
||||
boolean has_images = args.getBoolean("has_images");
|
||||
boolean show_images = properties.getValue("images", message.id);
|
||||
|
||||
|
@ -2650,9 +2648,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvBody.setTextIsSelectable(true);
|
||||
tvBody.setMovementMethod(new TouchHandler(message));
|
||||
|
||||
if (scroll)
|
||||
properties.scrollTo(getAdapterPosition());
|
||||
|
||||
pbBody.setVisibility(View.GONE);
|
||||
|
||||
// Show attachments/images
|
||||
|
@ -2731,7 +2726,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
DynamicDrawableSpan[] ddss = buffer.getSpans(off, off, DynamicDrawableSpan.class);
|
||||
if (ddss.length > 0) {
|
||||
properties.setValue("quotes", message.id, true);
|
||||
loadText(message, false);
|
||||
loadText(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue