优化
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled

This commit is contained in:
Horis
2025-04-09 20:19:52 +08:00
parent 2ab7239b26
commit 0d1ada134b
4 changed files with 22 additions and 22 deletions

View File

@@ -135,8 +135,8 @@ abstract class BaseBooksAdapter<VH : RecyclerView.ViewHolder>(
interface CallBack {
fun onItemClick(position: Int)
fun onItemLongClick(position: Int)
fun onItemClick(item: Any)
fun onItemLongClick(item: Any)
fun isUpdate(bookUrl: String): Boolean
fun getItems(): List<Any>
}

View File

@@ -34,12 +34,12 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) :
) {
when (holder) {
is BookViewHolder -> (getItem(position) as? Book)?.let {
holder.registerListener(position)
holder.registerListener(it)
holder.onBind(it, position, payloads)
}
is GroupViewHolder -> (getItem(position) as? BookGroup)?.let {
holder.registerListener(position)
holder.registerListener(it)
holder.onBind(it, position, payloads)
}
}
@@ -78,12 +78,12 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) :
}
}
fun registerListener(position: Int) {
fun registerListener(item: Any) {
binding.root.setOnClickListener {
callBack.onItemClick(position)
callBack.onItemClick(item)
}
binding.root.onLongClick {
callBack.onItemLongClick(position)
callBack.onItemLongClick(item)
}
}
@@ -128,12 +128,12 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) :
}
}
fun registerListener(position: Int) {
fun registerListener(item: Any) {
binding.root.setOnClickListener {
callBack.onItemClick(position)
callBack.onItemClick(item)
}
binding.root.onLongClick {
callBack.onItemLongClick(position)
callBack.onItemLongClick(item)
}
}

View File

@@ -33,12 +33,12 @@ class BooksAdapterList(context: Context, callBack: CallBack) :
) {
when (holder) {
is BookViewHolder -> (getItem(position) as? Book)?.let {
holder.registerListener(position)
holder.registerListener(it)
holder.onBind(it, position, payloads)
}
is GroupViewHolder -> (getItem(position) as? BookGroup)?.let {
holder.registerListener(position)
holder.registerListener(it)
holder.onBind(it, position, payloads)
}
}
@@ -87,12 +87,12 @@ class BooksAdapterList(context: Context, callBack: CallBack) :
}
}
fun registerListener(position: Int) {
fun registerListener(item: Any) {
binding.root.setOnClickListener {
callBack.onItemClick(position)
callBack.onItemClick(item)
}
binding.root.onLongClick {
callBack.onItemLongClick(position)
callBack.onItemLongClick(item)
}
}
@@ -144,12 +144,12 @@ class BooksAdapterList(context: Context, callBack: CallBack) :
}
}
fun registerListener(position: Int) {
fun registerListener(item: Any) {
binding.root.setOnClickListener {
callBack.onItemClick(position)
callBack.onItemClick(item)
}
binding.root.onLongClick {
callBack.onItemLongClick(position)
callBack.onItemLongClick(item)
}
}

View File

@@ -211,8 +211,8 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
}
}
override fun onItemClick(position: Int) {
when (val item = booksAdapter.getItem(position)) {
override fun onItemClick(item: Any) {
when (item) {
is Book -> when {
item.isAudio ->
startActivity<AudioPlayActivity> {
@@ -231,8 +231,8 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
}
}
override fun onItemLongClick(position: Int) {
when (val item = booksAdapter.getItem(position)) {
override fun onItemLongClick(item: Any) {
when (item) {
is Book -> startActivity<BookInfoActivity> {
putExtra("name", item.name)
putExtra("author", item.author)