aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java
blob: 7742258763b1ba18f42aabadc2279c646b5ab1ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
    }

}