Skip to content

Commit 803669f

Browse files
committed
patch 2
1 parent d4290db commit 803669f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/java/com/google/android/material/slider/BaseSlider.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,9 @@ private void processAttributes(Context context, AttributeSet attrs, int defStyle
477477
? haloColor
478478
: AppCompatResources.getColorStateList(context, R.color.material_slider_halo_color));
479479

480-
if (a.hasValue(R.styleable.Slider_tickVisibilityMode)) {
481-
this.tickVisibilityMode = a.getInt(R.styleable.Slider_tickVisibilityMode, -1);
482-
} else {
483-
this.tickVisibilityMode = a.getBoolean(R.styleable.Slider_tickVisible, true)
484-
? TICK_VISIBILITY_AUTO_LIMIT
485-
: TICK_VISIBILITY_HIDDEN;
486-
}
480+
tickVisibilityMode = a.hasValue(R.styleable.Slider_tickVisibilityMode)
481+
? a.getInt(R.styleable.Slider_tickVisibilityMode, -1)
482+
: convertToTickVisibilityMode(a.getBoolean(R.styleable.Slider_tickVisible, true));
487483

488484
boolean hasTickColor = a.hasValue(R.styleable.Slider_tickColor);
489485
int tickColorInactiveRes =
@@ -1489,9 +1485,8 @@ public void setTickInactiveTintList(@NonNull ColorStateList tickColor) {
14891485
* Returns whether the tick marks are visible. Only used when the slider is in discrete mode.
14901486
*
14911487
* @attr ref com.google.android.material.R.styleable#Slider_tickVisible
1492-
* @deprecated Use {@link BaseSlider#getTickVisibilityMode()} to get the current
1493-
* tick visibility mode or {@link BaseSlider#areTicksDrawn()} to get whether the ticks
1494-
* are currently drawn.
1488+
* @deprecated Use {@link #getTickVisibilityMode()} to get the current tick visibility mode
1489+
* or {@link #areTicksDrawn()} to get whether the ticks are currently drawn.
14951490
*/
14961491
@Deprecated
14971492
public boolean isTickVisible() {
@@ -1517,11 +1512,18 @@ public boolean areTicksDrawn() {
15171512
*
15181513
* @param tickVisible The visibility of tick marks.
15191514
* @attr ref com.google.android.material.R.styleable#Slider_tickVisible
1520-
* @deprecated Use {@link BaseSlider#setTickVisibilityMode(int)} instead.
1515+
* @deprecated Use {@link #setTickVisibilityMode(int)} instead.
15211516
*/
15221517
@Deprecated
15231518
public void setTickVisible(boolean tickVisible) {
1524-
setTickVisibilityMode(tickVisible ? TICK_VISIBILITY_AUTO_LIMIT : TICK_VISIBILITY_HIDDEN);
1519+
setTickVisibilityMode(convertToTickVisibilityMode(tickVisible));
1520+
}
1521+
1522+
@TickVisibilityMode
1523+
private int convertToTickVisibilityMode(boolean tickVisible) {
1524+
return tickVisible
1525+
? TICK_VISIBILITY_AUTO_LIMIT
1526+
: TICK_VISIBILITY_HIDDEN;
15251527
}
15261528

15271529
/**

0 commit comments

Comments
 (0)