Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Android: add playOnce()
Browse files Browse the repository at this point in the history
Summary:
Add `playOnce()` that will play the animation only once and stops at the end
Closes #94

Differential Revision: D4385175

Pulled By: lozzle

fbshipit-source-id: 8b2f65003bfb9a3cfc040e90385369d13e1025c5
  • Loading branch information
m1ga authored and facebook-github-bot committed Jan 5, 2017
1 parent 4bd6cc0 commit 07ce61e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ kfDrawable.stopAnimation();

// Stops the animation when the current animation ends.
kfDrawable.stopAnimationAtLoopEnd();

// Starts the animation and plays it once. Will stop at the end
kfDrawable.playOnce();
```

### Mobile Frameworks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ public void startAnimation() {
mKeyframesDrawableAnimationCallback.start();
}

/**
* Starts the animation and plays it once
*/
public void playOnce() {
mKeyframesDrawableAnimationCallback.playOnce();
}

/**
* Stops the animation callbacks for this drawable immediately.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ public void start() {
postCallback();
}

/**
* Starts the animation and plays it once
*/
public void playOnce() {
mStopAtLoopEnd = true;
mStartTimeMillis = 0;
mCurrentLoopNumber = 0;
cancelCallback();
postCallback();
}

/**
* Stops the callbacks animation and resets the start time.
*/
Expand Down

0 comments on commit 07ce61e

Please sign in to comment.