Search in sources :

Example 51 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project android_frameworks_base by crdroidandroid.

the class NotificationColorUtil method isGrayscaleIcon.

/**
     * Checks whether a Drawable is a small grayscale icon.
     * Grayscale here means "very close to a perfect gray"; icon means "no larger than 64dp".
     *
     * @param d The drawable to test.
     * @return True if the bitmap is grayscale; false if it is color or too large to examine.
     */
public boolean isGrayscaleIcon(Drawable d) {
    if (d == null) {
        return false;
    } else if (d instanceof BitmapDrawable) {
        BitmapDrawable bd = (BitmapDrawable) d;
        return bd.getBitmap() != null && isGrayscaleIcon(bd.getBitmap());
    } else if (d instanceof AnimationDrawable) {
        AnimationDrawable ad = (AnimationDrawable) d;
        int count = ad.getNumberOfFrames();
        return count > 0 && isGrayscaleIcon(ad.getFrame(0));
    } else if (d instanceof VectorDrawable) {
        // We just assume you're doing the right thing if using vectors
        return true;
    } else {
        return false;
    }
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) VectorDrawable(android.graphics.drawable.VectorDrawable)

Example 52 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project android_frameworks_base by crdroidandroid.

the class MinitBattery method updateImageView.

private void updateImageView() {
    switch(mStatus) {
        case BatteryManager.BATTERY_STATUS_CHARGING:
            AnimationDrawable ad = getChargingAnimation(mLevel);
            setImageDrawable(ad);
            ad.setOneShot(false);
            ad.start();
            break;
        case BatteryManager.BATTERY_STATUS_FULL:
            setImageDrawable(getNormalDrawable(100));
            break;
        default:
            setImageDrawable(getNormalDrawable(mLevel));
            break;
    }
    applyColorFilter();
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable)

Example 53 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project android_frameworks_base by crdroidandroid.

the class MinitBattery method getChargingAnimation.

private AnimationDrawable getChargingAnimation(int level) {
    AnimationDrawable ad = new AnimationDrawable();
    switch(mSettings.mChargeAnim) {
        case 0:
            ad.addFrame(getChargingDrawable(level), 1500);
            ad.addFrame(getNormalDrawable(level), 500);
            break;
        case 1:
            for (int i = 1; i < 100; i++) {
                ad.addFrame(getChargingDrawable(i), 20);
            }
            ad.addFrame(getChargingDrawable(100), 500);
            ad.addFrame(getNormalDrawable(level), 2500);
            break;
        case 2:
            ad.addFrame(getNormalDrawable(level), 2000);
            for (int i = level; i < 101; i++) {
                ad.addFrame(getChargingDrawable(i), 80);
            }
            break;
        case 3:
            int l = level;
            if (l == 0)
                l = 1;
            for (int i = 0; i < l; i++) {
                ad.addFrame(getChargingDrawable(i), 20);
            }
            ad.addFrame(getNormalDrawable(level), 2500);
            break;
        case 4:
            for (int i = 0; i < 101; i++) {
                ad.addFrame(getChargingDrawable(i), 20);
            }
            ad.addFrame(getNormalDrawable(level), 250);
            ad.addFrame(getChargingDrawable(level), 100);
            ad.addFrame(getNormalDrawable(level), 250);
            ad.addFrame(getChargingDrawable(level), 100);
            ad.addFrame(getNormalDrawable(level), 2000);
            break;
    }
    return ad;
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) Paint(android.graphics.Paint)

Example 54 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project little-bear-dictionary by daimajia.

the class ProgressBar method updateDrawableBounds.

private void updateDrawableBounds(int w, int h) {
    int right = w - getPaddingRight() - getPaddingLeft();
    int bottom = h - getPaddingBottom() - getPaddingTop();
    int top = 0;
    int left = 0;
    if (mIndeterminateDrawable != null) {
        if (mOnlyIndeterminate && !(mIndeterminateDrawable instanceof AnimationDrawable)) {
            final int intrinsicWidth = mIndeterminateDrawable.getIntrinsicWidth();
            final int intrinsicHeight = mIndeterminateDrawable.getIntrinsicHeight();
            final float intrinsicAspect = (float) intrinsicWidth / intrinsicHeight;
            final float boundAspect = (float) w / h;
            if (intrinsicAspect != boundAspect) {
                if (boundAspect > intrinsicAspect) {
                    final int width = (int) (h * intrinsicAspect);
                    left = (w - width) / 2;
                    right = left + width;
                } else {
                    final int height = (int) (w * (1 / intrinsicAspect));
                    top = (h - height) / 2;
                    bottom = top + height;
                }
            }
        }
        mIndeterminateDrawable.setBounds(left, top, right, bottom);
    }
    if (mProgressDrawable != null) {
        mProgressDrawable.setBounds(0, 0, right, bottom);
    }
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) SuppressLint(android.annotation.SuppressLint)

Example 55 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project little-bear-dictionary by daimajia.

the class ProgressBar method tileifyIndeterminate.

private Drawable tileifyIndeterminate(Drawable drawable) {
    if (drawable instanceof AnimationDrawable) {
        AnimationDrawable background = (AnimationDrawable) drawable;
        final int N = background.getNumberOfFrames();
        AnimationDrawable newBg = new AnimationDrawable();
        newBg.setOneShot(background.isOneShot());
        for (int i = 0; i < N; i++) {
            Drawable frame = tileify(background.getFrame(i), true);
            frame.setLevel(10000);
            newBg.addFrame(frame, background.getDuration(i));
        }
        newBg.setLevel(10000);
        drawable = newBg;
    }
    return drawable;
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) ClipDrawable(android.graphics.drawable.ClipDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RotateDrawable(android.graphics.drawable.RotateDrawable) SuppressLint(android.annotation.SuppressLint)

Aggregations

AnimationDrawable (android.graphics.drawable.AnimationDrawable)55 BitmapDrawable (android.graphics.drawable.BitmapDrawable)30 Drawable (android.graphics.drawable.Drawable)29 ClipDrawable (android.graphics.drawable.ClipDrawable)18 LayerDrawable (android.graphics.drawable.LayerDrawable)18 ShapeDrawable (android.graphics.drawable.ShapeDrawable)13 StateListDrawable (android.graphics.drawable.StateListDrawable)9 View (android.view.View)7 ImageView (android.widget.ImageView)7 SuppressLint (android.annotation.SuppressLint)5 TypedArray (android.content.res.TypedArray)5 XmlResourceParser (android.content.res.XmlResourceParser)5 VectorDrawable (android.graphics.drawable.VectorDrawable)5 Button (android.widget.Button)4 Paint (android.graphics.Paint)2 RecyclerView (android.support.v7.widget.RecyclerView)2 TextView (android.widget.TextView)2 AppWidgetHostView (android.appwidget.AppWidgetHostView)1 Intent (android.content.Intent)1 RotateDrawable (android.graphics.drawable.RotateDrawable)1