From fd81d71fac2fa1c1a456ae4ab51783ebcd260b18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Reimar=20D=C3=B6ffinger?= Date: Sat, 2 Sep 2017 20:12:22 +0200 Subject: [PATCH] Extended error messages and additional null checks. --- src/com/hughes/android/dictionary/DictionaryActivity.java | 2 +- src/com/hughes/android/dictionary/DictionaryInfo.java | 2 +- .../hughes/android/dictionary/DictionaryManagerActivity.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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()); -- 2.43.0