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/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java | |
parent | 990a35c47500c6a3f4292d41450a5f6cb689c7b1 (diff) |
Generic view util added to change the visibility of subclasses of View
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java | 39 |
1 files changed, 39 insertions, 0 deletions
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; + } + +} |