From 9b974c9a253fb28bd05e5335a79a77dd965b4b13 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Wed, 2 Oct 2024 23:56:05 -0700 Subject: [PATCH] Bugfix: showAndFlash must be called on UI thread, closes #2427 (#2428) --- .../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)); } }