am 8648dfe5: am 5229be05: Merge "Convert getHourForDegrees result to 12-hour format when needed" into lmp-mr1-dev
* commit '8648dfe5f52f131b0af1a17a383ce11d213cedc2': Convert getHourForDegrees result to 12-hour format when needed
This commit is contained in:
@@ -1381,11 +1381,19 @@ public class RadialTimePickerView extends View implements View.OnTouchListener {
|
|||||||
@Override
|
@Override
|
||||||
protected int getVirtualViewAt(float x, float y) {
|
protected int getVirtualViewAt(float x, float y) {
|
||||||
final int id;
|
final int id;
|
||||||
|
|
||||||
|
// Calling getDegreesXY() has side-effects, so we need to cache the
|
||||||
|
// current inner circle value and restore after the call.
|
||||||
|
final boolean wasOnInnerCircle = mIsOnInnerCircle;
|
||||||
final int degrees = getDegreesFromXY(x, y);
|
final int degrees = getDegreesFromXY(x, y);
|
||||||
|
final boolean isOnInnerCircle = mIsOnInnerCircle;
|
||||||
|
mIsOnInnerCircle = wasOnInnerCircle;
|
||||||
|
|
||||||
if (degrees != -1) {
|
if (degrees != -1) {
|
||||||
final int snapDegrees = snapOnly30s(degrees, 0) % 360;
|
final int snapDegrees = snapOnly30s(degrees, 0) % 360;
|
||||||
if (mShowHours) {
|
if (mShowHours) {
|
||||||
final int hour = getHourForDegrees(snapDegrees, mIsOnInnerCircle);
|
final int hour24 = getHourForDegrees(snapDegrees, isOnInnerCircle);
|
||||||
|
final int hour = mIs24HourMode ? hour24 : hour24To12(hour24);
|
||||||
id = makeId(TYPE_HOUR, hour);
|
id = makeId(TYPE_HOUR, hour);
|
||||||
} else {
|
} else {
|
||||||
final int current = getCurrentMinute();
|
final int current = getCurrentMinute();
|
||||||
@@ -1514,6 +1522,16 @@ public class RadialTimePickerView extends View implements View.OnTouchListener {
|
|||||||
return hour24;
|
return hour24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int hour24To12(int hour24) {
|
||||||
|
if (hour24 == 0) {
|
||||||
|
return 12;
|
||||||
|
} else if (hour24 > 12) {
|
||||||
|
return hour24 - 12;
|
||||||
|
} else {
|
||||||
|
return hour24;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void getBoundsForVirtualView(int virtualViewId, Rect bounds) {
|
private void getBoundsForVirtualView(int virtualViewId, Rect bounds) {
|
||||||
final float radius;
|
final float radius;
|
||||||
final int type = getTypeFromId(virtualViewId);
|
final int type = getTypeFromId(virtualViewId);
|
||||||
|
|||||||
Reference in New Issue
Block a user