修复新安装崩溃bug

pull/433/head
gedoor 4 years ago
parent 273402df5d
commit 279f9d4b62
  1. 8
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  2. 2
      app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt

@ -49,25 +49,25 @@ abstract class AppDatabase: RoomDatabase() {
override fun onOpen(db: SupportSQLiteDatabase) { override fun onOpen(db: SupportSQLiteDatabase) {
db.execSQL( db.execSQL(
""" """
insert into book_groups(groupId, groupName, 'order') select ${AppConst.bookGroupAllId}, '全部', -10 insert into book_groups(groupId, groupName, 'order', show) select ${AppConst.bookGroupAllId}, '全部', -10, 1
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupAllId}) where not exists (select * from book_groups where groupId = ${AppConst.bookGroupAllId})
""" """
) )
db.execSQL( db.execSQL(
""" """
insert into book_groups(groupId, groupName, 'order') select ${AppConst.bookGroupLocalId}, '本地', -9 insert into book_groups(groupId, groupName, 'order', show) select ${AppConst.bookGroupLocalId}, '本地', -9, 1
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupLocalId}) where not exists (select * from book_groups where groupId = ${AppConst.bookGroupLocalId})
""" """
) )
db.execSQL( db.execSQL(
""" """
insert into book_groups(groupId, groupName, 'order') select ${AppConst.bookGroupAudioId}, '音频', -8 insert into book_groups(groupId, groupName, 'order', show) select ${AppConst.bookGroupAudioId}, '音频', -8, 1
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupAudioId}) where not exists (select * from book_groups where groupId = ${AppConst.bookGroupAudioId})
""" """
) )
db.execSQL( db.execSQL(
""" """
insert into book_groups(groupId, groupName, 'order') select ${AppConst.bookGroupNoneId}, '未分组', -7 insert into book_groups(groupId, groupName, 'order', show) select ${AppConst.bookGroupNoneId}, '未分组', -7, 1
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupNoneId}) where not exists (select * from book_groups where groupId = ${AppConst.bookGroupNoneId})
""" """
) )

@ -16,7 +16,7 @@ interface BookGroupDao {
@Query("SELECT * FROM book_groups ORDER BY `order`") @Query("SELECT * FROM book_groups ORDER BY `order`")
fun liveDataAll(): LiveData<List<BookGroup>> fun liveDataAll(): LiveData<List<BookGroup>>
@Query("SELECT * FROM book_groups where show > 0 ORDER BY `order`") @Query("SELECT * FROM book_groups where show > 0 or groupId >= 0 ORDER BY `order`")
fun liveDataShow(): LiveData<List<BookGroup>> fun liveDataShow(): LiveData<List<BookGroup>>
@Query("SELECT * FROM book_groups where groupId >= 0 ORDER BY `order`") @Query("SELECT * FROM book_groups where groupId >= 0 ORDER BY `order`")

Loading…
Cancel
Save