@Override public boolean setVisible(boolean visible, boolean restart) { return wrapped.setVisible(visible, restart); }
private static void setDrawablesVisible(final Drawable[] drawables, final boolean visible) { for (final Drawable drawable : drawables) { if (drawable != null) { drawable.setVisible(visible, false); } } }
@Override public boolean setVisible(boolean visible, boolean restart) { return super.setVisible(visible, restart) || (mDrawable != null && mDrawable.setVisible(visible, restart)); }
@Override public boolean setVisible(boolean visible, boolean restart) { return super.setVisible(visible, restart) || mDrawable.setVisible(visible, restart); }
@Override public boolean setVisible(boolean visible, boolean restart) { boolean changed = super.setVisible(visible, restart); if (mLastDrawable != null) { mLastDrawable.setVisible(visible, restart); } if (mCurrDrawable != null) { mCurrDrawable.setVisible(visible, restart); } return changed; }
public boolean setVisible(boolean visible, boolean restart) { return super.setVisible(visible, restart) || this.mDrawable.setVisible(visible, restart); }
private void setDrawableVisibilitySafe(boolean visible, boolean restart) { if (mDrawable != null && mDrawable.isVisible() != visible) { try { mDrawable.setVisible(visible, restart); } catch (NullPointerException e) { // Swallow. LayerDrawable on KitKat sometimes causes this, if some of its children are null. // This should not cause any rendering bugs, since visibility is anyway a "hint". } } }
@Override public boolean setVisible(boolean visible, boolean restart) { final boolean changed = super.setVisible(visible, restart); setDrawableVisibilitySafe(visible, restart); return changed; }
@Override public boolean setVisible(boolean visible, boolean restart) { return super.setVisible(visible, restart) || mDrawable.setVisible(visible, restart); }
@Override public void setVisibility(int visibility) { super.setVisibility(visibility); if (mDrawable != null) { mDrawable.setVisible(visibility == VISIBLE, false); } }
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); isAttachedWindow = true; imageBlockImageLoader.stopLoad(); if (mDrawable != null) { mDrawable.setVisible(false, false); } }
@Override public boolean setVisible(boolean visible, boolean restart) { final boolean changed = super.setVisible(visible, restart); final ChildDrawable[] array = mLayerState.mChildren; final int N = mLayerState.mNum; for (int i = 0; i < N; i++) { final Drawable dr = array[i].mDrawable; if (dr != null) { dr.setVisible(visible, restart); } } return changed; }
/** * Mounts a drawable into a view. * @param view view into which the drawable should be mounted * @param drawable drawable to be mounted * @param bounds bounds of the drawable being mounted * @param flags flags that determine whether the drawable obtains state from the view * @param nodeInfo nodeInfo associated to the drawable node */ static void mountDrawable( View view, Drawable drawable, Rect bounds, int flags, NodeInfo nodeInfo) { drawable.setVisible(view.getVisibility() == View.VISIBLE, false); drawable.setCallback(view); maybeSetDrawableState(view, drawable, flags, nodeInfo); view.invalidate(bounds); }
@Override public boolean setVisible(boolean visible, boolean restart) { Preconditions.checkArgument(!isRecycled, "Cannot change the visibility of a recycled resource." + " Ensure that you unset the Drawable from your View before changing the View's" + " visibility."); isVisible = visible; if (!visible) { stopRunning(); } else if (isStarted) { startRunning(); } return super.setVisible(visible, restart); }
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); isAttachedWindow = true; if (mDrawable != null) { mDrawable.setVisible(getVisibility() == VISIBLE, false); } }
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); isAttachedWindow = false; imageBlockLoader.stopLoad(); if (mDrawable != null) { mDrawable.setVisible(false, false); } }
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); isAttachedWindow = false; if (mDrawable != null) { mDrawable.setVisible(getVisibility() == VISIBLE, false); } }
protected void positionSelectorLikeFocusCompat(int position, View sel) { // If we're changing position, update the visibility since the selector // is technically being detached from the previous selection. final Drawable selector = getSelector(); final boolean manageState = selector != null && position != INVALID_POSITION; if (manageState) { selector.setVisible(false, false); } positionSelectorCompat(position, sel); if (manageState) { final Rect bounds = mSelectorRect; final float x = bounds.exactCenterX(); final float y = bounds.exactCenterY(); selector.setVisible(getVisibility() == VISIBLE, false); DrawableCompat.setHotspot(selector, x, y); } } protected void positionSelectorCompat(int position, View sel) {
@Override public void setVisibility(int visibility) { super.setVisibility(visibility); for (int i = 0, size = (mDrawableMountItems == null) ? 0 : mDrawableMountItems.size(); i < size; i++) { final Drawable drawable = (Drawable) mDrawableMountItems.valueAt(i).getMountableContent(); drawable.setVisible(visibility == View.VISIBLE, false); } }
@Test public void testSetVisibility() { Drawable d1 = mock(ColorDrawable.class); when(d1.getBounds()).thenReturn(new Rect()); mount(0, d1); Drawable d2 = mock(ColorDrawable.class); when(d2.getBounds()).thenReturn(new Rect()); mount(1, d2); View v1 = mock(View.class); mount(2, v1); mHost.setVisibility(GONE); mHost.setVisibility(INVISIBLE); mHost.setVisibility(VISIBLE); verify(d1, times(2)).setVisible(eq(true), eq(false)); verify(d1, times(2)).setVisible(eq(false), eq(false)); verify(d2, times(2)).setVisible(eq(true), eq(false)); verify(d2, times(2)).setVisible(eq(false), eq(false)); verify(v1, never()).setVisibility(anyInt()); }