2016-03-13 17:06:32 -04:00
|
|
|
package eu.kanade.tachiyomi.util
|
|
|
|
|
|
|
|
import android.support.annotation.DrawableRes
|
2016-04-08 10:18:41 -04:00
|
|
|
import android.support.graphics.drawable.VectorDrawableCompat
|
2016-03-13 17:06:32 -04:00
|
|
|
import android.support.v4.content.ContextCompat
|
2016-03-12 08:22:40 -05:00
|
|
|
import android.support.v4.graphics.drawable.DrawableCompat
|
2016-03-13 17:06:32 -04:00
|
|
|
import android.widget.ImageView
|
|
|
|
|
|
|
|
/**
|
2016-04-08 10:18:41 -04:00
|
|
|
* Set a vector on a [ImageView].
|
2016-03-13 17:06:32 -04:00
|
|
|
*
|
|
|
|
* @param drawable id of drawable resource
|
|
|
|
*/
|
2016-04-08 10:18:41 -04:00
|
|
|
fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
|
|
|
|
val vector = VectorDrawableCompat.create(resources, drawable, context.theme)
|
|
|
|
if (tint != null) {
|
|
|
|
vector?.setTint(tint)
|
2016-03-13 17:06:32 -04:00
|
|
|
}
|
2016-04-08 10:18:41 -04:00
|
|
|
setImageDrawable(vector)
|
|
|
|
}
|