diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt index 287754b84..3a148a2c2 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt @@ -58,7 +58,10 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) : popupMenu.inflate(R.menu.change_source_item) popupMenu.setOnMenuItemClickListener { when (it.itemId) { - R.id.menu_disable_book_source -> callBack.disableSource(searchBook.origin) + R.id.menu_disable_book_source -> { + callBack.disableSource(searchBook) + removeItem(searchBook) + } } true } @@ -68,6 +71,6 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) : interface CallBack { val bookUrl: String? fun changeTo(searchBook: SearchBook) - fun disableSource(sourceUrl: String) + fun disableSource(searchBook: SearchBook) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 75df41680..09fa066ec 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -185,8 +185,8 @@ class ChangeSourceDialog : BaseDialogFragment(), override val bookUrl: String? get() = callBack?.oldBook?.bookUrl - override fun disableSource(sourceUrl: String) { - viewModel.disableSource(sourceUrl) + override fun disableSource(searchBook: SearchBook) { + viewModel.disableSource(searchBook) } interface CallBack { diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 93b02a425..e5adf9e85 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -165,12 +165,13 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio searchPool.close() } - fun disableSource(sourceUrl: String) { + fun disableSource(searchBook: SearchBook) { execute { - App.db.bookSourceDao().getBookSource(sourceUrl)?.let { source -> + App.db.bookSourceDao().getBookSource(searchBook.origin)?.let { source -> source.enabled = false App.db.bookSourceDao().update(source) } + searchBooks.remove(searchBook) } }