mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-21 08:21:14 +01:00
Replace VectorDrawableCompat.create() with AppCompatResources.getDrawable()
Fixes crash when loading pin icon in Android 5/6.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.util.preference
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import androidx.preference.DialogPreference
|
||||
@@ -13,7 +14,6 @@ import androidx.preference.PreferenceGroup
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.preference.PreferenceScreen
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.widget.preference.IntListPreference
|
||||
@@ -138,7 +138,7 @@ var Preference.titleRes: Int
|
||||
var Preference.iconRes: Int
|
||||
get() = 0 // set only
|
||||
set(value) {
|
||||
icon = VectorDrawableCompat.create(context.resources, value, context.theme)
|
||||
icon = AppCompatResources.getDrawable(context, value)
|
||||
}
|
||||
|
||||
var Preference.summaryRes: Int
|
||||
|
||||
@@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.util.view
|
||||
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
|
||||
/**
|
||||
* Set a vector on a [ImageView].
|
||||
@@ -10,7 +10,7 @@ import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||
* @param drawable id of drawable resource
|
||||
*/
|
||||
fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
|
||||
val vector = VectorDrawableCompat.create(resources, drawable, context.theme)
|
||||
val vector = AppCompatResources.getDrawable(context, drawable)
|
||||
if (tint != null) {
|
||||
vector?.mutate()
|
||||
vector?.setTint(tint)
|
||||
|
||||
Reference in New Issue
Block a user