Created
March 30, 2016 18:38
-
-
Save DrewCarlson/f7348cab8ab87cae33adb26173e34dc3 to your computer and use it in GitHub Desktop.
Drawable extensions for DrawableCompat helpers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.res.ColorStateList | |
import android.graphics.PorterDuff | |
import android.graphics.drawable.Drawable | |
import android.support.v4.graphics.drawable.DrawableCompat | |
fun Drawable.getLayoutDirectionCompat(): Int { | |
return DrawableCompat.getLayoutDirection(this) | |
} | |
fun Drawable.isAutoMirrorCompat(): Boolean { | |
return DrawableCompat.isAutoMirrored(this) | |
} | |
fun Drawable.jumpToCurrentStateCompat() { | |
DrawableCompat.jumpToCurrentState(this) | |
} | |
fun Drawable.setAutoMirrorCompat(mirrored: Boolean) { | |
DrawableCompat.setAutoMirrored(this, mirrored) | |
} | |
fun Drawable.setHotspotCompat(x: Float, y: Float) { | |
DrawableCompat.setHotspot(this, x, y) | |
} | |
fun Drawable.setHotspotBoundsCompat(left: Int, top: Int, right: Int, bottom: Int) { | |
DrawableCompat.setHotspotBounds(this, left, top, right, bottom) | |
} | |
fun Drawable.setLayoutDirectionCompat(layoutDirection: Int) { | |
DrawableCompat.setLayoutDirection(this, layoutDirection) | |
} | |
fun Drawable.setTintCompat(color: Int) { | |
DrawableCompat.setTint(DrawableCompat.wrap(this).mutate(), color) | |
} | |
fun Drawable.setTintListCompat(list: ColorStateList) { | |
DrawableCompat.setTintList(this, list) | |
} | |
fun Drawable.setTintMode(tintMode: PorterDuff.Mode) { | |
DrawableCompat.setTintMode(this, tintMode) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment