pull/90/head^2
kunfei 5 years ago
parent e3389ff8af
commit 15585965f4
  1. 4
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  2. 16
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt

@ -14,6 +14,7 @@ import io.legado.app.data.entities.BookGroup
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_arrange_book.*
import org.jetbrains.anko.sdk27.listeners.onClick
class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activity_arrange_book),
@ -47,6 +48,9 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
recycler_view.layoutManager = LinearLayoutManager(this)
adapter = ArrangeBookAdapter(this, this)
recycler_view.adapter = adapter
cb_selected_all.onClick {
adapter.selectAll(cb_selected_all.isChecked)
}
}
private fun initData() {

@ -13,7 +13,21 @@ import org.jetbrains.anko.sdk27.listeners.onClick
class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<Book>(context, R.layout.item_arrange_book) {
val selectedBooks: ArrayList<String> = arrayListOf()
val selectedBooks: HashSet<String> = hashSetOf()
fun selectAll(selectAll: Boolean) {
if (selectAll) {
selectedBooks.clear()
notifyDataSetChanged()
callBack.upSelectCount()
} else {
getItems().forEach {
selectedBooks.add(it.bookUrl)
}
notifyDataSetChanged()
callBack.upSelectCount()
}
}
override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) {
with(holder.itemView) {

Loading…
Cancel
Save