Skip to content

Commit 95e585c

Browse files
committed
[Slider] Fix NPE when trying to remove labels when ViewOverlay doesn't exist yet
Resolves #2845 PiperOrigin-RevId: 462418275 (cherry picked from commit 4122837)
1 parent 1666fbc commit 95e585c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,9 @@ protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
15831583
// according to the setting.
15841584
if (visibility != VISIBLE) {
15851585
ViewOverlayImpl contentViewOverlay = ViewUtils.getContentViewOverlay(this);
1586+
if (contentViewOverlay == null) {
1587+
return;
1588+
}
15861589
for (TooltipDrawable label : labels) {
15871590
contentViewOverlay.remove(label);
15881591
}
@@ -2372,6 +2375,7 @@ public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
23722375
return super.onKeyDown(keyCode, event);
23732376
}
23742377

2378+
@Nullable
23752379
private Boolean onKeyDownNoActiveThumb(int keyCode, @NonNull KeyEvent event) {
23762380
switch (keyCode) {
23772381
case KeyEvent.KEYCODE_TAB:
@@ -2459,6 +2463,7 @@ private boolean moveFocusInAbsoluteDirection(int direction) {
24592463
return moveFocus(direction);
24602464
}
24612465

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

0 commit comments

Comments
 (0)