From ca5ee70f5d48b4218e15949b7b77b397a281d676 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Reimar=20D=C3=B6ffinger?= Date: Sat, 18 Apr 2020 12:13:11 +0200 Subject: [PATCH] Attempt to fix search sometimes not working. ListView fails to process setSelection in some cases, probably related to it being busy updating for a new IndexAdapter. Try to avoid this by posting the message to it instead of to the uiHandler. Might fix issue #120. However the delay in jumpToTextFromHyperLink is still needed, so this still is not really reliable. --- src/com/hughes/android/dictionary/DictionaryActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index 12839ca..77454f9 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -1351,7 +1351,9 @@ public class DictionaryActivity extends AppCompatActivity { Log.d(LOG, "searchFinished: " + searchOperation + ", searchResult=" + searchResult); currentSearchOperation = null; - uiHandler.postDelayed(new Runnable() { + // Note: it's important to post to the ListView, otherwise + // the jumpToRow will randomly not work. + getListView().post(new Runnable() { @Override public void run() { if (currentSearchOperation == null) { @@ -1370,7 +1372,7 @@ public class DictionaryActivity extends AppCompatActivity { Log.d(LOG, "More coming, waiting for currentSearchOperation."); } } - }, 20); + }); } private void jumpToRow(final int row) { -- 2.43.0