mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-26 19:08:25 +01:00
Add cover error drawable (#6782)
This commit is contained in:
parent
9c426bc216
commit
ddb856edc7
@ -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
|
||||
|
25
app/src/main/res/drawable/cover_error.xml
Normal file
25
app/src/main/res/drawable/cover_error.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--suppress AndroidElementNotAllowed -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<item>
|
||||
<color android:color="@color/cover_placeholder" />
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:top="48dp"
|
||||
android:bottom="48dp"
|
||||
android:left="48dp"
|
||||
android:right="48dp">
|
||||
<vector
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/cover_placeholder"
|
||||
android:pathData="M21,5v6.59l-2.29,-2.3c-0.39,-0.39 -1.03,-0.39 -1.42,0L14,12.59 10.71,9.3c-0.39,-0.39 -1.02,-0.39 -1.41,0L6,12.59 3,9.58L3,5c0,-1.1 0.9,-2 2,-2h14c1.1,0 2,0.9 2,2zM18,11.42l3,3.01L21,19c0,1.1 -0.9,2 -2,2L5,21c-1.1,0 -2,-0.9 -2,-2v-6.58l2.29,2.29c0.39,0.39 1.02,0.39 1.41,0l3.3,-3.3 3.29,3.29c0.39,0.39 1.02,0.39 1.41,0l3.3,-3.28z"/>
|
||||
</vector>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
@ -2,6 +2,8 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<color name="splash">@color/accent_blue</color>
|
||||
|
||||
<color name="cover_placeholder">#1F888888</color>
|
||||
|
||||
<color name="error">#BA1B1B</color>
|
||||
<color name="errorContainer">#FFDAD4</color>
|
||||
<color name="onError">#FFFFFF</color>
|
||||
|
Loading…
Reference in New Issue
Block a user