List of usage examples for android.graphics.drawable AnimationDrawable getFrame
public Drawable getFrame(int index)
From source file:tk.wasdennnoch.androidn_ify.utils.NotificationColorUtil.java
/** * 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.//w w w. j a v a2s .c o m * @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; } }
From source file:com.actionbarsherlock.internal.widget.IcsProgressBar.java
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader.//from w ww .ja va2 s . c o m */ 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; }