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