Fixed race condition

pull/187/head
M66B 4 years ago
parent bcb9f8963d
commit 42999a270b

@ -82,7 +82,6 @@ Related questions:
* A preview of a message text doesn't (always) appear on Samsung watches because [setLocalOnly](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder.html#setLocalOnly(boolean)) seem to be ignored. Message preview texts are known to be displayed correctly on Pebble 2, Fitbit Charge 3, and Mi band 3 wearables. See also [this FAQ](#user-content-faq126). * A preview of a message text doesn't (always) appear on Samsung watches because [setLocalOnly](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder.html#setLocalOnly(boolean)) seem to be ignored. Message preview texts are known to be displayed correctly on Pebble 2, Fitbit Charge 3, and Mi band 3 wearables. See also [this FAQ](#user-content-faq126).
* A [bug in Android 6.0](https://issuetracker.google.com/issues/37068143) causes a crash with *... Invalid offset: ... Valid range is ...* when text is selected and tapping outside of the selected text. This bug has been fixed in Android 6.0.1. * A [bug in Android 6.0](https://issuetracker.google.com/issues/37068143) causes a crash with *... Invalid offset: ... Valid range is ...* when text is selected and tapping outside of the selected text. This bug has been fixed in Android 6.0.1.
* Internal (anchor) links will not work because original messages are shown in an embedded WebView in a scrolling view (the conversation list). This is an Android limitation which cannot be fixed or worked around. * Internal (anchor) links will not work because original messages are shown in an embedded WebView in a scrolling view (the conversation list). This is an Android limitation which cannot be fixed or worked around.
* The expanded/collapsed state and the visibility of the message body are sometimes not in sync. This seems to be caused by a bug in the AndroidX ConstraintLayout.
## Planned features ## Planned features

@ -3529,16 +3529,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
else { else {
boolean expanded = !properties.getValue("expanded", message.id); boolean expanded = !properties.getValue("expanded", message.id);
// Prevent flicker
if (expanded && message.accountAutoSeen && !message.folderReadOnly) {
message.unseen = 0;
message.ui_seen = true;
message.visible_unseen = 0;
message.ui_unsnoozed = false;
}
properties.setValue("expanded", message.id, expanded);
bindTo(message, expanded);
properties.setExpanded(message, expanded); properties.setExpanded(message, expanded);
// Needed to scroll to item after collapsing other items // Needed to scroll to item after collapsing other items
@ -4288,10 +4278,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (amessage == null || !amessage.id.equals(id)) if (amessage == null || !amessage.id.equals(id))
return; return;
properties.setExpanded(message, false);
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);
bindTo(message, false); properties.setExpanded(message, false);
} }
@Override @Override

@ -1653,6 +1653,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
setValue("expanded", message.id, value); setValue("expanded", message.id, value);
final int p = adapter.getPositionForKey(message.id);
if (p != NO_POSITION)
rvMessage.post(new Runnable() {
@Override
public void run() {
try {
adapter.notifyItemChanged(p);
} catch (Throwable ex) {
Log.e(ex);
}
}
});
// Collapse other messages // Collapse other messages
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean expand_all = prefs.getBoolean("expand_all", false); boolean expand_all = prefs.getBoolean("expand_all", false);

Loading…
Cancel
Save