package com.jbarbosa.viewcontrolvisibility;

import android.view.View;

import java.util.Arrays;
import java.util.HashSet;

/**
 * Created by Josinaldo on 06/07/2015.
 */

public class ViewControlVisibility {

    private HashSet<View> mViews;

    public ViewControlVisibility(View... views) {
        mViews = new HashSet<>();
        mViews.addAll(Arrays.asList(views));
        hideAll();
    }

    private void hideAll() {
        for (View view : mViews) {
            turnGone(view);
        }
    }

    public void show(View... views) {
        hideAll();

        for (View view : views) {
            if (mViews.contains(view))
                turnVisible(view);
            else
                throw new IllegalStateException(Constants.TAG + Constants.VIEW_NOT_FOUND);
        }
    }

    /* Visibility controls */
    public static void turnVisible(View view) {
        if (view != null)
            view.setVisibility(View.VISIBLE);
        else
            throw new IllegalStateException(Constants.TAG + Constants.VIEW_NULL);
    }

    public static void turnGone(View view) {
        if (view != null)
            view.setVisibility(View.GONE);
        else
            throw new IllegalStateException(Constants.TAG + Constants.VIEW_NULL);
    }

    public static void turnInvisible(View view) {
        if (view != null)
            view.setVisibility(View.INVISIBLE);
        else
            throw new IllegalStateException(Constants.TAG + Constants.VIEW_NULL);
    }

}

package com.jbarbosa.viewcontrolvisibility;

import android.view.View;

import java.util.Arrays;
import java.util.HashSet;

/**
 * Created by Josinaldo on 06/07/2015.
 */

public class ViewControlVisibility {

    private HashSet<View> mViews;

    public ViewControlVisibility(View... views) {
        this(false, views);
    }

    public ViewControlVisibility(boolean startAllHide, View... views) {
        mViews = new HashSet<>();
        mViews.addAll(Arrays.asList(views));

        if (startAllHide) {
            hideAll();
        }
    }

    private void hideAll() {
        for (View view : mViews) {
            turnGone(view);
        }
    }

    public void show(View... views) {
        hideAll();

        for (View view : views) {
            if (mViews.contains(view))
                turnVisible(view);
            else
                throw new IllegalStateException(Constants.TAG + Constants.VIEW_NOT_FOUND);
        }
    }

    /* Visibility controls */
    public static void turnVisible(View view) {
        if (view != null)
            view.setVisibility(View.VISIBLE);
        else
            throw new IllegalStateException(Constants.TAG + Constants.VIEW_NULL);
    }

    public static void turnGone(View view) {
        if (view != null)
            view.setVisibility(View.GONE);
        else
            throw new IllegalStateException(Constants.TAG + Constants.VIEW_NULL);
    }

    public static void turnInvisible(View view) {
        if (view != null)
            view.setVisibility(View.INVISIBLE);
        else
            throw new IllegalStateException(Constants.TAG + Constants.VIEW_NULL);
    }

}

add new constructor only views and other with hideAll optional