添加文件夹分组样式

pull/1023/head
gedoor 4 years ago
parent 95ecbebac2
commit a8d6b38ba0
  1. 22
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BaseBooksAdapter.kt
  2. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt
  3. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt

@ -6,8 +6,10 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
abstract class BaseBooksAdapter<VH : RecyclerView.ViewHolder>(val context: Context) : abstract class BaseBooksAdapter<VH : RecyclerView.ViewHolder>(
RecyclerView.Adapter<VH>() { val context: Context,
val callBack: CallBack
) : RecyclerView.Adapter<VH>() {
val diffItemCallback: DiffUtil.ItemCallback<Book> val diffItemCallback: DiffUtil.ItemCallback<Book>
get() = object : DiffUtil.ItemCallback<Book>() { get() = object : DiffUtil.ItemCallback<Book>() {
@ -62,14 +64,14 @@ abstract class BaseBooksAdapter<VH : RecyclerView.ViewHolder>(val context: Conte
} }
fun notification(bookUrl: String) { fun notification(bookUrl: String) {
// for (i in 0 until itemCount) { for (i in 0 until itemCount) {
// getItem(i)?.let { callBack.getItem(i).let {
// if (it.bookUrl == bookUrl) { if (it is Book && it.bookUrl == bookUrl) {
// notifyItemChanged(i, bundleOf(Pair("refresh", null))) notifyItemChanged(i, bundleOf(Pair("refresh", null)))
// return return
// } }
// } }
// } }
} }

@ -13,8 +13,8 @@ import io.legado.app.help.AppConfig
import io.legado.app.utils.invisible import io.legado.app.utils.invisible
import splitties.views.onLongClick import splitties.views.onLongClick
class BooksAdapterGrid(context: Context, private val callBack: CallBack) : class BooksAdapterGrid(context: Context, callBack: CallBack) :
BaseBooksAdapter<BooksAdapterGrid.ItemViewHolder>(context) { BaseBooksAdapter<BooksAdapterGrid.ItemViewHolder>(context, callBack) {
override fun getItemCount(): Int { override fun getItemCount(): Int {
return callBack.getItemCount() return callBack.getItemCount()

@ -15,8 +15,8 @@ import io.legado.app.utils.invisible
import io.legado.app.utils.visible import io.legado.app.utils.visible
import splitties.views.onLongClick import splitties.views.onLongClick
class BooksAdapterList(context: Context, private val callBack: CallBack) : class BooksAdapterList(context: Context, callBack: CallBack) :
BaseBooksAdapter<BooksAdapterList.ItemViewHolder>(context) { BaseBooksAdapter<BooksAdapterList.ItemViewHolder>(context, callBack) {
override fun getItemCount(): Int { override fun getItemCount(): Int {
return callBack.getItemCount() return callBack.getItemCount()

Loading…
Cancel
Save