Fix chapter download button status

This commit is contained in:
Jay 2020-04-24 13:24:25 -04:00
parent f717900a89
commit edbea486c8
3 changed files with 2 additions and 27 deletions

View File

@ -664,6 +664,7 @@ class MangaDetailsController : BaseController,
chapterList = presenter.chapters.subList(startingPosition - 1, position) chapterList = presenter.chapters.subList(startingPosition - 1, position)
} }
downloadChapters(chapterList) downloadChapters(chapterList)
presenter.fetchChapters(false)
adapter?.removeSelection(startingPosition) adapter?.removeSelection(startingPosition)
(recycler.findViewHolderForAdapterPosition(startingPosition) as? BaseFlexibleViewHolder) (recycler.findViewHolderForAdapterPosition(startingPosition) as? BaseFlexibleViewHolder)
?.toggleActivation() ?.toggleActivation()
@ -687,7 +688,6 @@ class MangaDetailsController : BaseController,
popup.menuInflater.inflate(R.menu.chapter_single, popup.menu) popup.menuInflater.inflate(R.menu.chapter_single, popup.menu)
popup.setOnMenuItemClickListener { menuItem -> popup.setOnMenuItemClickListener { menuItem ->
val chapters = listOf(item)
when (menuItem.itemId) { when (menuItem.itemId) {
R.id.action_mark_previous_as_read -> markPreviousAsRead(item) R.id.action_mark_previous_as_read -> markPreviousAsRead(item)
} }

View File

@ -191,15 +191,6 @@ class MangaDetailsPresenter(
controller.refreshAdapter() controller.refreshAdapter()
} }
/**
* Sets the sorting method and requests an UI update.
* @param sort the sorting mode.
*/
fun setSorting(sort: Int) {
manga.sorting = sort
db.updateFlags(manga).executeAsBlocking()
}
/** /**
* Whether the display only downloaded filter is enabled. * Whether the display only downloaded filter is enabled.
*/ */
@ -337,17 +328,6 @@ class MangaDetailsPresenter(
chapters.filter { !it.read && it.status == Download.NOT_DOWNLOADED }.distinctBy { it.name } chapters.filter { !it.read && it.status == Download.NOT_DOWNLOADED }.distinctBy { it.name }
.sortedByDescending { it.source_order } .sortedByDescending { it.source_order }
/**
* Returns the next unread chapter or null if everything is read.
*/
fun getNewestChapterTime(): Long? {
return chapters.maxBy { it.date_upload }?.date_upload
}
fun getLatestChapter(): Float? {
return chapters.maxBy { it.chapter_number }?.chapter_number
}
fun startDownloadingNow(chapter: Chapter) { fun startDownloadingNow(chapter: Chapter) {
downloadManager.startDownloadNow(chapter) downloadManager.startDownloadNow(chapter)
} }
@ -360,10 +340,6 @@ class MangaDetailsPresenter(
downloadManager.downloadChapters(manga, chapters.filter { !it.isDownloaded }) downloadManager.downloadChapters(manga, chapters.filter { !it.isDownloaded })
} }
fun restartDownloads() {
if (downloadManager.isPaused()) downloadManager.startDownloads()
}
/** /**
* Deletes the given list of chapter. * Deletes the given list of chapter.
* @param chapters the list of chapters to delete. * @param chapters the list of chapters to delete.

View File

@ -5,7 +5,6 @@ import eu.davidea.flexibleadapter.items.AbstractSectionableItem
import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.util.system.HashCode
abstract class BaseChapterItem<T : BaseChapterHolder, H : AbstractHeaderItem<*>>( abstract class BaseChapterItem<T : BaseChapterHolder, H : AbstractHeaderItem<*>>(
val chapter: val chapter:
@ -41,6 +40,6 @@ Chapter,
} }
override fun hashCode(): Int { override fun hashCode(): Int {
return HashCode.generate(chapter.id ?: 0L, chapter.name) return (chapter.id ?: 0L).hashCode()
} }
} }