Search in sources :

Example 46 with AnimationDrawable

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

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 47 with AnimationDrawable

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

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 48 with AnimationDrawable

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

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 49 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project HoloEverywhere by Prototik.

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 50 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)

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