Commit e2469712 authored by Hussein El Feky's avatar Hussein El Feky

Refactored code

parent a346b70e
...@@ -86,10 +86,10 @@ object DrawableHelper { ...@@ -86,10 +86,10 @@ object DrawableHelper {
return return
} else { } else {
for (i in textView.indices) { for (i in textView.indices) {
if (textView[i].resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) { if (textView[i].resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL) {
textView[i].setCompoundDrawablesWithIntrinsicBounds(drawables[i], null, null, null)
} else {
textView[i].setCompoundDrawablesWithIntrinsicBounds(null, null, drawables[i], null) textView[i].setCompoundDrawablesWithIntrinsicBounds(null, null, drawables[i], null)
} else {
textView[i].setCompoundDrawablesWithIntrinsicBounds(drawables[i], null, null, null)
} }
} }
} }
...@@ -103,10 +103,10 @@ object DrawableHelper { ...@@ -103,10 +103,10 @@ object DrawableHelper {
* @see compoundDrawables * @see compoundDrawables
*/ */
fun compoundStartDrawable(textView: TextView, drawable: Drawable) = fun compoundStartDrawable(textView: TextView, drawable: Drawable) =
if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) { if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL) {
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null) textView.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null)
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
} }
/** /**
...@@ -117,10 +117,10 @@ object DrawableHelper { ...@@ -117,10 +117,10 @@ object DrawableHelper {
* @see compoundStartDrawable * @see compoundStartDrawable
*/ */
fun compoundEndDrawable(textView: TextView, drawable: Drawable) = fun compoundEndDrawable(textView: TextView, drawable: Drawable) =
if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) { if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL) {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null)
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null) textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null)
} }
/** /**
...@@ -136,10 +136,10 @@ object DrawableHelper { ...@@ -136,10 +136,10 @@ object DrawableHelper {
startDrawable: Drawable, startDrawable: Drawable,
endDrawable: Drawable endDrawable: Drawable
) = ) =
if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) { if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL) {
textView.setCompoundDrawablesWithIntrinsicBounds(startDrawable, null, endDrawable, null)
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(endDrawable, null, startDrawable, null) textView.setCompoundDrawablesWithIntrinsicBounds(endDrawable, null, startDrawable, null)
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(startDrawable, null, endDrawable, null)
} }
/** /**
......
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