Example usage for android.graphics.drawable Drawable getCallback

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

Introduction

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

Prototype

@Nullable
public Callback getCallback() 

Source Link

Document

Return the current Callback implementation attached to this Drawable.

Usage

From source file:Main.java

public static View getView(Drawable rootDrawable) {
    Drawable.Callback callback = rootDrawable.getCallback();
    return callback instanceof View ? (View) callback : null;
}

From source file:Main.java

public static Drawable getRootDrawable(Drawable drawable) {
    Drawable.Callback callback = drawable.getCallback();
    if (callback instanceof Drawable) {
        return getRootDrawable((Drawable) callback);
    } else {//from   w  w w . j  a  va 2s  .  c om
        return drawable;
    }
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void wrapMenuItemIcon(@NonNull MenuItem item, int itemColor, int... excludeGroups) {
    if (ArrayUtils.contains(excludeGroups, item.getGroupId()))
        return;//from w w  w.  j ava2 s  . com
    final Drawable icon = item.getIcon();
    if (icon == null)
        return;
    icon.mutate();
    final Drawable.Callback callback = icon.getCallback();
    final ActionIconDrawable newIcon = new ActionIconDrawable(icon, itemColor);
    newIcon.setCallback(callback);
    item.setIcon(newIcon);
}

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

public static DisplayListDrawable acquireDisplayListDrawable(Drawable content, DisplayList displayList) {

    // When we are wrapping drawable with DisplayListDrawable we need to make sure that
    // wrapped DisplayListDrawable has the same view callback as original one had for correct
    // view invalidations.
    final Drawable.Callback callback = content.getCallback();

    DisplayListDrawable displayListDrawable = ComponentsConfiguration.usePooling
            ? sDisplayListDrawablePool.acquire()
            : null;//from  ww  w.j  a  v a  2  s. c  om
    if (displayListDrawable == null) {
        displayListDrawable = new DisplayListDrawable(content, displayList);
    } else {
        displayListDrawable.setWrappedDrawable(content, displayList);
    }
    displayListDrawable.setCallback(callback);

    return displayListDrawable;
}

From source file:org.mariotaku.twidere.util.ThemeUtils.java

public static void wrapMenuItemIcon(@NonNull MenuItem item, int itemColor, int... excludeGroups) {
    if (ArrayUtils.contains(excludeGroups, item.getGroupId()))
        return;// ww w .  j a v a 2s  .c om
    final Drawable icon = item.getIcon();
    if (icon == null)
        return;
    if (icon instanceof ActionIconDrawable) {
        ((ActionIconDrawable) icon).setDefaultColor(itemColor);
        item.setIcon(icon);
        return;
    }
    icon.mutate();
    final Drawable.Callback callback = icon.getCallback();
    final ActionIconDrawable newIcon = new ActionIconDrawable(icon, itemColor);
    newIcon.setCallback(callback);
    item.setIcon(newIcon);
}

From source file:com.albedinsky.android.ui.graphics.drawable.DrawableWrapper.java

/**
 * Creates a new instance of DrawableWrapper which wraps the given <var>drawable</var>.
 *
 * @param drawable The drawable to wrap.
 *//*  w  w  w . j  a  v  a  2 s  .  c  o m*/
public DrawableWrapper(@NonNull Drawable drawable) {
    this.mDrawable = drawable;

    /**
     * Copy current state of the wrapped drawable.
     */
    setState(drawable.getState());
    setBounds(drawable.getBounds());
    setLevel(drawable.getLevel());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        setCallback(drawable.getCallback());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setAlpha(drawable.getAlpha());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setColorFilter(drawable.getColorFilter());
    }
    mDrawable.setCallback(this);
}