From: Reimar Döffinger Date: Sat, 18 Apr 2020 10:13:11 +0000 (+0200) Subject: Attempt to fix search sometimes not working. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=ca5ee70f5d48b4218e15949b7b77b397a281d676 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. --- 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) {