public String getAnimationInformation(Animatable animatable) { if (animatable instanceof AbstractAnimatedDrawable) { AbstractAnimatedDrawable animatedDrawable = (AbstractAnimatedDrawable) animatable; int animationDuration = animatedDrawable.getDuration(); int frameCount = animatedDrawable.getFrameCount(); String loopCountString = getLoopCountString(animatedDrawable); return getString(R.string.animation_info, animationDuration, frameCount, loopCountString); } return getString(R.string.unknown_animation_info); }
public boolean tryPausing(Animatable animatable) { // AbstractAnimatedDrawable supports pausing, but we could also have a different Animatable if (animatable instanceof AbstractAnimatedDrawable) { AbstractAnimatedDrawable animatedDrawable = (AbstractAnimatedDrawable) animatable; animatedDrawable.pause(); return true; } else { Toast.makeText(this, "Could not pause animation", Toast.LENGTH_SHORT).show(); return false; } }
private String getLoopCountString(AbstractAnimatedDrawable animatedDrawable) { return animatedDrawable.getLoopCount() == AnimatedImage.LOOP_COUNT_INFINITE ? getString(R.string.infinite) : animatedDrawable.getLoopCount() + ""; }