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/TextViewUtil.java | 4 +-- .../conversationsplus/utils/ui/ViewUtil.java | 39 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java 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 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