mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Add long click action on chapter download button (#7125)
This commit is contained in:
parent
71bb8ed975
commit
5002692bda
3 changed files with 24 additions and 0 deletions
|
@ -25,6 +25,10 @@ class ChapterHolder(
|
|||
binding.download.setOnClickListener {
|
||||
onDownloadClick(it, bindingAdapterPosition)
|
||||
}
|
||||
binding.download.setOnLongClickListener {
|
||||
onDownloadLongClick(bindingAdapterPosition)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(item: ChapterItem, manga: Manga) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue