Skip to content

Commit

Permalink
add new feature show ends tick texts only
Browse files Browse the repository at this point in the history
  • Loading branch information
warkiz committed Jun 16, 2018
1 parent 6a3801b commit 5d59b36
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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.0.7'
implementation 'com.github.warkiz.widget:indicatorseekbar:2.0.8'
```

## Usage
Expand Down Expand Up @@ -141,7 +141,7 @@ seekbar.setIndicatorTextFormat("I am ${TICK_TEXT}")
The color of every block of seek bar can also be custom.

```Java
sectionSeekBar.customSectionTrackColor(new ColorCollector() {
seekBar.customSectionTrackColor(new ColorCollector() {
@Override
public boolean collectSectionTrackColor(int[] colorIntArr) {
//the length of colorIntArray equals section count
Expand Down Expand Up @@ -188,7 +188,7 @@ TickMarks selector drawable:
```xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--this drawable is for tickMarks when pressing-->
<!--this drawable is for tickMarks those are at start side of thumb-->
<item android:drawable="@mipmap/ic_launcher_round" android:state_selected="true" />
<!--for tickMarks in normal-->
<item android:drawable="@mipmap/ic_launcher" />
Expand All @@ -200,7 +200,7 @@ TickMarks selector color:
```xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--this color is for marks those are at left side of thumb-->
<!--this color is for marks those are at start side of thumb-->
<item android:color="@color/colorAccent" android:state_selected="true" />
<!--for marks those are at right side of thumb-->
<item android:color="@color/color_gray" />
Expand All @@ -212,7 +212,7 @@ TickTexts selector color:
```xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--this color is for texts those are at left side of thumb-->
<!--this color is for texts those are at start side of thumb-->
<item android:color="@color/colorAccent" android:state_selected="true" />
<!--for tick text which is stopped under thumb -->
<item android:color="@color/color_blue" android:state_hovered="true" />
Expand Down
8 changes: 4 additions & 4 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
## 初始化

```gradle
implementation 'com.github.warkiz.widget:indicatorseekbar:2.0.7'
implementation 'com.github.warkiz.widget:indicatorseekbar:2.0.8'
```

## 使用
Expand Down Expand Up @@ -140,7 +140,7 @@ seekbar.setIndicatorTextFormat("I am ${TICK_TEXT}")
seekbar上每一块track的颜色都能被设置:

```Java
sectionSeekBar.customSectionTrackColor(new ColorCollector() {
seekBar.customSectionTrackColor(new ColorCollector() {
@Override
public boolean collectSectionTrackColor(int[] colorIntArr) {
//the length of colorIntArray equals section count
Expand Down Expand Up @@ -186,7 +186,7 @@ tick标记图片 selector:
```xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--this drawable is for tickMarks when pressing-->
<!--this drawable is for tickMarks those are at left side of thumb-->
<item android:drawable="@mipmap/ic_launcher_round" android:state_selected="true" />
<!--for tickMarks in normal-->
<item android:drawable="@mipmap/ic_launcher" />
Expand Down Expand Up @@ -223,7 +223,7 @@ tick文字颜色 selector:
```Java
seekBar.setOnSeekChangeListener(new OnSeekChangeListener() {
@Override
public void onSeeking(SeekParams seekParams) {
public void onSeeking(SeekParams p) {
Log.i(TAG, seekParams.seekBar);
Log.i(TAG, seekParams.progress);
Log.i(TAG, seekParams.progressFloat);
Expand Down
6 changes: 3 additions & 3 deletions 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.0.7"
def VERSION_NAME = "2.0.8"

ext {
bintrayRepo = 'maven'
Expand Down Expand Up @@ -49,5 +49,5 @@ dependencies {
}


apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
Expand Down Expand Up @@ -75,6 +76,7 @@ public class IndicatorSeekBar extends View {
private boolean mR2L;//right to left,compat local problem.
//tick texts
private boolean mShowTickText;//the palace where the tick text show .
private boolean mShowBothTickTextsOnly;//show the tick texts on the both ends of seek bar before.
private int mTickTextsHeight;//the height of text
private String[] mTickTextsArr;//save the tick texts which at tickMark position.
private float[] mTickTextsWidth;//save the tick texts width bounds.
Expand Down Expand Up @@ -559,6 +561,11 @@ private void drawTickTexts(Canvas canvas) {
}
float thumbPosFloat = getThumbPosOnTickFloat();
for (int i = 0; i < mTickTextsArr.length; i++) {
if (mShowBothTickTextsOnly) {
if (i != 0 && i != mTickTextsArr.length - 1) {
continue;
}
}
if (i == getThumbPosOnTick() && i == thumbPosFloat) {
mTextPaint.setColor(mHoveredTextColor);
} else if (i < thumbPosFloat) {
Expand Down Expand Up @@ -1935,6 +1942,14 @@ public void setOnSeekChangeListener(@NonNull OnSeekChangeListener listener) {
this.mSeekChangeListener = listener;
}

/**
* only show the tick texts on both of ends seek bar, make sure you hava called the attr:show tick text before.
*
* @param onlyShow true if only show the tick texts on both of ends seek bar
*/
public void showBothTickTextsOnly(boolean onlyShow) {
this.mShowBothTickTextsOnly = onlyShow;
}
/*------------------API END-------------------*/


Expand Down

0 comments on commit 5d59b36

Please sign in to comment.