diff options
author | steckbrief <steckbrief@chefmail.de> | 2018-03-11 18:41:02 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2018-03-11 18:41:02 +0100 |
commit | 4ea955d8fe47d6943f7e46f3c8d5485147780609 (patch) | |
tree | faead3d74759ac515d36700d857963cdfd506118 | |
parent | 1be60ce8c8426b357cf9e4b6e36e09e3a3a9557d (diff) |
improves TextViewUtil
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java index 9840ce41..6182d922 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java @@ -1,6 +1,7 @@ package de.thedevstack.conversationsplus.utils.ui; import android.support.annotation.ColorRes; +import android.support.annotation.IdRes; import android.support.annotation.StringRes; import android.text.util.Linkify; import android.util.Patterns; @@ -51,18 +52,38 @@ public final class TextViewUtil extends ViewUtil { tv.setAutoLinkMask(oldAutoLinkMask); } - public static void setText(View parentView, int textViewId, CharSequence text) { - TextView tv = (TextView) parentView.findViewById(textViewId); + public static TextView showAndSetText(TextView tv, CharSequence text) { + visible(tv); + return setText(tv, text); + } + + public static TextView showAndSetText(TextView tv, int textResId) { + visible(tv); + return setText(tv, textResId); + } + + public static TextView setText(TextView tv, CharSequence text) { if (null != tv) { tv.setText(text); } + + return tv; } - public static void setText(View parentView, int textViewId, int textResId) { - TextView tv = (TextView) parentView.findViewById(textViewId); + public static TextView setText(TextView tv, int textResId) { if (null != tv) { tv.setText(textResId); } + + return tv; + } + + public static TextView setText(View parentView, int textViewId, CharSequence text) { + return setText((TextView) parentView.findViewById(textViewId), text); + } + + public static TextView setText(View parentView, int textViewId, int textResId) { + return setText((TextView) parentView.findViewById(textViewId), textResId); } public static void enable(TextView tv) { @@ -117,8 +138,9 @@ public final class TextViewUtil extends ViewUtil { if (enabled != null) { tv.setEnabled(enabled); } + if (resid != null) { - tv.setText(resid); + setText(tv, resid); } } @@ -130,8 +152,9 @@ public final class TextViewUtil extends ViewUtil { if (enabled != null) { tv.setEnabled(enabled); } + if (text != null) { - tv.setText(text); + setText(tv, text); } } |