Avoid some unnecessary re-renderings of download icons
(cherry picked from commit 348c1ff29d77f9487dbf4a1304527c22d016c113) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt
This commit is contained in:
parent
c5b5c8c21d
commit
b6c7e96ddc
@ -713,6 +713,7 @@ class MangaPresenter(
|
|||||||
observeDownloadsStatusSubscription?.let { remove(it) }
|
observeDownloadsStatusSubscription?.let { remove(it) }
|
||||||
observeDownloadsStatusSubscription = downloadManager.queue.getStatusObservable()
|
observeDownloadsStatusSubscription = downloadManager.queue.getStatusObservable()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.onBackpressureLatest()
|
||||||
.filter { download -> /* SY --> */ if (isMergedSource) download.manga.id in mergedIds else /* SY <-- */ download.manga.id == manga.id }
|
.filter { download -> /* SY --> */ if (isMergedSource) download.manga.id in mergedIds else /* SY <-- */ download.manga.id == manga.id }
|
||||||
.doOnNext { onDownloadStatusChange(it) }
|
.doOnNext { onDownloadStatusChange(it) }
|
||||||
.subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error ->
|
.subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error ->
|
||||||
@ -722,6 +723,7 @@ class MangaPresenter(
|
|||||||
observeDownloadsPageSubscription?.let { remove(it) }
|
observeDownloadsPageSubscription?.let { remove(it) }
|
||||||
observeDownloadsPageSubscription = downloadManager.queue.getProgressObservable()
|
observeDownloadsPageSubscription = downloadManager.queue.getProgressObservable()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.onBackpressureLatest()
|
||||||
.filter { download -> /* SY --> */ if (isMergedSource) download.manga.id in mergedIds else /* SY <-- */ download.manga.id == manga.id }
|
.filter { download -> /* SY --> */ if (isMergedSource) download.manga.id in mergedIds else /* SY <-- */ download.manga.id == manga.id }
|
||||||
.subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error ->
|
.subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error ->
|
||||||
Timber.e(error)
|
Timber.e(error)
|
||||||
|
@ -14,6 +14,9 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
|
|
||||||
private val binding: ChapterDownloadViewBinding
|
private val binding: ChapterDownloadViewBinding
|
||||||
|
|
||||||
|
private var state = Download.State.NOT_DOWNLOADED
|
||||||
|
private var progress = 0
|
||||||
|
|
||||||
private var downloadIconAnimator: ObjectAnimator? = null
|
private var downloadIconAnimator: ObjectAnimator? = null
|
||||||
private var isAnimating = false
|
private var isAnimating = false
|
||||||
|
|
||||||
@ -23,6 +26,17 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setState(state: Download.State, progress: Int = 0) {
|
fun setState(state: Download.State, progress: Int = 0) {
|
||||||
|
val isDirty = this.state.value != state.value || this.progress != progress
|
||||||
|
|
||||||
|
this.state = state
|
||||||
|
this.progress = progress
|
||||||
|
|
||||||
|
if (isDirty) {
|
||||||
|
updateLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateLayout() {
|
||||||
binding.downloadIconBorder.isVisible = state == Download.State.NOT_DOWNLOADED
|
binding.downloadIconBorder.isVisible = state == Download.State.NOT_DOWNLOADED
|
||||||
|
|
||||||
binding.downloadIcon.isVisible = state == Download.State.NOT_DOWNLOADED || state == Download.State.DOWNLOADING
|
binding.downloadIcon.isVisible = state == Download.State.NOT_DOWNLOADED || state == Download.State.DOWNLOADING
|
||||||
|
Loading…
x
Reference in New Issue
Block a user