]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Fix jumping to row from clicking on a link in the HTMLView.
authorThad Hughes <thadh@google.com>
Thu, 26 Dec 2013 02:43:59 +0000 (18:43 -0800)
committerThad Hughes <thadh@google.com>
Thu, 26 Dec 2013 02:43:59 +0000 (18:43 -0800)
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/DictionaryManagerActivity.java
todo.txt

index 4425a0b0f3d7cc2276ba5679d7df7e956b68ef20..14cbcdadb8b5f4b0d944eff1350472a773e51668 100644 (file)
@@ -604,7 +604,8 @@ public class DictionaryActivity extends SherlockListActivity {
             currentSearchOperation.interrupted.set(true);
             currentSearchOperation = null;
         }
-        setIndexAndSearchText((indexIndex + 1) % dictionary.indices.size(), searchView.getQuery().toString());
+        setIndexAndSearchText((indexIndex + 1) % dictionary.indices.size(), 
+                searchView.getQuery().toString());
     }
 
     void onLanguageButtonLongClick(final Context context) {
@@ -902,7 +903,15 @@ public class DictionaryActivity extends SherlockListActivity {
         if (indexToUse == -1) {
             indexToUse = defaultIndexToUse;
         }
-        setIndexAndSearchText(indexToUse, selectedText);
+        // Without this extra indirection, the call to jumpToRow that this
+        // invokes didn't actually have any effect.
+        final int actualIndexToUse = indexToUse;
+        getListView().post(new Runnable() {
+            @Override
+            public void run() {
+                setIndexAndSearchText(actualIndexToUse, selectedText);
+            }
+        });
     }
     
     /**
@@ -1009,14 +1018,13 @@ public class DictionaryActivity extends SherlockListActivity {
     }
 
     private void setSearchText(final String text, final boolean triggerSearch) {
-        if (!triggerSearch) {
-            searchView.setOnQueryTextListener(null);
-        }
+        Log.d(LOG, "setSearchText, text=" + text + ", triggerSearch=" + triggerSearch);
+        // Disable the listener, because sometimes it doesn't work.
+        searchView.setOnQueryTextListener(null);
         searchView.setQuery(text, false);
         moveCursorToRight();
-        if (!triggerSearch) {
-            searchView.setOnQueryTextListener(onQueryTextListener);            
-        } else {
+        searchView.setOnQueryTextListener(onQueryTextListener);
+        if (triggerSearch) {
             onQueryTextListener.onQueryTextChange(text);
         }
     }
index 5a0305015731bdfce8f90ac46b5a525188ceb481..9b6bf4a3078849cc3c952d7154b649ff2962b95c 100644 (file)
@@ -529,15 +529,10 @@ public class DictionaryManagerActivity extends SherlockListActivity {
         
         if (canLaunch) {
             row.setClickable(true);
-            row.setOnClickListener(new OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    new IntentLauncher(parent.getContext(), 
+            row.setOnClickListener(new IntentLauncher(parent.getContext(), 
                             DictionaryActivity.getLaunchIntent(
                                     application.getPath(dictionaryInfo.uncompressedFilename), 
-                                    dictionaryInfo.indexInfos.get(0).shortName, ""));
-                }
-            });
+                                    dictionaryInfo.indexInfos.get(0).shortName, "")));
             row.setFocusable(true);
             row.setLongClickable(true);
         }
index 8cdab765f8aaa8990f5a82ffc3df6099f91afa37..3eeffdfabf50972a2759972d28f023384887b714 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -1,4 +1,3 @@
-* Clicking link in HTML view doesn't trigger search.
 * Back button in top left
 * Contributions from:
 * HtmlEntries inline, expandable.
\ No newline at end of file