From aa49a88b76ebfb3d7844ba9bfe1ced6cd0ce367e Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 6 Feb 2020 22:59:06 +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/entities/Book.kt | 11 +++++++++++ .../app/ui/book/arrange/ArrangeBookViewModel.kt | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 204d2de7a..b7ecf828a 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -57,6 +57,17 @@ data class Book( return isLocalBook() && originName.endsWith(".txt", true) } + override fun equals(other: Any?): Boolean { + if (other is Book) { + return other.bookUrl == bookUrl + } + return false + } + + override fun hashCode(): Int { + return bookUrl.hashCode() + } + @Ignore @IgnoredOnParcel override var variableMap: HashMap? = null diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt index c7e571447..173678b15 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt @@ -11,7 +11,7 @@ class ArrangeBookViewModel(application: Application) : BaseViewModel(application fun deleteBook(vararg book: Book) { execute { - App.db.bookDao().delete() + App.db.bookDao().delete(*book) } }