Skip to content

Commit

Permalink
Added reset feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmuvi committed Jun 23, 2017
1 parent a7f86ec commit a71175d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
8 changes: 8 additions & 0 deletions app/src/main/java/com/carlosmuvi/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class MainActivity extends AppCompatActivity {
SegmentedProgressBar segmentedProgressBar;
Button startButton;
Button pauseButton;
Button resetButton;

@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -20,6 +21,7 @@ public class MainActivity extends AppCompatActivity {

startButton = (Button) findViewById(R.id.button);
pauseButton = (Button) findViewById(R.id.button3);
resetButton = (Button) findViewById(R.id.button2);

startButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
Expand All @@ -32,6 +34,12 @@ public class MainActivity extends AppCompatActivity {
segmentedProgressBar.pause();
}
});

resetButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
segmentedProgressBar.reset();
}
});
}

private void initSegmentedProgressBar() {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,14 @@
android:text="Start next segment"
/>

<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Reset"
android:layout_below="@+id/button3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>

</RelativeLayout>
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ POM_NAME=SegmentedProgressBar Library
POM_ARTIFACT_ID=library
POM_PACKAGING=aar

VERSION_NAME=0.1
VERSION_CODE=1
VERSION_NAME=0.4
VERSION_CODE=4
GROUP=com.carlosmuvi.segmentedprogressbar

POM_DESCRIPTION=Instagram like segmented progress bar for Android.
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
versionCode 4
versionName "0.4"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,17 @@ class SegmentedProgressBar : View {

fun setCompletedSegments(completedSegments: Int) {
if (completedSegments <= properties.segmentCount) {
currentSegmentProgressInPx = 0
drawingTimer.reset()
lastCompletedSegment = completedSegments
invalidate()
}
}

fun reset() {
setCompletedSegments(0)
}

/*
PRIVATE METHODS
*/
Expand Down

0 comments on commit a71175d

Please sign in to comment.