]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Add a few null checks.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sat, 13 Feb 2016 15:11:37 +0000 (16:11 +0100)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sat, 13 Feb 2016 15:11:37 +0000 (16:11 +0100)
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/PreferenceActivity.java

index e00f5ddf765466475a7fc605f18c9a48fee37cce..5b5f9e113ce57220f5fe2320eb810e501684ae9b 100644 (file)
@@ -389,7 +389,7 @@ public class DictionaryActivity extends ActionBarActivity {
                     for (final Index index : dictionary.indices) {
                         final String searchToken = index.sortedIndexEntries.get(0).token;
                         final IndexEntry entry = index.findExact(searchToken);
-                        if (!searchToken.equals(entry.token)) {
+                        if (entry == null || !searchToken.equals(entry.token)) {
                             Log.e(LOG, "Couldn't find token: " + searchToken + ", " + entry.token);
                         }
                     }
@@ -1095,8 +1095,11 @@ public class DictionaryActivity extends ActionBarActivity {
         if (keyCode == KeyEvent.KEYCODE_ENTER) {
             Log.d(LOG, "Trying to hide soft keyboard.");
             final InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
-            inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(),
-                    InputMethodManager.HIDE_NOT_ALWAYS);
+            View focus = getCurrentFocus();
+            if (focus != null) {
+                inputManager.hideSoftInputFromWindow(focus.getWindowToken(),
+                        InputMethodManager.HIDE_NOT_ALWAYS);
+            }
             return true;
         }
         return super.onKeyDown(keyCode, event);
index a415d871a262839ce6ecdff1f6462b6b4c3fb81e..2d66bf945235b48375e5730005a689c89906a5fb 100644 (file)
@@ -104,9 +104,12 @@ public class PreferenceActivity extends android.preference.PreferenceActivity
                         dirs += "\n" + f.getAbsolutePath();
                 }
             } else {
-                String externalFilesDir = getApplicationContext().getExternalFilesDir(null).getAbsolutePath();
-                if (new File(externalFilesDir).canWrite())
-                    dirs += "\n" + externalFilesDir;
+                File efd = getApplicationContext().getExternalFilesDir(null);
+                if (efd != null) {
+                    String externalFilesDir = efd.getAbsolutePath();
+                    if (new File(externalFilesDir).canWrite())
+                        dirs += "\n" + externalFilesDir;
+                }
             }
             new AlertDialog.Builder(this).setTitle(getString(R.string.error))
                 .setMessage(getString(R.string.chosenNotWritable) + dirs)