Skip to content

Commit

Permalink
✈️ supply set prgress range mapped and publish [0.2.3]
Browse files Browse the repository at this point in the history
  • Loading branch information
dtboy1995 committed Jul 30, 2018
1 parent d8193e2 commit 7cdf734
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
- add to your module gradle file

```gradle
implementation 'com.github.dtboy1995:android-sex-ring:0.2.2'
implementation 'com.github.dtboy1995:android-sex-ring:0.2.3'
```

# screenshot
Expand Down Expand Up @@ -54,20 +54,22 @@ implementation 'com.github.dtboy1995:android-sex-ring:0.2.2'
RingView rv = (RingView)findViewById(R.id.ring_view);
// set progress - true is animated
rv.go(20, true);
// set prgress range mapped
rv.go(10, -20, 30, true);
// set progress callback
rv.setCallback(new AVCallback() {
// progress 0~100
@Override
public void step(int progress) {
// progress 0~100
tv.setText(String.valueOf(progress));

}
});
// set range mapped progress callback [0, 100] map to => [-20, 30]
rv.setCallback(new AVRangeMapCallback(-20, 30) {
// progress -20~30
@Override
public void step(int progress) {
// progress -20~30
tv.setText(String.valueOf(progress));

}
});
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public void go2(View v) {
ring2.go(30, true);
}

public void goRangeMapped(View v) {
ring1.go(-20, -20, 30, true);
}

public void step1(int progress) {
tv1.setText(String.valueOf(progress));
}
Expand Down
18 changes: 14 additions & 4 deletions example/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,22 @@
<Button
android:onClick="go1"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="GO"
android:textColor="#646464"
android:textSize="20sp" />
android:textSize="17sp" />

<Button
android:onClick="goRangeMapped"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="GO Range Mapped"
android:textColor="#646464"
android:textSize="17sp" />

<RelativeLayout
android:layout_width="150dp"
Expand Down Expand Up @@ -108,10 +118,10 @@
<Button
android:onClick="go2"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="GO"
android:textColor="#646464"
android:textSize="20sp" />
android:textSize="17sp" />
</LinearLayout>
4 changes: 2 additions & 2 deletions ring/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 3
versionName "0.2.2"
versionCode 4
versionName "0.2.3"
}

buildTypes {
Expand Down
10 changes: 10 additions & 0 deletions ring/src/main/java/org/ithot/android/view/RingView.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,16 @@ public void go(int progress) {
go(progress, false);
}

public void go(int progress, int min, int max) {
float unit = (max - min) / MAX_PROGRESS;
go((int) ((progress - min) / unit));
}

public void go(int progress, int min, int max, boolean animate) {
float unit = (max - min) / MAX_PROGRESS;
go((int) ((progress - min) / unit), true);
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Expand Down

0 comments on commit 7cdf734

Please # to comment.