Skip to content

Commit

Permalink
[Slider] Fix NPE when trying to remove labels when ViewOverlay doesn'…
Browse files Browse the repository at this point in the history
…t exist yet

Resolves #2845

PiperOrigin-RevId: 462418275
(cherry picked from commit 4122837)
  • Loading branch information
drchen committed Aug 4, 2022
1 parent 1666fbc commit 95e585c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/java/com/google/android/material/slider/BaseSlider.java
Expand Up @@ -1583,6 +1583,9 @@ protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
// according to the setting.
if (visibility != VISIBLE) {
ViewOverlayImpl contentViewOverlay = ViewUtils.getContentViewOverlay(this);
if (contentViewOverlay == null) {
return;
}
for (TooltipDrawable label : labels) {
contentViewOverlay.remove(label);
}
Expand Down Expand Up @@ -2372,6 +2375,7 @@ public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
return super.onKeyDown(keyCode, event);
}

@Nullable
private Boolean onKeyDownNoActiveThumb(int keyCode, @NonNull KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_TAB:
Expand Down Expand Up @@ -2459,6 +2463,7 @@ private boolean moveFocusInAbsoluteDirection(int direction) {
return moveFocus(direction);
}

@Nullable
private Float calculateIncrementForKey(int keyCode) {
// If this is a long press, increase the increment so it will only take around 20 steps.
// Otherwise choose the smallest valid increment.
Expand Down

0 comments on commit 95e585c

Please sign in to comment.