aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/ui/ViewUtil.java
blob: 7147f681aa74311b32b721d4f5566755bf895435 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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) {
        return ViewUtil.visible((T) parentView.findViewById(textViewId));
    }

    public static <T extends View> T invisible(View parentView, @IdRes int textViewId) {
        return ViewUtil.invisible((T) parentView.findViewById(textViewId));
    }

    public static <T extends View> T gone(View parentView, @IdRes int textViewId) {
        return ViewUtil.gone((T) parentView.findViewById(textViewId));
    }

    public static <T extends View> T gone(T view) {
        if (null != view) {
            view.setVisibility(View.GONE);
        }
        return view;
    }

    public static <T extends View> void gone(T... views) {
        if (null != views && 0 < views.length) {
            for (T view : views) {
                gone(view);
            }
        }
    }

    public static <T extends View> T visible(T view) {
        if (null != view) {
            view.setVisibility(View.VISIBLE);
        }
        return view;
    }

    public static <T extends View> void visible(T... views) {
        if (null != views && 0 < views.length) {
            for (T view : views) {
                visible(view);
            }
        }
    }

    public static <T extends View> T invisible(T view) {
        if (null != view) {
            view.setVisibility(View.INVISIBLE);
        }
        return view;
    }

    public static <T extends View> void invisible(T... views) {
        if (null != views && 0 < views.length) {
            for (T view : views) {
                invisible(view);
            }
        }
    }
}