From 563fcfa77580292a7ff2360eea20553743bd0ae7 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Wed, 11 Jan 2017 14:49:07 +0100 Subject: Generic view util added to change the visibility of subclasses of View --- .../conversationsplus/utils/ui/ViewUtil.java | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java') 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 visible(View parentView, @IdRes int textViewId) { + T tv = (T) parentView.findViewById(textViewId); + if (null != tv) { + tv.setVisibility(View.VISIBLE); + } + + return tv; + } + + public static 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 gone(View parentView, @IdRes int textViewId) { + T tv = (T) parentView.findViewById(textViewId); + if (null != tv) { + tv.setVisibility(View.GONE); + } + + return tv; + } + +} -- cgit v1.2.3