From 66a27fc28df3c0395256c044284422f925032608 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 7 Jun 2019 18:17:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/AppDatabase.kt | 6 +----- app/src/main/java/io/legado/app/data/entities/BookSource.kt | 2 +- .../io/legado/app/ui/main/booksource/BookSourceAdapter.kt | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index 5e0ebdd07..1f5bb7c87 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -39,11 +39,7 @@ abstract class AppDatabase : RoomDatabase() { // .addMigrations(MIGRATION_3_4) // .addMigrations(MIGRATION_4_5) // .addMigrations(MIGRATION_5_6) - .addCallback(object : Callback() { - override fun onCreate(db: SupportSQLiteDatabase) { - super.onCreate(db) - } - }) + .fallbackToDestructiveMigration() .build() } diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index 2ac3aea66..40a975434 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -10,7 +10,7 @@ import kotlinx.android.parcel.Parcelize @Parcelize @Entity( tableName = "book_sources", - indices = [(Index(value = ["sourceId"])), (Index(value = ["origin"], unique = false))] + indices = [(Index(value = ["origin"], unique = false))] ) data class BookSource ( @PrimaryKey diff --git a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt index 8f97640d2..1b2c793ff 100644 --- a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt @@ -20,10 +20,10 @@ class BookSourceAdapter : PagedListAdapter() { override fun areItemsTheSame(oldItem: BookSource, newItem: BookSource): Boolean = - oldItem.id == newItem.id + oldItem.origin == newItem.origin override fun areContentsTheSame(oldItem: BookSource, newItem: BookSource): Boolean = - oldItem.id == newItem.id + oldItem.origin == newItem.origin && oldItem.name == newItem.name && oldItem.group == newItem.group && oldItem.isEnabled == newItem.isEnabled