X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FDictionaryActivity.java;h=77454f9a3e0032af41d5b056de722c577747fdc2;hb=ca5ee70f5d48b4218e15949b7b77b397a281d676;hp=02286155532c187bf366a1cf86ffcdec1e034db6;hpb=e79165503392ed6a7cb7a8eadc15eaae0cda9443;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index 0228615..77454f9 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -285,7 +285,7 @@ public class DictionaryActivity extends AppCompatActivity { * -> language in which the phrase is written to -> to which * language shall be translated */ - if (intentAction != null && intentAction.equals("com.hughes.action.ACTION_SEARCH_DICT")) { + if ("com.hughes.action.ACTION_SEARCH_DICT".equals(intentAction)) { String query = intent.getStringExtra(SearchManager.QUERY); String from = intent.getStringExtra("from"); if (from != null) @@ -1243,7 +1243,7 @@ public class DictionaryActivity extends AppCompatActivity { try { wordList.getParentFile().mkdirs(); final PrintWriter out = new PrintWriter(new FileWriter(wordList, true)); - out.println(rawText.toString()); + out.println(rawText); out.close(); } catch (Exception e) { Log.e(LOG, "Unable to append to " + wordList.getAbsolutePath(), e); @@ -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,10 +1372,10 @@ public class DictionaryActivity extends AppCompatActivity { Log.d(LOG, "More coming, waiting for currentSearchOperation."); } } - }, 20); + }); } - private final void jumpToRow(final int row) { + private void jumpToRow(final int row) { Log.d(LOG, "jumpToRow: " + row + ", refocusSearchText=" + false); // getListView().requestFocusFromTouch(); getListView().setSelectionFromTop(row, 0); @@ -1406,7 +1408,7 @@ public class DictionaryActivity extends AppCompatActivity { } public String toString() { - return String.format("SearchOperation(%s,%s)", searchText, interrupted.toString()); + return String.format("SearchOperation(%s,%s)", searchText, interrupted); } @Override