Skip to content

Commit

Permalink
Merge pull request #8 from markzhai/master
Browse files Browse the repository at this point in the history
Add animation loop support
  • Loading branch information
geftimov committed Jun 2, 2015
2 parents abe3712 + ab44945 commit 7e865bc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ To make custom Action , just extend the BaseAction and implement the two abstrac
[Martin Vitanov](https://github.com/martinVitanov "Martin Vitanov") <br />
[Georgi Eftimov](https://github.com/geftimov "Georgi Eftimov")

#### CHANGELOG

- June 6th. Add animation loop support.

##### Download

dependencies {
Expand Down
17 changes: 17 additions & 0 deletions androidplayer/src/main/java/com/eftimoff/androidplayer/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class Player {
private List<List<BaseAction>> list;
private PlayerStartListener playerStartListener;
private PlayerEndListener playerEndListener;
private int loopTime = -1;

final Handler handler = new Handler();

private Player() {
Expand All @@ -46,6 +48,15 @@ public Player then() {
return this;
}

/**
* Loop animation
* @param loopTime 0 if infinity loop
*/
public Player loop(int loopTime) {
this.loopTime = loopTime;
return this;
}

public void play() {
final View firstView = getFirstView();
if (firstView == null) {
Expand Down Expand Up @@ -104,6 +115,12 @@ public void run() {
if (playerEndListener != null) {
playerEndListener.onEnd();
}
if (loopTime > 0) {
--loopTime;
}
if (loopTime != 0) {
animateAll();
}
}
}, durationCounter);
}
Expand Down
13 changes: 12 additions & 1 deletion sample/src/main/java/com/eftimoff/empty/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {
// animateSampleTwo(toolbar, activityMainMobileNumberLayout, activityMainPinkFab, activityMainheaderLayout);
// animateSampleThree(toolbar, activityMainMobileNumberLayout, activityMainPinkFab, activityMainheaderLayout, activityMainMessageIcon);
// animateSampleFour(toolbar, activityMainMessageIcon, activityMainMobile, activityMainMobileNumber, activityMainCallIcon, activityMainPinkFab, activityMainheaderLayout);

//animateSampleFive(activityMainProfileName);
}


Expand Down Expand Up @@ -113,6 +113,17 @@ private void animateSampleFour(View toolbar, View activityMainMessageIcon, View
play();
}

private void animateSampleFive(View activityMainMessageIcon) {
final PropertyAction headerAction1 = PropertyAction.newPropertyAction(activityMainMessageIcon).scaleX(0.5f).scaleY(0.5f).duration(500).build();
final PropertyAction headerAction2 = PropertyAction.newPropertyAction(activityMainMessageIcon).scaleX(2).scaleY(2).duration(500).build();

Player.init().
animate(headerAction1).
then().
animate(headerAction2).
loop(5).
play();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand Down

0 comments on commit 7e865bc

Please sign in to comment.