Skip to content

Commit

Permalink
accept similar advise warkiz#94 warkiz#104
Browse files Browse the repository at this point in the history
  • Loading branch information
warkiz committed Sep 2, 2018
1 parent ad8b4e5 commit 0be6122
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/res/layout/discrete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@

<TextView
style="@style/subtitle_text_style"
android:text="9. tick_marks_color=@color/selector_tick_marks_color" />
android:text="9. tick_marks_color=@color/selector_tick_marks_color,thumb_adjust_auto=false" />

<com.warkiz.widget.IndicatorSeekBar
android:layout_width="match_parent"
Expand All @@ -161,6 +161,7 @@
app:isb_show_indicator="rectangle"
app:isb_show_tick_marks_type="square"
app:isb_show_tick_texts="true"
app:isb_thumb_adjust_auto="false"
app:isb_tick_marks_color="@color/selector_tick_marks_color"
app:isb_ticks_count="5"
app:isb_track_progress_color="@color/color_blue"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public class IndicatorSeekBar extends View {
private float mThumbTextY;//the thumb text's drawing Y anchor
private int mThumbTextColor;
private boolean mHideThumb;
private boolean mAdjustAuto;

public IndicatorSeekBar(Context context) {
this(context, null);
Expand Down Expand Up @@ -196,6 +197,7 @@ private void initAttrs(Context context, AttributeSet attrs) {
//thumb
mThumbSize = ta.getDimensionPixelSize(R.styleable.IndicatorSeekBar_isb_thumb_size, builder.thumbSize);
mThumbDrawable = ta.getDrawable(R.styleable.IndicatorSeekBar_isb_thumb_drawable);
mAdjustAuto = ta.getBoolean(R.styleable.IndicatorSeekBar_isb_thumb_adjust_auto,true);
initThumbColor(ta.getColorStateList(R.styleable.IndicatorSeekBar_isb_thumb_color), builder.thumbColor);
//thumb text
mShowThumbText = ta.getBoolean(R.styleable.IndicatorSeekBar_isb_show_thumb_text, builder.showThumbText);
Expand Down Expand Up @@ -1372,6 +1374,9 @@ private boolean autoAdjustThumb() {
if (mTicksCount < 3 || !mSeekSmoothly) {//it is not necessary to adjust while count less than 3 .
return false;
}
if (!mAdjustAuto){
return false;
}
final int closestIndex = getClosestIndex();
final float touchUpProgress = mProgress;
ValueAnimator animator = ValueAnimator.ofFloat(0, Math.abs(touchUpProgress - mProgressArr[closestIndex]));
Expand Down Expand Up @@ -1979,6 +1984,16 @@ public synchronized void setTickCount(int tickCount) {
updateStayIndicator();
}

/**
* Sets the thumb move to the closed tick after touched up automatically, default true
*
* @param adjustAuto true if auto move after touched up.
*/
public void setThumbAdjustAuto(boolean adjustAuto) {
mAdjustAuto = adjustAuto;
}


/*------------------API END-------------------*/


Expand Down
1 change: 1 addition & 0 deletions indicatorseekbar/src/main/res/values/attr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<attr name="isb_thumb_size" format="dimension|reference" /><!--set thumb's size, default 14dp, thumb size will be limited in 30dp-->
<attr name="isb_thumb_color" format="color|reference" /><!--set thumb's color, default #FF4081-->
<attr name="isb_thumb_drawable" format="reference" /><!--set custom thumb's drawable you want,thumb size will be limited in 30dp, if drawable less than 30dp ,will show in intrinsic size -->
<attr name="isb_thumb_adjust_auto" format="boolean" /><!--set the thumb move to the closed tick after touched up, default true-->
//tickMarks
<attr name="isb_tick_marks_color" format="color|reference" /><!--set tick's color, default #FF4081-->
<attr name="isb_tick_marks_size" format="dimension|reference" /><!--set the tick width, default 10dp,custom drawable will be limited in 30dp, if less than 30dp ,will show in intrinsic size-->
Expand Down

0 comments on commit 0be6122

Please sign in to comment.