ViewUtils { 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; } private  ViewUtils(); static V setGone(final V view, final boolean gone); static V setInvisible(final V view,
      final boolean invisible); static void increaseHitRectBy(final int amount, final View delegate); static void increaseHitRectBy(final int top, final int left, final int bottom, final int right, final View delegate); static int transformToDensityPixel(int regularPixel, DisplayMetrics displayMetrics); static int transformToDensityPixel(int regularPixel, float densityDpi);  }
@Test public void setVisibleViewGone() { View view = new View(new Activity()); view.setVisibility(VISIBLE); assertEquals(VISIBLE, view.getVisibility()); ViewUtils.setGone(view, true); assertEquals(GONE, view.getVisibility()); }
@Test public void setInvisibleViewGone() { View view = new View(new Activity()); view.setVisibility(INVISIBLE); assertEquals(INVISIBLE, view.getVisibility()); ViewUtils.setGone(view, true); assertEquals(GONE, view.getVisibility()); }