Java Code Examples for android.graphics.drawable.Animatable#isRunning()
The following examples show how to use
android.graphics.drawable.Animatable#isRunning() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NextDoneButton.java From IntroActivity with Apache License 2.0 | 6 votes |
/** * Toggle the current button style, changing the icon * and animating the change if the device supports it. */ public void toggle() { // Toggle the button style mButtonStyle = (mButtonStyle == STYLE_NEXT) ? STYLE_DONE : STYLE_NEXT; // Set image drawable depending on the button style setImageDrawable(mButtonStyle == STYLE_NEXT ? mNextDrawable : mDoneDrawable); // Attempt to animate the button if we're on Lollipop or above if (Utils.hasLollipop()) { Drawable drawable = getDrawable(); if (drawable instanceof Animatable) { Animatable animatable = (Animatable) drawable; if (animatable.isRunning()) { animatable.stop(); } animatable.start(); } } }
Example 2
Source File: ToggleAnimationClickListener.java From fresco with MIT License | 6 votes |
@Override public void onClick(View v) { DraweeController controller = mDraweeView.getController(); if (controller == null) { return; } Animatable animatable = controller.getAnimatable(); if (animatable == null) { return; } if (animatable.isRunning()) { animatable.stop(); } else { animatable.start(); } }
Example 3
Source File: ZxingForegroundView.java From ProjectX with Apache License 2.0 | 6 votes |
/** * 设置开启图片 * * @param drawable 开启图片 */ public void setOpenDrawable(Drawable drawable) { if (mOpenDrawable == drawable) return; if (mOpenDrawable != null) { if (mOpenDrawable instanceof Animatable) ((Animatable) mOpenDrawable).stop(); mOpenDrawable.setCallback(null); } mOpenDrawable = drawable; if (mOpenDrawable != null) { mOpenDrawable.setCallback(this); if (mOpenDrawable instanceof Animatable) { Animatable animatable = (Animatable) mOpenDrawable; if (!animatable.isRunning()) animatable.start(); } } invalidate(); }
Example 4
Source File: ZxingForegroundView.java From ProjectX with Apache License 2.0 | 6 votes |
/** * 设置错误图片 * * @param drawable 错误图片 */ public void setErrorDrawable(Drawable drawable) { if (mErrorDrawable == drawable) return; if (mErrorDrawable != null) { if (mErrorDrawable instanceof Animatable) ((Animatable) mErrorDrawable).stop(); mErrorDrawable.setCallback(null); } mErrorDrawable = drawable; if (mErrorDrawable != null) { mErrorDrawable.setCallback(this); if (mErrorDrawable instanceof Animatable) { Animatable animatable = (Animatable) mErrorDrawable; if (!animatable.isRunning()) animatable.start(); } } invalidate(); }