From 6dcadcd5d71ae2ec58067041fed920fcd719f570 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 6 Feb 2020 19:17:26 +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 --- .../ui/book/arrange/ArrangeBookActivity.kt | 22 +++++++++++++++++++ .../app/ui/book/arrange/ArrangeBookAdapter.kt | 4 ++++ .../ui/book/arrange/ArrangeBookViewModel.kt | 5 +++++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 33 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index 936c7b70b..2f3658f89 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -11,10 +11,14 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookGroup +import io.legado.app.lib.dialogs.alert +import io.legado.app.lib.dialogs.okButton import io.legado.app.lib.theme.ATH +import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_arrange_book.* import org.jetbrains.anko.sdk27.listeners.onClick +import org.jetbrains.anko.toast class ArrangeBookActivity : VMBaseActivity(R.layout.activity_arrange_book), @@ -51,6 +55,17 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi cb_selected_all.onClick { adapter.selectAll(!adapter.isSelectAll()) } + btn_delete.onClick { + if (adapter.selectedBooks.isEmpty()) { + toast(R.string.non_select) + return@onClick + } + alert(titleResource = R.string.sure, messageResource = R.string.sure_del) { + okButton { + viewModel.deleteBook(*adapter.selectedBooks.toTypedArray()) + } + }.show().applyTint() + } } private fun initData() { @@ -81,4 +96,11 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi getString(R.string.select_count, adapter.selectedBooks.size, adapter.getItems().size) } + override fun deleteBook(bookUrl: String) { + alert(titleResource = R.string.sure, messageResource = R.string.sure_del) { + okButton { + viewModel.deleteBook(bookUrl) + } + }.show().applyTint() + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt index 890f29bad..0a4fb5a52 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt @@ -60,6 +60,9 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : } callBack.upSelectCount() } + tv_delete.onClick { + callBack.deleteBook(item.bookUrl) + } } } @@ -75,5 +78,6 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : interface CallBack { val groupList: List fun upSelectCount() + fun deleteBook(bookUrl: String) } } \ No newline at end of file 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 a6fa9463f..76e890886 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 @@ -6,4 +6,9 @@ import io.legado.app.base.BaseViewModel class ArrangeBookViewModel(application: Application) : BaseViewModel(application) { + + fun deleteBook(vararg bookUrl: String) { + + } + } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7b6ebfbc4..fc4d73a1a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -457,6 +457,8 @@ 网络连接不可用 + 确认 + 是否确认删除? 是否删除全部书籍? 是否同时删除已下载的书籍目录? 扫描二维码需相机权限