From c29c5fd5f9fb48e8b5705ad3aae8f0c7a3524654 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Mon, 30 Sep 2024 20:33:24 -0700 Subject: [PATCH] Post the show call to UI thread --- .../filebrowser/GsFileBrowserListAdapter.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java index 91539f1327..23843a9f3b 100644 --- a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java +++ b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java @@ -627,13 +627,14 @@ public void onLayoutChange(View v, int l, int t, int r, int b, int ol, int ot, i public boolean scrollToAndFlash(final File file) { final int pos = getFilePosition(file); if (pos >= 0 && _layoutManager != null) { - doAfterChange(() -> _recyclerView.postDelayed(() -> { - final RecyclerView.ViewHolder holder = _recyclerView.findViewHolderForLayoutPosition(pos); - if (holder != null) { - GsContextUtils.blinkView(holder.itemView); - } - }, 400)); _layoutManager.scrollToPosition(pos); + _recyclerView.post(() -> + _recyclerView.postDelayed(() -> { + final RecyclerView.ViewHolder holder = _recyclerView.findViewHolderForLayoutPosition(pos); + if (holder != null) { + GsContextUtils.blinkView(holder.itemView); + } + }, 400)); return true; } return false; @@ -782,7 +783,7 @@ private synchronized void _loadFolder(final @NonNull File folder, final @Nullabl } }); } else if (toShow != null && _adapterDataFiltered.contains(toShow)) { - scrollToAndFlash(toShow); + _recyclerView.post(() -> scrollToAndFlash(toShow)); } }