Example usage for android.graphics.drawable Drawable setVisible

List of usage examples for android.graphics.drawable Drawable setVisible

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable setVisible.

Prototype

public boolean setVisible(boolean visible, boolean restart) 

Source Link

Document

Set whether this Drawable is visible.

Usage

From source file:com.facebook.litho.ComponentHostUtils.java

/**
 * Mounts a drawable into a view.//from  w ww .java  2s .com
 * @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);
}

From source file:Main.java

/**
 * Copies various properties from one drawable to the other.
 * @param to drawable to copy properties to
 * @param from drawable to copy properties from
 *//*from  ww  w. ja v  a2  s  .  c o m*/
public static void copyProperties(Drawable to, Drawable from) {
    if (from == null || to == null || to == from) {
        return;
    }

    to.setBounds(from.getBounds());
    to.setChangingConfigurations(from.getChangingConfigurations());
    to.setLevel(from.getLevel());
    to.setVisible(from.isVisible(), /* restart */false);
    to.setState(from.getState());
}

From source file:com.negusoft.greenmatter.drawable.CompoundDrawableWrapper.java

@Override
public boolean setVisible(boolean visible, boolean restart) {
    for (Drawable d : mSecondaryDrawables)
        d.setVisible(visible, restart);
    return super.setVisible(visible, restart);
}

From source file:com.tsoliveira.android.listeners.DragDropTouchListener.java

private Bitmap copyViewAsBitmap(View v) {
    //Clear ripple effect to not get into screenshot,
    // need something more clever here
    if (v instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) v;
        Drawable foreground = frameLayout.getForeground();
        if (foreground != null)
            foreground.setVisible(false, false);
    } else {//w  w  w . j a va 2 s  .co m
        if (v.getBackground() != null)
            v.getBackground().setVisible(false, false);
    }

    Bitmap bitmap = Bitmap.createBitmap(v.getMeasuredWidth(), v.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    v.draw(canvas);

    return bitmap;
}

From source file:android.support.v7.internal.widget.ListViewCompat.java

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);
    }//from  w ww .j a  va2s .  c o m

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

From source file:com.shizhefei.view.largeimage.UpdateImageView.java

private void updateDrawable(Drawable d) {
    if (mDrawable != null) {
        mDrawable.setCallback(null);/* ww w  .  j a  va2 s  . c  o m*/
        unscheduleDrawable(mDrawable);
    }
    mDrawable = d;
    if (d != null) {
        d.setCallback(this);
        DrawableCompat.setLayoutDirection(d, DrawableCompat.getLayoutDirection(d));
        if (d.isStateful()) {
            d.setState(getDrawableState());
        }
        d.setVisible(getVisibility() == VISIBLE, true);
        d.setLevel(mLevel);
        mDrawableWidth = d.getIntrinsicWidth();
        mDrawableHeight = d.getIntrinsicHeight();
        //            applyImageTint();
        //            applyColorMod();
        //
        //            configureBounds();
    } else {
        mDrawableWidth = mDrawableHeight = -1;
    }
}

From source file:com.commonsware.cwac.mediarouter.app.MediaRouteButton.java

private void setRemoteIndicatorDrawable(Drawable d) {
    if (mRemoteIndicator != null) {
        mRemoteIndicator.setCallback(null);
        unscheduleDrawable(mRemoteIndicator);
    }/*from  w  w w  .jav a2s . co m*/
    mRemoteIndicator = d;
    if (d != null) {
        d.setCallback(this);
        d.setState(getDrawableState());
        d.setVisible(getVisibility() == VISIBLE, false);
    }

    refreshDrawableState();
}

From source file:android.support.v7.app.MediaRouteButton.java

/**
 * Sets a drawable to use as the remote route indicator.
 *//* www .j a  v a  2  s . c o m*/
public void setRemoteIndicatorDrawable(Drawable d) {
    if (mRemoteIndicator != null) {
        mRemoteIndicator.setCallback(null);
        unscheduleDrawable(mRemoteIndicator);
    }
    mRemoteIndicator = d;
    if (d != null) {
        d.setCallback(this);
        d.setState(getDrawableState());
        d.setVisible(getVisibility() == VISIBLE, false);
    }

    refreshDrawableState();
}

From source file:com.android.contacts.DynamicShortcuts.java

private Bitmap getFallbackAvatar(String displayName, String lookupKey) {
    // Use a circular icon if we're not on O or higher.
    final boolean circularIcon = !BuildCompat.isAtLeastO();

    final ContactPhotoManager.DefaultImageRequest request = new ContactPhotoManager.DefaultImageRequest(
            displayName, lookupKey, circularIcon);
    if (BuildCompat.isAtLeastO()) {
        // On O, scale the image down to add the padding needed by AdaptiveIcons.
        request.scale = LetterTileDrawable.getAdaptiveIconScale();
    }/*from w  ww .j  a va  2 s.  co  m*/
    final Drawable avatar = ContactPhotoManager.getDefaultAvatarDrawableForContact(mContext.getResources(),
            true, request);
    final Bitmap result = Bitmap.createBitmap(mIconSize, mIconSize, Bitmap.Config.ARGB_8888);
    // The avatar won't draw unless it thinks it is visible
    avatar.setVisible(true, true);
    final Canvas canvas = new Canvas(result);
    avatar.setBounds(0, 0, mIconSize, mIconSize);
    avatar.draw(canvas);
    return result;
}

From source file:com.shizhefei.view.largeimage.LargeImageView.java

private void updateDrawable(Drawable d) {
    if (mDrawable != null) {
        mDrawable.setCallback(null);/*ww  w . j  a v a2s  . c o m*/
        unscheduleDrawable(mDrawable);
    }
    mDrawable = d;
    if (d != null) {
        d.setCallback(this);
        DrawableCompat.setLayoutDirection(d, DrawableCompat.getLayoutDirection(d));
        if (d.isStateful()) {
            d.setState(getDrawableState());
        }
        d.setVisible(getVisibility() == VISIBLE, true);
        d.setLevel(mLevel);
        mDrawableWidth = d.getIntrinsicWidth();
        mDrawableHeight = d.getIntrinsicHeight();
    } else {
        mDrawableWidth = mDrawableHeight = -1;
    }
}