From 7be66bc9663c1106ebc78748dc22f394680ac86b Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 29 十二月 2020 09:57:09 +0800
Subject: [PATCH] 1. 修复场景地图界面选择场景点时可能由于列表下标越界导致崩溃问题; 2. 修复自定义PagerAdapter时,没有重写destroyItem可能会导致的崩溃问题; 3. 修改数据库实体类MediaTypeAlias的主键id类型从龙变更为Long,否则无法自增; 4. 新增部分列表相关的工具函数;
---
app/src/main/java/com/ping/greendao/gen/MediaTypeAliasDao.java | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/app/src/main/java/com/ping/greendao/gen/MediaTypeAliasDao.java b/app/src/main/java/com/ping/greendao/gen/MediaTypeAliasDao.java
index ed9b1ce..19a66bb 100644
--- a/app/src/main/java/com/ping/greendao/gen/MediaTypeAliasDao.java
+++ b/app/src/main/java/com/ping/greendao/gen/MediaTypeAliasDao.java
@@ -24,7 +24,7 @@
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
- public final static Property Id = new Property(0, long.class, "id", true, "_id");
+ public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property SceneTypeId = new Property(1, int.class, "sceneTypeId", false, "SCENE_TYPE_ID");
public final static Property TypeId = new Property(2, int.class, "typeId", false, "TYPE_ID");
public final static Property TypeName = new Property(3, String.class, "typeName", false, "TYPE_NAME");
@@ -44,7 +44,7 @@
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"MEDIA_TYPE_ALIAS\" (" + //
- "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL ," + // 0: id
+ "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"SCENE_TYPE_ID\" INTEGER NOT NULL ," + // 1: sceneTypeId
"\"TYPE_ID\" INTEGER NOT NULL ," + // 2: typeId
"\"TYPE_NAME\" TEXT," + // 3: typeName
@@ -60,7 +60,11 @@
@Override
protected final void bindValues(DatabaseStatement stmt, MediaTypeAlias entity) {
stmt.clearBindings();
- stmt.bindLong(1, entity.getId());
+
+ Long id = entity.getId();
+ if (id != null) {
+ stmt.bindLong(1, id);
+ }
stmt.bindLong(2, entity.getSceneTypeId());
stmt.bindLong(3, entity.getTypeId());
@@ -78,7 +82,11 @@
@Override
protected final void bindValues(SQLiteStatement stmt, MediaTypeAlias entity) {
stmt.clearBindings();
- stmt.bindLong(1, entity.getId());
+
+ Long id = entity.getId();
+ if (id != null) {
+ stmt.bindLong(1, id);
+ }
stmt.bindLong(2, entity.getSceneTypeId());
stmt.bindLong(3, entity.getTypeId());
@@ -95,13 +103,13 @@
@Override
public Long readKey(Cursor cursor, int offset) {
- return cursor.getLong(offset + 0);
+ return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public MediaTypeAlias readEntity(Cursor cursor, int offset) {
MediaTypeAlias entity = new MediaTypeAlias( //
- cursor.getLong(offset + 0), // id
+ cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.getInt(offset + 1), // sceneTypeId
cursor.getInt(offset + 2), // typeId
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // typeName
@@ -112,7 +120,7 @@
@Override
public void readEntity(Cursor cursor, MediaTypeAlias entity, int offset) {
- entity.setId(cursor.getLong(offset + 0));
+ entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setSceneTypeId(cursor.getInt(offset + 1));
entity.setTypeId(cursor.getInt(offset + 2));
entity.setTypeName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
@@ -136,7 +144,7 @@
@Override
public boolean hasKey(MediaTypeAlias entity) {
- throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
+ return entity.getId() != null;
}
@Override
--
Gitblit v1.9.3