Manga in Kotlin. Expect some errors yet
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import android.support.annotation.DrawableRes
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.widget.ImageView
|
||||
|
||||
/**
|
||||
* Set a drawable on a [ImageView] using [ContextCompat] for backwards compatibility.
|
||||
*
|
||||
* @param drawable id of drawable resource
|
||||
*/
|
||||
fun ImageView.setDrawableCompat(@DrawableRes drawable: Int?) {
|
||||
if (drawable != null) {
|
||||
setImageDrawable(ContextCompat.getDrawable(context, drawable))
|
||||
} else {
|
||||
setImageResource(android.R.color.transparent)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user