Debounce menu invalidations in conversation.

fork-5.53.8
Greyson Parrelli 2022-03-17 09:00:10 -04:00 zatwierdzone przez Cody Henthorne
rodzic dc50899fe0
commit 570b39f82e
1 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -109,6 +109,7 @@ import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.ShortcutLauncherActivity; import org.thoughtcrime.securesms.ShortcutLauncherActivity;
import org.thoughtcrime.securesms.TransportOption; import org.thoughtcrime.securesms.TransportOption;
import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel; import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel;
import org.thoughtcrime.securesms.util.Debouncer;
import org.thoughtcrime.securesms.util.LifecycleDisposable; import org.thoughtcrime.securesms.util.LifecycleDisposable;
import org.thoughtcrime.securesms.verify.VerifyIdentityActivity; import org.thoughtcrime.securesms.verify.VerifyIdentityActivity;
import org.thoughtcrime.securesms.attachments.Attachment; import org.thoughtcrime.securesms.attachments.Attachment;
@ -443,6 +444,7 @@ public class ConversationParentFragment extends Fragment
private boolean isSearchRequested = false; private boolean isSearchRequested = false;
private final LifecycleDisposable disposables = new LifecycleDisposable(); private final LifecycleDisposable disposables = new LifecycleDisposable();
private final Debouncer optionsMenuDebouncer = new Debouncer(50);
private volatile boolean screenInitialized = false; private volatile boolean screenInitialized = false;
@ -1109,8 +1111,12 @@ public class ConversationParentFragment extends Fragment
public void invalidateOptionsMenu() { public void invalidateOptionsMenu() {
if (!isSearchRequested && getActivity() != null) { if (!isSearchRequested && getActivity() != null) {
optionsMenuDebouncer.publish(() -> {
if (getActivity() != null) {
onCreateOptionsMenu(toolbar.getMenu(), requireActivity().getMenuInflater()); onCreateOptionsMenu(toolbar.getMenu(), requireActivity().getMenuInflater());
} }
});
}
} }
@Override @Override
@ -2196,7 +2202,7 @@ public class ConversationParentFragment extends Fragment
} }
protected void initializeActionBar() { protected void initializeActionBar() {
onCreateOptionsMenu(toolbar.getMenu(), requireActivity().getMenuInflater()); invalidateOptionsMenu();
toolbar.setOnMenuItemClickListener(this::onOptionsItemSelected); toolbar.setOnMenuItemClickListener(this::onOptionsItemSelected);
if (isInBubble()) { if (isInBubble()) {