mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix DB update issue (#5016)
This commit is contained in:
parent
c52002407d
commit
cb3094b51c
2 changed files with 14 additions and 5 deletions
|
|
@ -93,9 +93,11 @@ public class CategoryDao {
|
||||||
// fixme add a limit on the original query instead of falling out of the loop?
|
// fixme add a limit on the original query instead of falling out of the loop?
|
||||||
while (cursor != null && cursor.moveToNext()
|
while (cursor != null && cursor.moveToNext()
|
||||||
&& cursor.getPosition() < limit) {
|
&& cursor.getPosition() < limit) {
|
||||||
items.add(new CategoryItem(fromCursor(cursor).getName(),
|
if (fromCursor(cursor).getName() != null ) {
|
||||||
fromCursor(cursor).getDescription(), fromCursor(cursor).getThumbnail(),
|
items.add(new CategoryItem(fromCursor(cursor).getName(),
|
||||||
false));
|
fromCursor(cursor).getDescription(), fromCursor(cursor).getThumbnail(),
|
||||||
|
false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
@ -193,6 +195,13 @@ public class CategoryDao {
|
||||||
onUpdate(db, from, to);
|
onUpdate(db, from, to);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (from == 17) {
|
||||||
|
db.execSQL("ALTER TABLE categories ADD COLUMN description STRING;");
|
||||||
|
db.execSQL("ALTER TABLE categories ADD COLUMN thumbnail STRING;");
|
||||||
|
from++;
|
||||||
|
onUpdate(db, from, to);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import android.os.Parcelable
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class CategoryItem(val name: String, val description: String,
|
data class CategoryItem(val name: String, val description: String?,
|
||||||
val thumbnail: String, var isSelected: Boolean) : Parcelable {
|
val thumbnail: String?, var isSelected: Boolean) : Parcelable {
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "CategoryItem: '$name'"
|
return "CategoryItem: '$name'"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue