Skip to content

Commit 26bac58

Browse files
committed
[TimePicker] Make the dial selector discrete
1 parent 86eddaa commit 26bac58

4 files changed

Lines changed: 250 additions & 144 deletions

File tree

lib/java/com/google/android/material/timepicker/ClockFaceView.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class ClockFaceView extends RadialViewGroup implements OnRotateListener {
9191

9292
private String[] values;
9393

94-
private float currentHandRotation;
94+
private float currentHandDegrees;
95+
private float currentHandLevel;
9596

9697
private final ColorStateList textColor;
9798

@@ -366,11 +367,14 @@ private RadialGradient getGradientForTextView(RectF selectorBox, TextView tv) {
366367
}
367368

368369
@Override
369-
public void onRotate(float rotation, boolean animating) {
370-
if (abs(currentHandRotation - rotation) > EPSILON) {
371-
currentHandRotation = rotation;
372-
findIntersectingTextView();
370+
public void onRotate(float degrees, int level, boolean animating) {
371+
if (currentHandDegrees == degrees && currentHandLevel == level) {
372+
return;
373373
}
374+
375+
currentHandDegrees = degrees;
376+
currentHandLevel = level;
377+
findIntersectingTextView();
374378
}
375379

376380
@Override

0 commit comments

Comments
 (0)