Add long click action on chapter download button (#7125)

This commit is contained in:
CVIUS 2022-05-14 23:37:47 +08:00 committed by GitHub
parent 71bb8ed975
commit 5002692bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -25,6 +25,10 @@ class ChapterHolder(
binding.download.setOnClickListener {
onDownloadClick(it, bindingAdapterPosition)
}
binding.download.setOnLongClickListener {
onDownloadLongClick(bindingAdapterPosition)
true
}
}
fun bind(item: ChapterItem, manga: Manga) {

View File

@ -41,4 +41,20 @@ open class BaseChapterHolder(
}
}
}
fun onDownloadLongClick(position: Int) {
val item = adapter.getItem(position) as? BaseChapterItem<*, *> ?: return
when (item.status) {
Download.State.NOT_DOWNLOADED, Download.State.ERROR -> {
adapter.clickListener.downloadChapter(position)
}
Download.State.DOWNLOADED, Download.State.DOWNLOADING -> {
adapter.clickListener.deleteChapter(position)
}
// Download.State.QUEUE
else -> {
adapter.clickListener.startDownloadNow(position)
}
}
}
}

View File

@ -30,6 +30,10 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter)
binding.download.setOnClickListener {
onDownloadClick(it, bindingAdapterPosition)
}
binding.download.setOnLongClickListener {
onDownloadLongClick(bindingAdapterPosition)
true
}
}
fun bind(item: UpdatesItem) {