From fa8d3a0091a2208d77ea92f1be1aa02196889631 Mon Sep 17 00:00:00 2001 From: Thad Hughes Date: Wed, 25 Dec 2013 18:43:59 -0800 Subject: [PATCH] Fix jumping to row from clicking on a link in the HTMLView. --- .../dictionary/DictionaryActivity.java | 24 ++++++++++++------- .../dictionary/DictionaryManagerActivity.java | 9 ++----- todo.txt | 1 - 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index 4425a0b..14cbcda 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -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); } } diff --git a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java index 5a03050..9b6bf4a 100644 --- a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java @@ -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); } diff --git a/todo.txt b/todo.txt index 8cdab76..3eeffdf 100644 --- 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 -- 2.43.0