]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Attempt to fix search sometimes not working.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sat, 18 Apr 2020 10:13:11 +0000 (12:13 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sat, 18 Apr 2020 10:13:11 +0000 (12:13 +0200)
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

index 12839caeddcf3d6c351e0a2a137fe4508c38fc1a..77454f9a3e0032af41d5b056de722c577747fdc2 100644 (file)
@@ -1351,7 +1351,9 @@ public class DictionaryActivity extends AppCompatActivity {
         Log.d(LOG, "searchFinished: " + searchOperation + ", searchResult=" + searchResult);
 
         currentSearchOperation = null;
         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) {
             @Override
             public void run() {
                 if (currentSearchOperation == null) {
@@ -1370,7 +1372,7 @@ public class DictionaryActivity extends AppCompatActivity {
                     Log.d(LOG, "More coming, waiting for currentSearchOperation.");
                 }
             }
                     Log.d(LOG, "More coming, waiting for currentSearchOperation.");
                 }
             }
-        }, 20);
+        });
     }
 
     private void jumpToRow(final int row) {
     }
 
     private void jumpToRow(final int row) {