diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index c4025a6a0..2e5b3f9e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -727,8 +727,7 @@ class MangaController : fun onChapterDownloadUpdate(download: Download) { chaptersAdapter?.currentItems?.find { it.id == download.chapter.id }?.let { - chaptersAdapter?.updateItem(it) - chaptersAdapter?.notifyDataSetChanged() + chaptersAdapter?.updateItem(it, it.status) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt index 533deaa09..59a0c5367 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt @@ -5,23 +5,24 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.FrameLayout +import androidx.core.content.ContextCompat import androidx.core.view.isVisible +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.databinding.ChapterDownloadViewBinding class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { - private val binding: ChapterDownloadViewBinding + private val binding: ChapterDownloadViewBinding = + ChapterDownloadViewBinding.inflate(LayoutInflater.from(context), this, false) private var state = Download.State.NOT_DOWNLOADED private var progress = 0 private var downloadIconAnimator: ObjectAnimator? = null - private var isAnimating = false init { - binding = ChapterDownloadViewBinding.inflate(LayoutInflater.from(context), this, false) addView(binding.root) } @@ -37,11 +38,12 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att } private fun updateLayout() { - binding.downloadIconBorder.isVisible = state == Download.State.NOT_DOWNLOADED + binding.downloadIconBorder.isVisible = state == Download.State.NOT_DOWNLOADED || state == Download.State.QUEUE - binding.downloadIcon.isVisible = state == Download.State.NOT_DOWNLOADED || state == Download.State.DOWNLOADING - if (state == Download.State.DOWNLOADING) { - if (!isAnimating) { + binding.downloadIcon.isVisible = state == Download.State.NOT_DOWNLOADED || + state == Download.State.DOWNLOADING || state == Download.State.QUEUE + if (state == Download.State.DOWNLOADING || state == Download.State.QUEUE) { + if (downloadIconAnimator == null) { downloadIconAnimator = ObjectAnimator.ofFloat(binding.downloadIcon, "alpha", 1f, 0f).apply { duration = 1000 @@ -49,22 +51,29 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att repeatMode = ObjectAnimator.REVERSE } downloadIconAnimator?.start() - isAnimating = true } - } else { + downloadIconAnimator?.currentPlayTime = System.currentTimeMillis() % 2000 + } else if (downloadIconAnimator != null) { downloadIconAnimator?.cancel() + downloadIconAnimator = null binding.downloadIcon.alpha = 1f - isAnimating = false } - binding.downloadQueued.isVisible = state == Download.State.QUEUE + binding.downloadProgress.isVisible = state == Download.State.DOWNLOADING + binding.downloadProgress.setProgressCompat(progress, true) - binding.downloadProgress.isVisible = state == Download.State.DOWNLOADING || - (state == Download.State.QUEUE && progress > 0) - binding.downloadProgress.progress = progress - - binding.downloadedIcon.isVisible = state == Download.State.DOWNLOADED - - binding.errorIcon.isVisible = state == Download.State.ERROR + binding.downloadStatusIcon.apply { + if (state == Download.State.DOWNLOADED || state == Download.State.ERROR) { + isVisible = true + val drawable = if (state == Download.State.DOWNLOADED) { + ContextCompat.getDrawable(context, R.drawable.ic_check_circle_24dp) + } else { + ContextCompat.getDrawable(context, R.drawable.ic_error_outline_24dp) + } + setImageDrawable(drawable) + } else { + isVisible = false + } + } } } diff --git a/app/src/main/res/drawable/ic_error_outline_24dp.xml b/app/src/main/res/drawable/ic_error_outline_24dp.xml index 5ea6b9db1..74e652794 100644 --- a/app/src/main/res/drawable/ic_error_outline_24dp.xml +++ b/app/src/main/res/drawable/ic_error_outline_24dp.xml @@ -2,7 +2,8 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24" - android:viewportHeight="24"> + android:viewportHeight="24" + android:tint="?colorError"> diff --git a/app/src/main/res/layout/chapter_download_view.xml b/app/src/main/res/layout/chapter_download_view.xml index a0d90c790..9b5d5c6dd 100644 --- a/app/src/main/res/layout/chapter_download_view.xml +++ b/app/src/main/res/layout/chapter_download_view.xml @@ -38,36 +38,13 @@ app:indicatorSize="24dp" app:trackThickness="2dp" /> - - - -