List of usage examples for android.os Handler postAtTime
public final boolean postAtTime(Runnable r, long uptimeMillis)
From source file:Main.java
/** * Starts an AnimationDrawable animation at the specified point in the future. * @param handler The Handler for the Activity in which the animation will run. * @param drawable The AnimationDrawable that will have its animation started. * @param millisFromNow The number of milliseconds to wait before starting this animation. *//*from w w w. j a v a 2 s . co m*/ public static void startAnimationInFuture(final Handler handler, final AnimationDrawable drawable, long millisFromNow) { handler.postAtTime(new Runnable() { @Override public void run() { drawable.start(); } }, SystemClock.uptimeMillis() + millisFromNow); }
From source file:Main.java
/** * Replaces an ImageView's background AnimationDrawable with the specified resource id in the * future. Calls start() on the AnimationDrawable once it has been replaced. * @param handler The Handler for the Activity in which the animation will run. * @param imageView An ImageView that has a background that can be casted to AnimationDrawable. * @param animationResourceId The animation's resource id. * @param color The color to apply to the AnimationDrawable. * @param millisFromNow The number of milliseconds to wait before replacing the animation. *//*from w ww . jav a2s. c o m*/ public static void replaceAnimationInFuture(final Handler handler, final ImageView imageView, final int animationResourceId, final int color, long millisFromNow) { handler.postAtTime(new Runnable() { @Override public void run() { imageView.setBackgroundResource(animationResourceId); imageView.getBackground().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); ((AnimationDrawable) (imageView.getBackground())).start(); } }, SystemClock.uptimeMillis() + millisFromNow); }