Skip to content

Commit

Permalink
[Slider] Fix compat halo visibility
Browse files Browse the repository at this point in the history
Resolves #2951

GIT_ORIGIN_REV_ID=f3cd8ddc7a7b1fee6fac9378515ce3668fcc6b70
PiperOrigin-RevId: 472846843
  • Loading branch information
pubiqq authored and afohrman committed Sep 8, 2022
1 parent fbd75ec commit bcb551b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/java/com/google/android/material/slider/BaseSlider.java
Expand Up @@ -1721,14 +1721,13 @@ protected void onDraw(@NonNull Canvas canvas) {

maybeDrawTicks(canvas);

if ((thumbIsPressed || isFocused() || shouldAlwaysShowLabel()) && isEnabled()) {
maybeDrawHalo(canvas, trackWidth, yCenter);
// Draw labels if there is an active thumb or the labels are always visible.
if (activeThumbIdx != -1 || shouldAlwaysShowLabel()) {
ensureLabelsAdded();
} else {
ensureLabelsRemoved();
}
if ((thumbIsPressed || isFocused()) && isEnabled()) {
maybeDrawCompatHalo(canvas, trackWidth, yCenter);
}

// Draw labels if there is an active thumb or the labels are always visible.
if ((activeThumbIdx != -1 || shouldAlwaysShowLabel()) && isEnabled()) {
ensureLabelsAdded();
} else {
ensureLabelsRemoved();
}
Expand Down Expand Up @@ -1841,7 +1840,7 @@ private void drawThumbDrawable(
canvas.restore();
}

private void maybeDrawHalo(@NonNull Canvas canvas, int width, int top) {
private void maybeDrawCompatHalo(@NonNull Canvas canvas, int width, int top) {
// Only draw the halo for devices that aren't using the ripple.
if (shouldDrawCompatHalo()) {
int centerX = (int) (trackSidePadding + normalizeValue(values.get(focusedThumbIdx)) * width);
Expand Down

0 comments on commit bcb551b

Please sign in to comment.