diff options
Diffstat (limited to 'src/main')
-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); } } |