]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
Tried to fix launch last used bug.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index ac828e6092a8633db7b2a47b3931d093e7ad80b6..2ecaf3738615785f7f876a837c3e47d92f7d7259 100644 (file)
@@ -176,9 +176,6 @@ public class DictionaryActivity extends ListActivity {
 \r
     application = (DictionaryApplication) getApplication();\r
     theme = application.getSelectedTheme();\r
-\r
-    // Clear them so that if something goes wrong, we won't relaunch.\r
-    clearDictionaryPrefs(this);\r
     \r
     final Intent intent = getIntent();\r
     dictFile = new File(intent.getStringExtra(C.DICT_FILE));\r
@@ -372,15 +369,6 @@ public class DictionaryActivity extends ListActivity {
     prefs.commit();\r
   }\r
 \r
-  private static void clearDictionaryPrefs(final Context context) {\r
-    final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(context).edit();\r
-    prefs.remove(C.DICT_FILE);\r
-    prefs.remove(C.INDEX_INDEX);\r
-    prefs.remove(C.SEARCH_TOKEN);\r
-    prefs.commit();\r
-  }\r
-\r
-\r
   @Override\r
   protected void onDestroy() {\r
     super.onDestroy();\r
@@ -523,7 +511,10 @@ public class DictionaryActivity extends ListActivity {
     Log.d(LOG, "onUpDownButton, destIndexEntry=" + dest.token);\r
     searchText.removeTextChangedListener(searchTextWatcher);\r
     searchText.setText(dest.token);\r
-    Selection.moveToRightEdge(searchText.getText(), searchText.getLayout());\r
+    if (searchText.getLayout() != null) {\r
+      // Surprising, but this can otherwise crash sometimes...\r
+      Selection.moveToRightEdge(searchText.getText(), searchText.getLayout());\r
+    }\r
     jumpToRow(index.sortedIndexEntries.get(destIndexEntry).startRow);\r
     searchText.addTextChangedListener(searchTextWatcher);\r
   }\r
@@ -730,7 +721,8 @@ public class DictionaryActivity extends ListActivity {
     }\r
     if (keyCode == KeyEvent.KEYCODE_BACK) {\r
       Log.d(LOG, "Clearing dictionary prefs.");\r
-      DictionaryActivity.clearDictionaryPrefs(this);\r
+      // Pretend that we just autolaunched so that we won't do it again.\r
+      DictionaryManagerActivity.lastAutoLaunchMillis = System.currentTimeMillis();\r
     }\r
     if (keyCode == KeyEvent.KEYCODE_ENTER) {\r
       Log.d(LOG, "Trying to hide soft keyboard.");\r