From ddb856edc7294ca68ab223ea50358e9323ed9a3f Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Wed, 16 Mar 2022 09:21:30 +0700 Subject: [PATCH] Add cover error drawable (#6782) --- .../util/view/ImageViewExtensions.kt | 7 +++--- app/src/main/res/drawable/cover_error.xml | 25 +++++++++++++++++++ app/src/main/res/values/colors.xml | 2 ++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/cover_error.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ImageViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ImageViewExtensions.kt index c64f045759..5df8fcb334 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ImageViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ImageViewExtensions.kt @@ -1,19 +1,18 @@ package eu.kanade.tachiyomi.util.view import android.content.Context -import android.graphics.Color import android.graphics.drawable.Animatable import android.graphics.drawable.ColorDrawable import android.widget.ImageView import androidx.annotation.AttrRes import androidx.annotation.DrawableRes import androidx.appcompat.content.res.AppCompatResources -import androidx.core.graphics.ColorUtils import coil.ImageLoader import coil.imageLoader import coil.load import coil.request.ImageRequest import coil.target.ImageViewTarget +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.animatorDurationScale import eu.kanade.tachiyomi.util.system.getResourceColor @@ -42,8 +41,8 @@ fun ImageView.loadAutoPause( builder: ImageRequest.Builder.() -> Unit = {} ) { load(data, loader) { - val placeholderColor = ColorUtils.setAlphaComponent(Color.GRAY, 0x1F) // 12% gray - placeholder(ColorDrawable(placeholderColor)) + placeholder(ColorDrawable(context.getColor(R.color.cover_placeholder))) + error(R.drawable.cover_error) // Build the original request so we can add on our success listener val originalListener = apply(builder).build().listener diff --git a/app/src/main/res/drawable/cover_error.xml b/app/src/main/res/drawable/cover_error.xml new file mode 100644 index 0000000000..98ca1458d9 --- /dev/null +++ b/app/src/main/res/drawable/cover_error.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a106bf35af..9f9f62f191 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,6 +2,8 @@ @color/accent_blue + #1F888888 + #BA1B1B #FFDAD4 #FFFFFF