pull/90/head^2
kunfei 5 years ago
parent 705c38cd09
commit 92dadc5842
  1. 15
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  2. 19
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt

@ -64,5 +64,20 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
})
}
override fun upSelectCount() {
if (adapter.selectedBooks.size == 0) {
cb_selected_all.isChecked = false
} else {
cb_selected_all.isChecked = adapter.selectedBooks.size >= adapter.getItems().size
}
//重置全选的文字
if (cb_selected_all.isChecked) {
cb_selected_all.setText(R.string.cancel)
} else {
cb_selected_all.setText(R.string.select_all)
}
tv_select_count.text =
getString(R.string.select_count, adapter.selectedBooks.size, adapter.getItems().size)
}
}

@ -7,17 +7,35 @@ import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookGroup
import kotlinx.android.synthetic.main.item_arrange_book.view.*
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()
override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) {
with(holder.itemView) {
tv_name.text = item.name
tv_author.text = context.getString(R.string.author_show, item.author)
tv_group.text = getGroupName(item.group)
checkbox.isChecked = selectedBooks.contains(item.bookUrl)
checkbox.onClick {
if (checkbox.isChecked) {
selectedBooks.add(item.bookUrl)
} else {
selectedBooks.remove(item.bookUrl)
}
}
onClick {
checkbox.isChecked = !checkbox.isChecked
if (checkbox.isChecked) {
selectedBooks.add(item.bookUrl)
} else {
selectedBooks.remove(item.bookUrl)
}
}
}
}
@ -32,5 +50,6 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) :
interface CallBack {
val groupList: List<BookGroup>
fun upSelectCount()
}
}
Loading…
Cancel
Save