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);
}
}
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);
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)