package com.lean56.andplug.utils;
import android.view.View;
import static android.view.View.GONE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
/**
* Utilities for working with the {@link View} class
*
* @author Kevin Sawicki <kevinsawicki@gmail.com>
* @author Charles
*/
public class ViewUtils {
/**
* Set visibility of given view to be gone or visible
* <p/>
* This method has no effect if the view visibility is currently invisible
*
* @param view
* @param gone
* @return view
*/
public static <V extends View> V setGone(final V view, final boolean gone) {
if (view != null)
if (gone) {
if (GONE != view.getVisibility())
view.setVisibility(GONE);
} else {
if (VISIBLE != view.getVisibility())
view.setVisibility(VISIBLE);
}
return view;
}
/**
* Set visibility of given view to be invisible or visible
* <p/>
* This method has no effect if the view visibility is currently gone
*
* @param view
* @param invisible
* @return view
*/
public static <V extends View> V setInvisible(final V view,
final boolean invisible) {
if (view != null)
if (invisible) {
if (INVISIBLE != view.getVisibility())
view.setVisibility(INVISIBLE);
} else {
if (VISIBLE != view.getVisibility())
view.setVisibility(VISIBLE);
}
return view;
}
}