StoriesProgressView
show horizontal progress like instagram stories.
How to Use
To see how the StoriesProgressView are added to your xml layouts, check the sample project.
<jp.shts.android.storiesprogressview.StoriesProgressView
android:id="@+id/stories"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_gravity="top"
android:layout_marginTop="8dp" />
Overview
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 stories
storiesProgressView.setStoryDuration(1200L); // <- set a story duration
storiesProgressView.setStoriesListener(this); // <- set listener
storiesProgressView.startStories(); // <- start progress
}
@Override
public void onNext() {
Toast.makeText(this, "onNext", Toast.LENGTH_SHORT).show();
}
@Override
public void onPrev() {
// Call when finished revserse animation.
Toast.makeText(this, "onPrev", Toast.LENGTH_SHORT).show();
}
@Override
public void onComplete() {
Toast.makeText(this, "onComplete", Toast.LENGTH_SHORT).show();
}
@Override
protected void onDestroy() {
// Very important !
storiesProgressView.destroy();
super.onDestroy();
}
}
Skip and Reverse story
storiesProgressView.skip();
storiesProgressView.reverse();
Pause and Resume story
storiesProgressView.pause();
storiesProgressView.resume();
Install
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Add the dependency
dependencies {
compile 'com.github.shts:StoriesProgressView:2.0.0'
}