mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-08 10:03:51 +02:00
Prevent flicker on expanding messages
This commit is contained in:
@@ -1469,26 +1469,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
values.get(name).add(id);
|
||||
} else
|
||||
values.get(name).remove(id);
|
||||
|
||||
if ("expanded".equals(name)) {
|
||||
// Collapse other messages
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean expand_all = prefs.getBoolean("expand_all", false);
|
||||
boolean expand_one = prefs.getBoolean("expand_one", true);
|
||||
if (!expand_all && expand_one) {
|
||||
for (Long other : new ArrayList<>(values.get(name)))
|
||||
if (!other.equals(id)) {
|
||||
values.get(name).remove(other);
|
||||
int pos = adapter.getPositionForKey(other);
|
||||
if (pos != RecyclerView.NO_POSITION)
|
||||
adapter.notifyItemChanged(pos);
|
||||
}
|
||||
}
|
||||
|
||||
updateExpanded();
|
||||
if (enabled)
|
||||
handleExpand(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1500,6 +1480,36 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setExpanded(TupleMessageEx message, boolean value) {
|
||||
// Prevent flicker
|
||||
if (value &&
|
||||
message.accountProtocol != EntityAccount.TYPE_IMAP ||
|
||||
(message.accountAutoSeen && !message.ui_seen && !message.folderReadOnly)) {
|
||||
message.unseen = 0;
|
||||
message.ui_seen = true;
|
||||
}
|
||||
|
||||
setValue("expanded", message.id, value);
|
||||
|
||||
// Collapse other messages
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean expand_all = prefs.getBoolean("expand_all", false);
|
||||
boolean expand_one = prefs.getBoolean("expand_one", true);
|
||||
if (!expand_all && expand_one) {
|
||||
for (Long other : new ArrayList<>(values.get("expanded")))
|
||||
if (!other.equals(id)) {
|
||||
values.get("expanded").remove(other);
|
||||
int pos = adapter.getPositionForKey(other);
|
||||
if (pos != RecyclerView.NO_POSITION)
|
||||
adapter.notifyItemChanged(pos);
|
||||
}
|
||||
}
|
||||
|
||||
updateExpanded();
|
||||
if (value)
|
||||
handleExpand(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(long id, Float size) {
|
||||
if (size == null)
|
||||
@@ -3769,16 +3779,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
expand = messages.get(0);
|
||||
|
||||
if (expand != null &&
|
||||
(expand.content || unmetered || (expand.size != null && expand.size < download))) {
|
||||
// Prevent flicker
|
||||
if (expand.accountProtocol != EntityAccount.TYPE_IMAP ||
|
||||
(expand.accountAutoSeen && !expand.ui_seen && !expand.folderReadOnly)) {
|
||||
expand.unseen = 0;
|
||||
expand.ui_seen = true;
|
||||
}
|
||||
|
||||
iProperties.setValue("expanded", expand.id, true);
|
||||
}
|
||||
(expand.content || unmetered || (expand.size != null && expand.size < download)))
|
||||
iProperties.setExpanded(expand, true);
|
||||
}
|
||||
|
||||
// Auto expand all seen messages
|
||||
@@ -3786,7 +3788,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
if (expand_all)
|
||||
for (TupleMessageEx message : messages)
|
||||
if (message != null && message.ui_seen)
|
||||
iProperties.setValue("expanded", message.id, true);
|
||||
iProperties.setExpanded(message, true);
|
||||
} else {
|
||||
if (autoCloseCount > 0 && (autoclose || onclose != null)) {
|
||||
int count = 0;
|
||||
|
||||
Reference in New Issue
Block a user