Search in sources :

Example 41 with Drawable

use of android.graphics.drawable.Drawable in project remusic by aa112901.

the class AppCompatImageHelper method tint.

@Override
public void tint() {
    if (mImageTintResId == 0 || !setSupportImageTint(mImageTintResId)) {
        Drawable drawable = mTintManager.getDrawable(mImageResId);
        if (drawable == null) {
            drawable = mImageResId == 0 ? null : ContextCompat.getDrawable(mView.getContext(), mImageResId);
        }
        setImageDrawable(drawable);
    }
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable)

Example 42 with Drawable

use of android.graphics.drawable.Drawable in project remusic by aa112901.

the class AppCompatProgressBarHelper method applySupportProgressTint.

private void applySupportProgressTint() {
    Log.e("themep", "apply progress tint");
    if (mProgressTintInfo != null && (mProgressTintInfo.mHasTintList || mProgressTintInfo.mHasTintMode)) {
        Log.e("themep", "apply progress tint true");
        final Drawable target = getTintTarget(android.R.id.progress, true);
        if (target != null) {
            TintManager.tintViewDrawable(mView, target, mProgressTintInfo);
            Log.e("themep", "apply progress tint true tint");
            // stateful before applying the tint, so let's try again.
            if (target.isStateful()) {
                target.setState(mView.getDrawableState());
            }
        }
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable)

Example 43 with Drawable

use of android.graphics.drawable.Drawable in project remusic by aa112901.

the class AppCompatProgressBarHelper method getTintTarget.

@Nullable
private Drawable getTintTarget(int layerId, boolean shouldFallback) {
    Drawable layer = null;
    final Drawable d = ((ProgressBar) mView).getProgressDrawable();
    if (d != null) {
        ((ProgressBar) mView).setProgressDrawable(d.mutate());
        if (d instanceof LayerDrawable) {
            layer = ((LayerDrawable) d).findDrawableByLayerId(layerId);
        }
        if (shouldFallback && layer == null) {
            layer = d;
        }
    }
    return layer;
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) ProgressBar(android.widget.ProgressBar) Nullable(android.support.annotation.Nullable)

Example 44 with Drawable

use of android.graphics.drawable.Drawable in project remusic by aa112901.

the class TintManager method getDrawable.

@Nullable
public Drawable getDrawable(@DrawableRes int resId) {
    final Context context = mContextRef.get();
    if (context == null)
        return null;
    if (resId == 0)
        return null;
    if (mSkipDrawableIdTags != null) {
        final String cachedTagName = mSkipDrawableIdTags.get(resId);
        if (SKIP_DRAWABLE_TAG.equals(cachedTagName)) {
            printLog("[Match Skip DrawableTag] Skip the drawable which is matched with the skip tag.");
            return null;
        }
    } else {
        // Create an id cache as we'll need one later
        mSkipDrawableIdTags = new SparseArray<>();
    }
    // Try the cache first (if it exists)
    Drawable drawable = getCacheDrawable(context, resId);
    if (drawable == null) {
        drawable = DrawableUtils.createDrawable(context, resId);
        if (drawable != null && !(drawable instanceof ColorDrawable)) {
            if (addCachedDrawable(resId, drawable)) {
                printLog("[loadDrawable] Saved drawable to cache: " + context.getResources().getResourceName(resId));
            }
        }
    }
    if (drawable == null) {
        mSkipDrawableIdTags.append(resId, SKIP_DRAWABLE_TAG);
    }
    return drawable;
}
Also used : Context(android.content.Context) ColorDrawable(android.graphics.drawable.ColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) FilterableStateListDrawable(com.bilibili.magicasakura.drawables.FilterableStateListDrawable) Nullable(android.support.annotation.Nullable)

Example 45 with Drawable

use of android.graphics.drawable.Drawable in project remusic by aa112901.

the class AppCompatBackgroundHelper method tint.

@Override
public void tint() {
    if (mBackgroundTintResId == 0 || !setSupportBackgroundTint(mBackgroundTintResId)) {
        Drawable drawable = mTintManager.getDrawable(mBackgroundResId);
        if (drawable == null) {
            drawable = mBackgroundResId == 0 ? null : ContextCompat.getDrawable(mView.getContext(), mBackgroundResId);
        }
        setBackgroundDrawable(drawable);
    }
}
Also used : Drawable(android.graphics.drawable.Drawable)

Aggregations

Drawable (android.graphics.drawable.Drawable)4516 BitmapDrawable (android.graphics.drawable.BitmapDrawable)795 View (android.view.View)579 Bitmap (android.graphics.Bitmap)476 ColorDrawable (android.graphics.drawable.ColorDrawable)473 ImageView (android.widget.ImageView)471 TextView (android.widget.TextView)439 Paint (android.graphics.Paint)322 LayerDrawable (android.graphics.drawable.LayerDrawable)314 Test (org.junit.Test)276 Context (android.content.Context)267 Resources (android.content.res.Resources)252 Rect (android.graphics.Rect)243 PackageManager (android.content.pm.PackageManager)233 StateListDrawable (android.graphics.drawable.StateListDrawable)212 TypedArray (android.content.res.TypedArray)205 Intent (android.content.Intent)155 ViewGroup (android.view.ViewGroup)148 AnimationDrawable (android.graphics.drawable.AnimationDrawable)147 ArrayList (java.util.ArrayList)139