Skip to content
Draft
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 @@ -5,6 +5,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
Expand Down Expand Up @@ -95,11 +96,18 @@ private void finishProgress(boolean isMax) {
}
}

public void startProgress() {
public void startProgress(long startTime) {
maxProgressView.setVisibility(GONE);

animation = new PausableScaleAnimation(0, 1, 1, 1, Animation.ABSOLUTE, 0, Animation.RELATIVE_TO_SELF, 0);
animation.setDuration(duration);
long remainingTime = duration - startTime;
if(remainingTime < 0) {
throw new IllegalArgumentException("Start time is greater than story duration");
}
float fromX = 1.0f - ((float)remainingTime/(float)duration);

animation = new PausableScaleAnimation(fromX, 1, 1, 1, Animation.ABSOLUTE, 0, Animation.RELATIVE_TO_SELF, 0);
animation.setDuration(remainingTime);

animation.setInterpolator(new LinearInterpolator());
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,17 @@ public void onFinishProgress() {
if (0 <= (current - 1)) {
PausableProgressBar p = progressBars.get(current - 1);
p.setMinWithoutCallback();
progressBars.get(--current).startProgress();
progressBars.get(--current).startProgress(0);
} else {
progressBars.get(current).startProgress();
progressBars.get(current).startProgress(0);
}
isReverseStart = false;
return;
}
int next = current + 1;
if (next <= (progressBars.size() - 1)) {
if (storiesListener != null) storiesListener.onNext();
progressBars.get(next).startProgress();
progressBars.get(next).startProgress(0);
} else {
isComplete = true;
if (storiesListener != null) storiesListener.onComplete();
Expand All @@ -202,17 +202,21 @@ public void onFinishProgress() {
* Start progress animation
*/
public void startStories() {
progressBars.get(0).startProgress();
progressBars.get(0).startProgress(0);
}

/**
* Start progress animation from specific progress
*/
public void startStories(int from) {
startStories(from, 0);
}

public void startStories(int from, long startTime) {
for (int i = 0; i < from; i++) {
progressBars.get(i).setMaxWithoutCallback();
}
progressBars.get(from).startProgress();
progressBars.get(from).startProgress(startTime);
}

/**
Expand Down