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);
    }

}

@@ -280,32 +280,139 @@
 iew... views) %7B%0A
+        this(false, views);%0A    %7D%0A%0A    public ViewControlVisibility(boolean startAllHide, View... views) %7B%0A
         mViews =
@@ -474,16 +474,49 @@
 iews));%0A
+%0A        if (startAllHide) %7B%0A    
         
@@ -522,24 +522,34 @@
  hideAll();%0A
+        %7D%0A
     %7D%0A%0A    p

add new constructor only views and other with hideAll optional