Skip to content
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;
}