From 670081087e5a6fc2e243cb5f1a9f157964eae552 Mon Sep 17 00:00:00 2001 From: Ztiany Date: Tue, 24 Sep 2019 19:49:22 +0800 Subject: [PATCH] update TextViewEx --- .../com/android/base/utils/android/views/TextViewEx.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_base/src/main/java/com/android/base/utils/android/views/TextViewEx.kt b/lib_base/src/main/java/com/android/base/utils/android/views/TextViewEx.kt index 6540157..6e32545 100644 --- a/lib_base/src/main/java/com/android/base/utils/android/views/TextViewEx.kt +++ b/lib_base/src/main/java/com/android/base/utils/android/views/TextViewEx.kt @@ -76,7 +76,7 @@ fun TextView.setBottomDrawable(@DrawableRes id: Int) { this.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, id) } -fun TextView.setTopDrawable(drawable: Drawable, retainOthers: Boolean = false) { +fun TextView.setTopDrawable(drawable: Drawable?, retainOthers: Boolean = false) { if (retainOthers) { val compoundDrawables = this.compoundDrawables this.setCompoundDrawablesWithIntrinsicBounds(compoundDrawables[0], drawable, compoundDrawables[2], compoundDrawables[3]) @@ -85,7 +85,7 @@ fun TextView.setTopDrawable(drawable: Drawable, retainOthers: Boolean = false) { } } -fun TextView.setLeftDrawable(drawable: Drawable, retainOthers: Boolean = false) { +fun TextView.setLeftDrawable(drawable: Drawable?, retainOthers: Boolean = false) { if (retainOthers) { val compoundDrawables = this.compoundDrawables this.setCompoundDrawablesWithIntrinsicBounds(drawable, compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]) @@ -94,7 +94,7 @@ fun TextView.setLeftDrawable(drawable: Drawable, retainOthers: Boolean = false) } } -fun TextView.setRightDrawable(drawable: Drawable, retainOthers: Boolean = false) { +fun TextView.setRightDrawable(drawable: Drawable?, retainOthers: Boolean = false) { if (retainOthers) { val compoundDrawables = this.compoundDrawables this.setCompoundDrawablesWithIntrinsicBounds(compoundDrawables[0], compoundDrawables[1], drawable, compoundDrawables[3]) @@ -103,7 +103,7 @@ fun TextView.setRightDrawable(drawable: Drawable, retainOthers: Boolean = false) } } -fun TextView.setBottomDrawable(drawable: Drawable, retainOthers: Boolean = false) { +fun TextView.setBottomDrawable(drawable: Drawable?, retainOthers: Boolean = false) { if (retainOthers) { val compoundDrawables = this.compoundDrawables this.setCompoundDrawablesWithIntrinsicBounds(compoundDrawables[0], compoundDrawables[1], compoundDrawables[2], drawable)