To implement the progress view, implement the StoriesProgressView.StoriesListener interface in your Activity. You must initialize the view with the number of stories and the duration per story, then call startStories().
Important: You must call storiesProgressView.destroy() in onDestroy() to prevent memory leaks.
public class YourActivity extends AppCompatActivity implements StoriesProgressView.StoriesListener {
private StoriesProgressView storiesProgressView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
storiesProgressView = (StoriesProgressView) findViewById(R.id.stories);
storiesProgressView.setStoriesCount(PROGRESS_COUNT); // set number of stories
storiesProgressView.setStoryDuration(1200L); // set duration in milliseconds
storiesProgressView.setStoriesListener(this);
storiesProgressView.startStories();
}
@Override
public void onNext() {
// Called when moving to the next story
}
@Override
public void onPrev() {
// Called when finished reverse animation
}
@Override
public void onComplete() {
// Called when all stories are finished
}
@Override
protected void onDestroy() {
// Very important!
storiesProgressView.destroy();
super.onDestroy();
}
}