Fixed scroll on expand

This commit is contained in:
M66B 2020-11-04 07:53:55 +01:00
parent 9906ef5b6b
commit 0842f828a5
2 changed files with 15 additions and 12 deletions

View File

@ -3545,12 +3545,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.putExtra("id", message.id)); .putExtra("id", message.id));
else { else {
boolean expanded = !properties.getValue("expanded", message.id); boolean expanded = !properties.getValue("expanded", message.id);
properties.setExpanded(message, expanded, expanded);
properties.setExpanded(message, expanded);
// Needed to scroll to item after collapsing other items
if (expanded)
properties.scrollTo(getAdapterPosition(), 0);
} }
} }
@ -4298,7 +4293,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
message.ui_seen = args.getBoolean("seen"); message.ui_seen = args.getBoolean("seen");
message.unseen = (message.ui_seen ? 0 : message.count); message.unseen = (message.ui_seen ? 0 : message.count);
properties.setExpanded(message, false); properties.setExpanded(message, false, false);
} }
@Override @Override
@ -5803,8 +5798,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return; return;
} }
boolean scroll = false;
if (viewType == ViewType.THREAD) {
scroll = properties.getValue("scroll", message.id);
properties.setValue("scroll", message.id, false);
}
holder.unwire(); holder.unwire();
holder.bindTo(message, false); holder.bindTo(message, scroll);
holder.wire(); holder.wire();
} }
@ -5886,7 +5887,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean getValue(String name, long id); boolean getValue(String name, long id);
void setExpanded(TupleMessageEx message, boolean expanded); void setExpanded(TupleMessageEx message, boolean expanded, boolean scroll);
void setSize(long id, Float size); void setSize(long id, Float size);

View File

@ -1588,7 +1588,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
@Override @Override
public void setExpanded(TupleMessageEx message, boolean value) { public void setExpanded(TupleMessageEx message, boolean value, boolean scroll) {
// Prevent flicker // Prevent flicker
if (value && message.accountAutoSeen && !message.folderReadOnly) { if (value && message.accountAutoSeen && !message.folderReadOnly) {
message.unseen = 0; message.unseen = 0;
@ -1598,6 +1598,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
setValue("expanded", message.id, value); setValue("expanded", message.id, value);
if (scroll)
setValue("scroll", message.id, true);
final int p = adapter.getPositionForKey(message.id); final int p = adapter.getPositionForKey(message.id);
if (p != NO_POSITION) if (p != NO_POSITION)
@ -4683,7 +4685,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (expand != null && if (expand != null &&
(expand.content || unmetered || (expand.size != null && expand.size < download))) (expand.content || unmetered || (expand.size != null && expand.size < download)))
iProperties.setExpanded(expand, true); iProperties.setExpanded(expand, true, false);
} }
// Auto expand all seen messages // Auto expand all seen messages
@ -4695,7 +4697,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
!message.duplicate && !message.duplicate &&
!EntityFolder.DRAFTS.equals(message.folderType) && !EntityFolder.DRAFTS.equals(message.folderType) &&
!EntityFolder.TRASH.equals(message.folderType)) !EntityFolder.TRASH.equals(message.folderType))
iProperties.setExpanded(message, true); iProperties.setExpanded(message, true, false);
} else { } else {
if (autoCloseCount > 0 && (autoclose || onclose != null)) { if (autoCloseCount > 0 && (autoclose || onclose != null)) {
List<MessageTarget> mt = new ArrayList<>(); List<MessageTarget> mt = new ArrayList<>();