diff options
author | steckbrief <steckbrief@chefmail.de> | 2017-01-11 14:49:07 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2017-01-11 14:49:07 +0100 |
commit | 563fcfa77580292a7ff2360eea20553743bd0ae7 (patch) | |
tree | b1252827b222ed79d1fc73e4f9b76467fae2048a /src | |
parent | 990a35c47500c6a3f4292d41450a5f6cb689c7b1 (diff) |
Generic view util added to change the visibility of subclasses of View
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java | 4 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java | 39 |
2 files changed, 41 insertions, 2 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 a775dad6..27a269f2 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java @@ -5,9 +5,9 @@ import android.view.View; import android.widget.TextView; /** - * Created by steckbrief on 29.03.2016. + * */ -public final class TextViewUtil { +public final class TextViewUtil extends ViewUtil { public static void setText(View parentView, int textViewId, CharSequence text) { TextView tv = (TextView) parentView.findViewById(textViewId); diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java new file mode 100644 index 00000000..77422587 --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java @@ -0,0 +1,39 @@ +package de.thedevstack.conversationsplus.utils.ui; + +import android.support.annotation.IdRes; +import android.view.View; + +/** + * Created by steckbrief on 11.01.2017. + */ + +public class ViewUtil { + + public static <T extends View> T visible(View parentView, @IdRes int textViewId) { + T tv = (T) parentView.findViewById(textViewId); + if (null != tv) { + tv.setVisibility(View.VISIBLE); + } + + return tv; + } + + public static <T extends View> T invisible(View parentView, @IdRes int textViewId) { + T tv = (T) parentView.findViewById(textViewId); + if (null != tv) { + tv.setVisibility(View.INVISIBLE); + } + + return tv; + } + + public static <T extends View> T gone(View parentView, @IdRes int textViewId) { + T tv = (T) parentView.findViewById(textViewId); + if (null != tv) { + tv.setVisibility(View.GONE); + } + + return tv; + } + +} |