Skip to content

Commit

Permalink
Added additional boolean param to color ticks on thumb right with tra…
Browse files Browse the repository at this point in the history
…ck background color.
  • Loading branch information
edgar-v committed May 30, 2018
1 parent 03e1134 commit 54c8879
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DiscreteFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.discrete, container, false);
final TextView progressTv = (TextView) root.findViewById(R.id.discrete_progress);
final TextView postionTv = (TextView) root.findViewById(R.id.discrete_pos);
final TextView positionTv = (TextView) root.findViewById(R.id.discrete_pos);
final TextView textTv = (TextView) root.findViewById(R.id.discrete_text);
IndicatorSeekBar discrete = (IndicatorSeekBar) root.findViewById(R.id.discrete);

Expand All @@ -33,7 +33,7 @@ public void onProgressChanged(IndicatorSeekBar seekBar, int progress, float prog

@Override
public void onSectionChanged(IndicatorSeekBar seekBar, int thumbPosOnTick, String tickBelowText, boolean fromUserTouch) {
postionTv.setText("thumbPosOnTick: " + thumbPosOnTick);
positionTv.setText("thumbPosOnTick: " + thumbPosOnTick);
textTv.setText("tickBelowText: " + tickBelowText);
}

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/discrete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@
app:isb_tick_num="7"
app:isb_tick_type="oval" />

<TextView
style="@style/subtitle_text_style"
android:text="2.1. isb_tick_on_thumb_right_color_as_track_background = true" />

<com.warkiz.widget.IndicatorSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:isb_indicator_stay="true"
app:isb_progress="68"
app:isb_seek_bar_type="discrete_ticks_texts"
app:isb_show_indicator="true"
app:isb_tick_num="7"
app:isb_tick_type="oval"
app:isb_tick_on_thumb_right_color_as_track_background="true"/>

<TextView
style="@style/subtitle_text_style"
android:text="3. custom thumb drawable; change tick color; change tick size" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BuilderParams {
int mTickColor = Color.parseColor("#FF4081");
boolean mTickHideBothEnds = false;
boolean mTickOnThumbLeftHide = false;
boolean mTickOnThumbRightColorTrackBackground = false;
Drawable mTickDrawable = null;
//text
int mTextSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ private void initAttrs(Context context, AttributeSet attrs) {
p.mTickType = ta.getInt(R.styleable.IndicatorSeekBar_isb_tick_type, p.mTickType);
p.mTickHideBothEnds = ta.getBoolean(R.styleable.IndicatorSeekBar_isb_tick_both_end_hide, p.mTickHideBothEnds);
p.mTickOnThumbLeftHide = ta.getBoolean(R.styleable.IndicatorSeekBar_isb_tick_on_thumb_left_hide, p.mTickOnThumbLeftHide);
p.mTickOnThumbRightColorTrackBackground = ta.getBoolean(R.styleable.IndicatorSeekBar_isb_tick_on_thumb_right_color_as_track_background,
p.mTickOnThumbRightColorTrackBackground);
p.mTickSize = ta.getDimensionPixelSize(R.styleable.IndicatorSeekBar_isb_tick_size, p.mTickSize);
//text
p.mTextArray = ta.getTextArray(R.styleable.IndicatorSeekBar_isb_text_array);
Expand Down Expand Up @@ -531,6 +533,9 @@ private void drawTicks(Canvas canvas, float thumbX) {
canvas.drawBitmap(mTickDraw, locationX - mTickDraw.getWidth() / 2.0f, mTrackY - mTickDraw.getHeight() / 2.0f, mStockPaint);
}
} else {
if (thumbX <= locationX && p.mTickOnThumbRightColorTrackBackground) {
mStockPaint.setColor(p.mBackgroundTrackColor);
}
if (p.mTickType == TickType.OVAL) {
canvas.drawCircle(locationX, mTrackY, mTickRadius, mStockPaint);
} else if (p.mTickType == TickType.REC) {
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 @@ -48,6 +48,7 @@
<attr name="isb_tick_size" format="dimension|reference" /><!--set the tick width, default 10dp,custom drawable will be limited in 30dp, if less than 30dp ,will show in raw size-->
<attr name="isb_tick_both_end_hide" format="boolean" /><!--hide 2 ticks on the seekBar's both ends, default false-->
<attr name="isb_tick_on_thumb_left_hide" format="boolean" /><!--hide the ticks on the seekBar's thumb left, default false-->
<attr name="isb_tick_on_thumb_right_color_as_track_background" format="boolean" /><!--set the ticks' color on the seekBar's thumb right to isb_track_background_bar_color, default false-->
<attr name="isb_tick_type"><!--select the tick shape type, default rectangle/1-->
<enum name="none" value="0" />
<enum name="rec" value="1" />
Expand Down

0 comments on commit 54c8879

Please sign in to comment.