@SuppressWarnings("WeakerAccess") public void setFrameTransformation(Transformation<Bitmap> frameTransformation, Bitmap firstFrame) { state.frameLoader.setFrameTransformation(frameTransformation, firstFrame); }
/** * Returns the current frame index in the range 0..{@link #getFrameCount()} - 1, or -1 if no frame * is displayed. */ // Public API. @SuppressWarnings("WeakerAccess") public int getFrameIndex() { return state.frameLoader.getCurrentIndex(); }
/** * Clears any resources for loading frames that are currently held on to by this object. */ public void recycle() { isRecycled = true; state.frameLoader.clear(); }
/** * Starts the animation from the first frame. Can only be called while animation is not running. */ // Public API. @SuppressWarnings("unused") public void startFromFirstFrame() { Preconditions.checkArgument(!isRunning, "You cannot restart a currently running animation."); state.frameLoader.setNextStartFromFirstFrame(); start(); }
private void startRunning() { Preconditions.checkArgument(!isRecycled, "You cannot start a recycled Drawable. Ensure that" + "you clear any references to the Drawable when clearing the corresponding request."); // If we have only a single frame, we don't want to decode it endlessly. if (state.frameLoader.getFrameCount() == 1) { invalidateSelf(); } else if (!isRunning) { isRunning = true; state.frameLoader.subscribe(this); invalidateSelf(); } }
@Override public void start() { isStarted = true; resetLoopCount(); if (isVisible) { startRunning(); } }
Bitmap getCurrentFrame() { return current != null ? current.getResource() : firstFrame; }
private void start() { if (isRunning) { return; } isRunning = true; isCleared = false; loadNextFrame(); }
@Override public void stop() { isStarted = false; stopRunning(); }
@Override public int getSize() { return drawable.getSize(); }
private void stopRunning() { isRunning = false; state.frameLoader.unsubscribe(this); }
@Override public int getIntrinsicWidth() { return state.frameLoader.getWidth(); }
@Override public int getIntrinsicHeight() { return state.frameLoader.getHeight(); }
public int getSize() { return state.frameLoader.getSize(); }
public int getFrameCount() { return state.frameLoader.getFrameCount(); }
public Bitmap getFirstFrame() { return state.frameLoader.getFirstFrame(); }
public Transformation<Bitmap> getFrameTransformation() { return state.frameLoader.getFrameTransformation(); }