mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-12 12:08:56 +01:00
Upgrade support library. Switch gradle build tools and AS to 2.0. Adapt code to new support lib
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import android.support.annotation.DrawableRes
|
||||
import android.support.graphics.drawable.VectorDrawableCompat
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.graphics.drawable.DrawableCompat
|
||||
import android.widget.ImageView
|
||||
|
||||
/**
|
||||
* Set a drawable on a [ImageView] using [ContextCompat] for backwards compatibility.
|
||||
* Set a vector on a [ImageView].
|
||||
*
|
||||
* @param drawable id of drawable resource
|
||||
*/
|
||||
fun ImageView.setDrawableCompat(@DrawableRes drawable: Int?) {
|
||||
if (drawable != null) {
|
||||
var drawable = ContextCompat.getDrawable(context, drawable)
|
||||
DrawableCompat.setTint(drawable,this.context.theme.getResourceColor(android.R.attr.textColorHint))
|
||||
setImageDrawable(drawable)
|
||||
} else {
|
||||
setImageResource(android.R.color.transparent)
|
||||
fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
|
||||
val vector = VectorDrawableCompat.create(resources, drawable, context.theme)
|
||||
if (tint != null) {
|
||||
vector?.setTint(tint)
|
||||
}
|
||||
}
|
||||
setImageDrawable(vector)
|
||||
}
|
||||
Reference in New Issue
Block a user