Commit 05761d2f authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add new methods.

parent 49952d35
......@@ -22,6 +22,7 @@ object DrawableHelper {
* Wraps an array of Drawable to be used for example for tinting.
*
* @param drawables The array of Drawable to wrap.
* @see wrapDrawable
* @see tintDrawables
*/
fun wrapDrawables(drawables: Array<Drawable>) {
......@@ -30,6 +31,16 @@ object DrawableHelper {
}
}
/**
* Wraps the Drawable to be used for example for tinting.
*
* @param drawable The Drawable to wrap.
* @see wrapDrawables
* @see tintDrawable
*/
fun wrapDrawable(drawable: Drawable) = DrawableCompat.wrap(drawable)
/**
* Tints an array of Drawable.
*
......@@ -38,6 +49,7 @@ object DrawableHelper {
* @param drawables The array of Drawable to tint.
* @param context The context.
* @param resId The resource id color to tint the Drawables.
* @see tintDrawable
* @see wrapDrawables
*/
fun tintDrawables(drawables: Array<Drawable>, context: Context, resId: Int) {
......@@ -46,6 +58,19 @@ object DrawableHelper {
}
}
/**
* Tints a Drawable.
*
* REMARK: you MUST always wrap the Drawable before tint it.
*
* @param drawable The Drawable to tint.
* @param context The context.
* @param resId The resource id color to tint the Drawable.
* @see tintDrawables
* @see wrapDrawable
*/
fun tintDrawable(drawable: Drawable, context: Context, resId: Int) = DrawableCompat.setTint(drawable, ContextCompat.getColor(context, resId))
/**
* Compounds an array of Drawable (to appear to the left of the text) into an array of EditText.
*
......@@ -53,6 +78,7 @@ object DrawableHelper {
*
* @param editTexts The array of EditText.
* @param drawables The array of Drawable.
* @see compoundDrawable
*/
fun compoundDrawables(editTexts: Array<EditText>, drawables: Array<Drawable>) {
if (editTexts.size != drawables.size) {
......@@ -63,4 +89,13 @@ object DrawableHelper {
}
}
}
/**
* Compounds a Drawable (to appear to the left of the text) into an EditText.
*
* @param editText The EditText.
* @param drawable The Drawable.
* @see compoundDrawables
*/
fun compoundDrawable(editText: EditText, drawable: Drawable) = editText.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment