1
0
Fork 1

Even better animator race guards

This commit is contained in:
Stephen Paul Weber 2024-10-08 22:19:40 +02:00 committed by Arne
parent a64120700c
commit f54e7335de
2 changed files with 10 additions and 3 deletions

View file

@ -1783,6 +1783,13 @@ public class ConversationFragment extends XmppFragment
return adapter;
}
@Override
protected void onViewHidden() {
if (getRecyclerView() == null) return;
try { getRecyclerView().getItemAnimator().endAnimations(); } catch (final Exception e) { }
super.onViewHidden();
}
@Override
protected void onQuery(@Nullable CharSequence query) {
if (activity != null && activity.xmppConnectionService != null && !activity.xmppConnectionService.getBooleanPreference("message_autocomplete", R.bool.message_autocomplete))
@ -1791,8 +1798,7 @@ public class ConversationFragment extends XmppFragment
emojiDebounce.removeCallbacksAndMessages(null);
emojiDebounce.postDelayed(() -> {
if (getRecyclerView() == null) return;
try { getRecyclerView().getItemAnimator().endAnimations(); } catch (final Exception e) { }
adapter.search(activity, query.toString());
adapter.search(activity, getRecyclerView(), query.toString());
}, 100L);
}
})

View file

@ -291,13 +291,14 @@ public class EmojiSearch {
});
}
public void search(final Activity activity, final String q) {
public void search(final Activity activity, final RecyclerView view, final String q) {
executor.execute(() -> {
final List<Emoji> results = find(q);
try {
// Acquire outside so to not block UI thread
doingUpdate.acquire();
activity.runOnUiThread(() -> {
try { view.getItemAnimator().endAnimations(); } catch (final Exception e) { }
submitList(results, () -> {
activity.runOnUiThread(() -> doingUpdate.release());
});