diff --git a/Alkitab/src/main/java/yuku/alkitab/base/S.java b/Alkitab/src/main/java/yuku/alkitab/base/S.java index 1cfd143f9..ccfd60b94 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/S.java +++ b/Alkitab/src/main/java/yuku/alkitab/base/S.java @@ -203,9 +203,17 @@ public static void openVersionsDialog(final Activity activity, final boolean wit new MaterialDialog.Builder(activity) .items(options) .itemsCallbackSingleChoice(selected, (dialog, view, which, text) -> { - final MVersion mv = versions.get(which); - listener.onVersionSelected(mv); - dialog.dismiss(); + if (which == -1) { + // it is possible that 'which' is -1 in the case that + // a version is already deleted, but the current displayed version is that version + // (hence the initial selected item position is -1) and then the user + // presses the "other version" button. This callback will still be triggered + // before the positive button callback. + } else { + final MVersion mv = versions.get(which); + listener.onVersionSelected(mv); + dialog.dismiss(); + } return true; }) .alwaysCallSingleChoiceCallback() diff --git a/Alkitab/src/main/java/yuku/alkitab/base/storage/InternalDbHelper.java b/Alkitab/src/main/java/yuku/alkitab/base/storage/InternalDbHelper.java index 8ca13f3eb..99a6c94b3 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/storage/InternalDbHelper.java +++ b/Alkitab/src/main/java/yuku/alkitab/base/storage/InternalDbHelper.java @@ -75,8 +75,19 @@ public void onOpen(SQLiteDatabase db) { // } if (oldVersion <= 50) { - // new table Version - createTableEdisi(db); + // recreate a temporary old-style table "Edisi" + // This will later be converted in version 14000166 + db.execSQL("create table if not exists Edisi (" + + "_id integer primary key autoincrement, " + + "shortName text, " + + "judul text, " + + "jenis text, " + + "keterangan text, " + + "namafile text, " + + "namafile_pdbasal text, " + + "aktif integer, " + + "urutan integer)" + ); } if (oldVersion <= 69) { // 70: 2.0.0 @@ -125,7 +136,7 @@ public void onOpen(SQLiteDatabase db) { createIndexReadingPlanProgress(db); } - if (oldVersion < 14000163) { // last version that doesn't use Marker table + if (oldVersion < 14000163) { // 4.0.0-beta1: last version that doesn't use Marker table addGidColumnToLabelIfNeeded(db); createTableMarker(db); @@ -136,7 +147,7 @@ public void onOpen(SQLiteDatabase db) { convertFromBookmark2ToMarker(db); } - if (oldVersion < 14000166) { // last version that doesn't use the new Version table + if (oldVersion < 14000166) { // 4.0.0-beta5: last version that doesn't use the new Version table createTableVersion(db); createIndexVersion(db); convertFromEdisiToVersion(db); @@ -217,19 +228,6 @@ private void createIndexDevotion(SQLiteDatabase db) { db.execSQL("create index if not exists index_Devotion_02 on " + Table.Devotion.tableName() + " (" + Table.Devotion.touchTime + ")"); } - private void createTableEdisi(SQLiteDatabase db) { - db.execSQL("create table if not exists Edisi (" + - "_id integer primary key autoincrement, " + - "shortName text, " + - "judul text, " + - "jenis text, " + - "keterangan text, " + - Db.Version.filename + "namafile text, " + - "namafile_pdbasal text, " + - "aktif integer, " + - "urutan integer)"); - } - void createTableVersion(SQLiteDatabase db) { db.execSQL("create table if not exists " + Db.TABLE_Version + " (" + "_id integer primary key autoincrement, " + diff --git a/Alkitab/src/main/java/yuku/alkitab/base/widget/VerseAdapter.java b/Alkitab/src/main/java/yuku/alkitab/base/widget/VerseAdapter.java index 969c1d1f8..6d5adf9d8 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/widget/VerseAdapter.java +++ b/Alkitab/src/main/java/yuku/alkitab/base/widget/VerseAdapter.java @@ -193,7 +193,7 @@ public synchronized void reloadAttributeMap() { } @Override public synchronized long getItemId(int position) { - return itemPointer_[position]; + return position; } public void setParallelListener(CallbackSpan.OnClickListener parallelListener) { @@ -341,7 +341,13 @@ public int getVerseCount() { } @Override public boolean isEnabled(int position) { - return getItemId(position) >= 0; + final int[] _itemPointer = this.itemPointer_; + + // guard against wild ListView.onInitializeAccessibilityNodeInfoForItem + if (_itemPointer == null) return false; + if (position >= _itemPointer.length) return false; + + return _itemPointer[position] >= 0; } private static int[] makeItemPointer(int nverse, int[] pericopeAris, PericopeBlock[] pericopeBlocks, int nblock) {