/** * Check if the time that has been typed so far is completely legal, as is. */ private boolean isTypedTimeFullyLegal() { if (mIs24HourMode) { // For 24-hour mode, the time is legal if the hours and minutes are each legal. Note: // getEnteredTime() will ONLY call isTypedTimeFullyLegal() when NOT in 24hour mode. int[] values = getEnteredTime(null); return (values[0] >= 0 && values[1] >= 0 && values[1] < 60); } else { // For AM/PM mode, the time is legal if it contains an AM or PM, as those can only be // legally added at specific times based on the tree's algorithm. return (mTypedTimes.contains(getAmOrPmKeyCode(AM)) || mTypedTimes.contains(getAmOrPmKeyCode(PM))); } }
/** * Get out of keyboard mode. If there is nothing in typedTimes, revert to TimePicker's time. * @param changeDisplays If true, update the displays with the relevant time. */ private void finishKbMode(boolean updateDisplays) { mInKbMode = false; if (!mTypedTimes.isEmpty()) { int values[] = getEnteredTime(null); mTimePicker.setTime(values[0], values[1]); if (!mIs24HourMode) { mTimePicker.setAmOrPm(values[2]); } mTypedTimes.clear(); } if (updateDisplays) { updateDisplay(false); mTimePicker.trySettingInputEnabled(true); } }
} else { Boolean[] enteredZeros = {false, false}; int[] values = getEnteredTime(enteredZeros); String hourFormat = enteredZeros[0]? "%02d" : "%2d"; String minuteFormat = (enteredZeros[1])? "%02d" : "%2d";
/** * Check if the time that has been typed so far is completely legal, as is. */ private boolean isTypedTimeFullyLegal() { if (mIs24HourMode) { // For 24-hour mode, the time is legal if the hours and minutes are each legal. Note: // getEnteredTime() will ONLY call isTypedTimeFullyLegal() when NOT in 24hour mode. int[] values = getEnteredTime(null); return (values[0] >= 0 && values[1] >= 0 && values[1] < 60); } else { // For AM/PM mode, the time is legal if it contains an AM or PM, as those can only be // legally added at specific times based on the tree's algorithm. return (mTypedTimes.contains(getAmOrPmKeyCode(AM)) || mTypedTimes.contains(getAmOrPmKeyCode(PM))); } }
/** * Get out of keyboard mode. If there is nothing in typedTimes, revert to TimePicker's time. * @param changeDisplays If true, update the displays with the relevant time. */ private void finishKbMode(boolean updateDisplays) { mInKbMode = false; if (!mTypedTimes.isEmpty()) { int values[] = getEnteredTime(null); mTimePicker.setTime(values[0], values[1]); if (!mIs24HourMode) { mTimePicker.setAmOrPm(values[2]); } mTypedTimes.clear(); } if (updateDisplays) { updateDisplay(false); mTimePicker.trySettingInputEnabled(true); } }
} else { Boolean[] enteredZeros = {false, false}; int[] values = getEnteredTime(enteredZeros); String hourFormat = enteredZeros[0]? "%02d" : "%2d"; String minuteFormat = (enteredZeros[1])? "%02d" : "%2d";