@@ -2357,19 +2357,12 @@ public boolean onTouchEvent(@NonNull MotionEvent event) {
2357
2357
2358
2358
requestFocus ();
2359
2359
thumbIsPressed = true ;
2360
+ updateThumbWidthWhenPressed ();
2361
+ onStartTrackingTouch ();
2362
+
2360
2363
snapTouchPosition ();
2361
2364
updateHaloHotspot ();
2362
- // Update the thumb width when pressed.
2363
- if (hasGapBetweenThumbAndTrack ()) {
2364
- defaultThumbWidth = thumbWidth ;
2365
- defaultThumbTrackGapSize = thumbTrackGapSize ;
2366
- int pressedThumbWidth = Math .round (thumbWidth * THUMB_WIDTH_PRESSED_RATIO );
2367
- int delta = thumbWidth - pressedThumbWidth ;
2368
- setThumbWidth (pressedThumbWidth );
2369
- setThumbTrackGapSize (thumbTrackGapSize - delta / 2 );
2370
- }
2371
2365
invalidate ();
2372
- onStartTrackingTouch ();
2373
2366
break ;
2374
2367
case MotionEvent .ACTION_MOVE :
2375
2368
if (!thumbIsPressed ) {
@@ -2378,15 +2371,17 @@ public boolean onTouchEvent(@NonNull MotionEvent event) {
2378
2371
return false ;
2379
2372
}
2380
2373
getParent ().requestDisallowInterceptTouchEvent (true );
2381
- onStartTrackingTouch ();
2382
- }
2383
2374
2384
- if (!pickActiveThumb ()) {
2385
- // Couldn't determine the active thumb yet.
2386
- break ;
2375
+ if (!pickActiveThumb ()) {
2376
+ // Couldn't determine the active thumb yet.
2377
+ break ;
2378
+ }
2379
+
2380
+ thumbIsPressed = true ;
2381
+ updateThumbWidthWhenPressed ();
2382
+ onStartTrackingTouch ();
2387
2383
}
2388
2384
2389
- thumbIsPressed = true ;
2390
2385
snapTouchPosition ();
2391
2386
updateHaloHotspot ();
2392
2387
invalidate ();
@@ -2430,6 +2425,18 @@ && abs(lastEvent.getY() - event.getY()) <= scaledTouchSlop) {
2430
2425
return true ;
2431
2426
}
2432
2427
2428
+ private void updateThumbWidthWhenPressed () {
2429
+ // Update thumb width and track gap size when pressed.
2430
+ if (hasGapBetweenThumbAndTrack ()) {
2431
+ defaultThumbWidth = thumbWidth ;
2432
+ defaultThumbTrackGapSize = thumbTrackGapSize ;
2433
+ int pressedThumbWidth = Math .round (thumbWidth * THUMB_WIDTH_PRESSED_RATIO );
2434
+ int delta = thumbWidth - pressedThumbWidth ;
2435
+ setThumbWidth (pressedThumbWidth );
2436
+ setThumbTrackGapSize (thumbTrackGapSize - delta / 2 );
2437
+ }
2438
+ }
2439
+
2433
2440
private double snapPosition (float position ) {
2434
2441
if (stepSize > 0.0f ) {
2435
2442
int stepCount = (int ) ((valueTo - valueFrom ) / stepSize );
0 commit comments