pull/90/head^2
kunfei 5 years ago
parent 497eed579f
commit 6dcadcd5d7
  1. 22
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt
  3. 5
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt
  4. 2
      app/src/main/res/values/strings.xml

@ -11,10 +11,14 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookGroup 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.lib.theme.ATH
import io.legado.app.utils.applyTint
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_arrange_book.* import kotlinx.android.synthetic.main.activity_arrange_book.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.toast
class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activity_arrange_book), class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activity_arrange_book),
@ -51,6 +55,17 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
cb_selected_all.onClick { cb_selected_all.onClick {
adapter.selectAll(!adapter.isSelectAll()) 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() { private fun initData() {
@ -81,4 +96,11 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
getString(R.string.select_count, adapter.selectedBooks.size, adapter.getItems().size) 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()
}
} }

@ -60,6 +60,9 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
} }
callBack.upSelectCount() callBack.upSelectCount()
} }
tv_delete.onClick {
callBack.deleteBook(item.bookUrl)
}
} }
} }
@ -75,5 +78,6 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
interface CallBack { interface CallBack {
val groupList: List<BookGroup> val groupList: List<BookGroup>
fun upSelectCount() fun upSelectCount()
fun deleteBook(bookUrl: String)
} }
} }

@ -6,4 +6,9 @@ import io.legado.app.base.BaseViewModel
class ArrangeBookViewModel(application: Application) : BaseViewModel(application) { class ArrangeBookViewModel(application: Application) : BaseViewModel(application) {
fun deleteBook(vararg bookUrl: String) {
}
} }

@ -457,6 +457,8 @@
<string name="network_connection_unavailable">网络连接不可用</string> <string name="network_connection_unavailable">网络连接不可用</string>
<string name="yes"></string> <string name="yes"></string>
<string name="no"></string> <string name="no"></string>
<string name="sure">确认</string>
<string name="sure_del">是否确认删除?</string>
<string name="sure_del_all_book">是否删除全部书籍?</string> <string name="sure_del_all_book">是否删除全部书籍?</string>
<string name="sure_del_download_book">是否同时删除已下载的书籍目录?</string> <string name="sure_del_download_book">是否同时删除已下载的书籍目录?</string>
<string name="qr_per">扫描二维码需相机权限</string> <string name="qr_per">扫描二维码需相机权限</string>

Loading…
Cancel
Save