Fix auto-advance regression in radial time picker

If autoAdvance is set, we need to always fire the listener. We should
create a separate callback for auto-advance, but this is a minimal fix.

BUG: 18654878
Change-Id: Ie7b8a3ff91761325a508f580b27fa3b08f7b4e16
This commit is contained in:
Alan Viverette
2014-12-08 15:54:38 -08:00
parent 2ea3650d18
commit 11a68e1803

View File

@@ -1246,37 +1246,40 @@ public class RadialTimePickerView extends View implements View.OnTouchListener {
}
final int[] selectionDegrees = mSelectionDegrees;
int type = -1;
int newValue = -1;
final int type;
final int newValue;
final boolean valueChanged;
if (mShowHours) {
final int snapDegrees = snapOnly30s(degrees, 0) % 360;
if (forceSelection
|| selectionDegrees[HOURS] != snapDegrees
valueChanged = selectionDegrees[HOURS] != snapDegrees
|| selectionDegrees[HOURS_INNER] != snapDegrees
|| wasOnInnerCircle != mIsOnInnerCircle) {
selectionDegrees[HOURS] = snapDegrees;
selectionDegrees[HOURS_INNER] = snapDegrees;
|| wasOnInnerCircle != mIsOnInnerCircle;
type = HOURS;
newValue = getCurrentHour();
}
selectionDegrees[HOURS] = snapDegrees;
selectionDegrees[HOURS_INNER] = snapDegrees;
type = HOURS;
newValue = getCurrentHour();
} else {
final int snapDegrees = snapPrefer30s(degrees) % 360;
if (forceSelection || selectionDegrees[MINUTES] != snapDegrees) {
selectionDegrees[MINUTES] = snapDegrees;
valueChanged = selectionDegrees[MINUTES] != snapDegrees;
type = MINUTES;
newValue = getCurrentMinute();
}
selectionDegrees[MINUTES] = snapDegrees;
type = MINUTES;
newValue = getCurrentMinute();
}
if (newValue != -1) {
if (valueChanged || forceSelection || autoAdvance) {
// Fire the listener even if we just need to auto-advance.
if (mListener != null) {
mListener.onValueSelected(type, newValue, autoAdvance);
}
performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
invalidate();
// Only provide feedback if the value actually changed.
if (valueChanged || forceSelection) {
performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
invalidate();
}
return true;
}