Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "fill finished" status #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,20 @@ public void setToFinishedFrame() {

if (hasToKeepDrawing(elapsedTime)) {
ViewCompat.postInvalidateOnAnimation(this);
checkState();
} else {
changeState(State.FINISHED);
}
}

private void checkState() {
if (drawingState != State.FILL_FINISHED
&& percentageEnabled
&& previousFramePercentage >= percentage) {
changeState(State.FILL_FINISHED);
}
}

private void drawStroke(Canvas canvas, long elapsedTime) {
float phase = MathUtil.constrain(0, 1, elapsedTime * 1f / strokeDrawingDuration);
float distance = animInterpolator.getInterpolation(phase) * pathData.length;
Expand Down Expand Up @@ -356,7 +365,9 @@ public void setPercentage(float percentage) {
} else if (drawingState == State.STROKE_STARTED) {
this.percentageEnabled = true;
this.percentage = percentage;
} else if (drawingState == State.FILL_STARTED) {
} else if (drawingState == State.FILL_STARTED || drawingState == State.FILL_FINISHED) {
drawingState = State.FILL_STARTED;

if (percentageEnabled) {
this.percentage = percentage;
} else {
Expand Down
1 change: 1 addition & 0 deletions library/src/main/java/com/github/jorgecastillo/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public class State {
public static final int STROKE_STARTED = 1;
public static final int FILL_STARTED = 2;
public static final int FINISHED = 3;
public static final int FILL_FINISHED = 4;
}