From: Reimar Döffinger Date: Sat, 2 Sep 2017 18:12:22 +0000 (+0200) Subject: Extended error messages and additional null checks. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=fd81d71fac2fa1c1a456ae4ab51783ebcd260b18 Extended error messages and additional null checks. --- diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index b5451a7..14aa4ff 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -836,7 +836,7 @@ public class DictionaryActivity extends ActionBarActivity { final LinearLayout result = new LinearLayout(parent.getContext()); - for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) { + for (int i = 0; dictionaryInfo.indexInfos != null && i < dictionaryInfo.indexInfos.size(); ++i) { final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i); final View button = IsoUtils.INSTANCE.createButton(parent.getContext(), dictionaryInfo, indexInfo, application.languageButtonPixels); diff --git a/src/com/hughes/android/dictionary/DictionaryInfo.java b/src/com/hughes/android/dictionary/DictionaryInfo.java index 53a1f7d..81c8f5d 100644 --- a/src/com/hughes/android/dictionary/DictionaryInfo.java +++ b/src/com/hughes/android/dictionary/DictionaryInfo.java @@ -65,7 +65,7 @@ public class DictionaryInfo implements Serializable { } public boolean isValid() { - return !indexInfos.isEmpty(); + return indexInfos != null && !indexInfos.isEmpty(); } public StringBuilder append(final StringBuilder result) { diff --git a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java index 833429a..869bc33 100644 --- a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java @@ -225,7 +225,7 @@ public class DictionaryManagerActivity extends ActionBarActivity { Toast.LENGTH_LONG).show(); result = true; } catch (Exception e) { - String msg = getString(R.string.unzippingFailed, dest); + String msg = getString(R.string.unzippingFailed, dest + ": " + e.getMessage()); File dir = application.getDictDir(); if (!dir.canWrite() || !application.checkFileCreate(dir)) { msg = getString(R.string.notWritable, dir.getAbsolutePath());