Skip to content

Commit

Permalink
update to v2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
warkiz committed Dec 9, 2018
1 parent 88b6f96 commit f4bcf20
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This is a customizable SeekBar library on Android. Also, If you don't need indic
## Setup

```gradle
implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.0'
implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.1'
```

## Usage
Expand Down Expand Up @@ -149,12 +149,18 @@ If you want to show the progress with suffix: `%` ,the code like:

```Java
seekBar.setIndicatorTextFormat("${PROGRESS} %")

Kotlin:
seekBar.setIndicatorTextFormat("\${PROGRESS} %")
```

or want to show the tick text with prefix: `I am` ,the code like:

```Java
seekBar.setIndicatorTextFormat("I am ${TICK_TEXT}")

Kotlin:
seekBar.setIndicatorTextFormat("I am \${TICK_TEXT}")
```

## Custom section tracks color
Expand Down
8 changes: 7 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
## 初始化

```gradle
implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.0'
implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.1'
```

## 使用
Expand Down Expand Up @@ -133,12 +133,18 @@ new IndicatorStayLayout(getContext()).attachTo(seekbar);

```Java
seekbar.setIndicatorTextFormat("${PROGRESS} %")

Kotlin:
seekbar.setIndicatorTextFormat("\${PROGRESS} %")
```

如果你想显示带前缀 `I am`的指示器tick text文字 ,代码如下:

```Java
seekbar.setIndicatorTextFormat("I am ${TICK_TEXT}")

Kotlin:
seekbar.setIndicatorTextFormat("I am \${TICK_TEXT}")
```

## 自定义每一节的track块颜色
Expand Down
Binary file modified apk/demo.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion indicatorseekbar/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'

def VERSION_NAME = "2.1.0"
def VERSION_NAME = "2.1.1"

ext {
bintrayRepo = 'maven'
Expand Down
31 changes: 11 additions & 20 deletions indicatorseekbar/src/main/java/com/warkiz/widget/FormatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,18 @@
class FormatUtils {

private final static char[][] LEADING_DECIMALS = new char[][]{
"0.".toCharArray(), "0.0".toCharArray(),
"0.00".toCharArray(), "0.000".toCharArray(), "0.0000".toCharArray(),
"0.00000".toCharArray(),
"0.000000".toCharArray(), "0.0000000".toCharArray(), "0.00000000".toCharArray(),
"0.000000000".toCharArray(), "0.0000000000".toCharArray(), "0.00000000000".toCharArray(),
"0.000000000000".toCharArray(), "0.0000000000000".toCharArray(),
"0.00000000000000".toCharArray(),
"0.000000000000000".toCharArray()
"0.".toCharArray(), "0.0".toCharArray(),
"0.00".toCharArray(), "0.000".toCharArray(), "0.0000".toCharArray(),
"0.00000".toCharArray(),
"0.000000".toCharArray(), "0.0000000".toCharArray(), "0.00000000".toCharArray(),
"0.000000000".toCharArray(), "0.0000000000".toCharArray(), "0.00000000000".toCharArray(),
"0.000000000000".toCharArray(), "0.0000000000000".toCharArray(),
"0.00000000000000".toCharArray(),
"0.000000000000000".toCharArray()
};

/**
* 快速格式化一个double,尾零去除(非对齐)<br>
* 等同于:<br>
* NumberFormat f = NumberFormat.getNumberInstance();<br>
* f.setGroupingUsed(false);<br>
* f.setMaximumFractionDigits(precision);<br>
* f.format(d);<br>
* 但一般情况效率高于NumberFormat一倍,且精度无丢失。<br>
*
* @param d the double value
* @param precision [0,16]
* format a double value quickly, will remove the suffix:0
*/
static String fastFormat(double d, int precision) {
int posPrecision = Math.abs(precision);
Expand All @@ -56,7 +47,7 @@ static String fastFormat(double d, int precision) {
System.arraycopy(longPartChars, 0, formatChars, 0, decIndex);
formatChars[decIndex] = '.';
System.arraycopy(longPartChars, decIndex, formatChars,
decIndex + 1, end - decIndex + 1);
decIndex + 1, end - decIndex + 1);
} else {
formatChars = new char[decIndex];
System.arraycopy(longPartChars, 0, formatChars, 0, decIndex);
Expand All @@ -75,7 +66,7 @@ static String fastFormat(double d, int precision) {

private static String bigDecFormat(double d, int precision) {
String formatStr = new BigDecimal(Double.toString(d)).setScale(Math.abs(precision), RoundingMode.HALF_UP)
.toString();
.toString();
if (precision == 0) {
return formatStr;
}
Expand Down

0 comments on commit f4bcf20

Please sign in to comment.