-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from ogaclejapan/loop
Cancel processing and animation loop
- Loading branch information
Showing
16 changed files
with
238 additions
and
18 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
app/src/main/java/su/levenetc/android/textsurface/sample/checks/ShapeRevealLoopSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package su.levenetc.android.textsurface.sample.checks; | ||
|
||
import su.levenetc.android.textsurface.Text; | ||
import su.levenetc.android.textsurface.TextBuilder; | ||
import su.levenetc.android.textsurface.TextSurface; | ||
import su.levenetc.android.textsurface.animations.Alpha; | ||
import su.levenetc.android.textsurface.animations.AnimationsSet; | ||
import su.levenetc.android.textsurface.animations.Circle; | ||
import su.levenetc.android.textsurface.animations.Delay; | ||
import su.levenetc.android.textsurface.animations.Loop; | ||
import su.levenetc.android.textsurface.animations.Rotate3D; | ||
import su.levenetc.android.textsurface.animations.ShapeReveal; | ||
import su.levenetc.android.textsurface.animations.SideCut; | ||
import su.levenetc.android.textsurface.animations.Slide; | ||
import su.levenetc.android.textsurface.animations.TransSurface; | ||
import su.levenetc.android.textsurface.contants.Align; | ||
import su.levenetc.android.textsurface.contants.Axis; | ||
import su.levenetc.android.textsurface.contants.Direction; | ||
import su.levenetc.android.textsurface.contants.Pivot; | ||
import su.levenetc.android.textsurface.contants.Side; | ||
import su.levenetc.android.textsurface.contants.TYPE; | ||
|
||
/** | ||
* Created by Eugene Levenetc. | ||
*/ | ||
public class ShapeRevealLoopSample { | ||
public static void play(TextSurface textSurface) { | ||
|
||
Text textA = TextBuilder.create("Now why you loer en kyk gelyk?").setPosition(Align.SURFACE_CENTER).build(); | ||
Text textB = TextBuilder.create("Is ek miskien van goud gemake?").setPosition(Align.BOTTOM_OF | Align.CENTER_OF, textA).build(); | ||
Text textC = TextBuilder.create("You want to fight, you come tonight.").setPosition(Align.BOTTOM_OF | Align.CENTER_OF, textB).build(); | ||
Text textD = TextBuilder.create("Ek moer jou sleg! So jy hardloop weg.").setPosition(Align.BOTTOM_OF | Align.CENTER_OF, textC).build(); | ||
|
||
final int flash = 1500; | ||
|
||
textSurface.play( | ||
new Loop( | ||
Rotate3D.showFromCenter(textA, 500, Direction.CLOCK, Axis.X), | ||
new AnimationsSet(TYPE.PARALLEL, | ||
ShapeReveal.create(textA, flash, SideCut.hide(Side.LEFT), false), | ||
new AnimationsSet(TYPE.SEQUENTIAL, Delay.duration(flash / 4), ShapeReveal.create(textA, flash, SideCut.show(Side.LEFT), false)) | ||
), | ||
new AnimationsSet(TYPE.PARALLEL, | ||
Rotate3D.showFromSide(textB, 500, Pivot.TOP), | ||
new TransSurface(500, textB, Pivot.CENTER) | ||
), | ||
Delay.duration(500), | ||
new AnimationsSet(TYPE.PARALLEL, | ||
Slide.showFrom(Side.TOP, textC, 500), | ||
new TransSurface(1000, textC, Pivot.CENTER) | ||
), | ||
Delay.duration(500), | ||
new AnimationsSet(TYPE.PARALLEL, | ||
ShapeReveal.create(textD, 500, Circle.show(Side.CENTER, Direction.OUT), false), | ||
new TransSurface(1500, textD, Pivot.CENTER) | ||
), | ||
Delay.duration(500), | ||
new AnimationsSet(TYPE.PARALLEL, | ||
new AnimationsSet(TYPE.PARALLEL, Alpha.hide(textD, 700), ShapeReveal.create(textD, 1000, SideCut.hide(Side.LEFT), true)), | ||
new AnimationsSet(TYPE.SEQUENTIAL, Delay.duration(500), new AnimationsSet(TYPE.PARALLEL, Alpha.hide(textC, 700), ShapeReveal.create(textC, 1000, SideCut.hide(Side.LEFT), true))), | ||
new AnimationsSet(TYPE.SEQUENTIAL, Delay.duration(1000), new AnimationsSet(TYPE.PARALLEL, Alpha.hide(textB, 700), ShapeReveal.create(textB, 1000, SideCut.hide(Side.LEFT), true))), | ||
new AnimationsSet(TYPE.SEQUENTIAL, Delay.duration(1500), new AnimationsSet(TYPE.PARALLEL, Alpha.hide(textA, 700), ShapeReveal.create(textA, 1000, SideCut.hide(Side.LEFT), true))), | ||
new TransSurface(4000, textA, Pivot.CENTER) | ||
) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
library/src/main/java/su/levenetc/android/textsurface/animations/Loop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package su.levenetc.android.textsurface.animations; | ||
|
||
import su.levenetc.android.textsurface.interfaces.IEndListener; | ||
import su.levenetc.android.textsurface.interfaces.ISurfaceAnimation; | ||
|
||
/** | ||
* Created by ogaclejapan. | ||
*/ | ||
public class Loop extends Sequential { | ||
|
||
private final IEndListener restartListener = new IEndListener() { | ||
@Override public void onAnimationEnd(ISurfaceAnimation animation) { | ||
if (canceled) { | ||
if (endListener != null) endListener.onAnimationEnd(Loop.this); | ||
} else { | ||
Loop.super.start(restartListener); | ||
} | ||
} | ||
}; | ||
|
||
private IEndListener endListener; | ||
private boolean canceled; | ||
|
||
public Loop(ISurfaceAnimation... animations) { | ||
super(animations); | ||
} | ||
|
||
@Override public void start(IEndListener listener) { | ||
endListener = listener; | ||
canceled = false; | ||
super.start(restartListener); | ||
} | ||
|
||
@Override public void cancel() { | ||
canceled = true; | ||
super.cancel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.