/* package */ void setTheme(Context context, boolean themeDark) { mCircleView.setTheme(context, themeDark); mAmPmCirclesView.setTheme(context, themeDark); mHourRadialTextsView.setTheme(context, themeDark); mMinuteRadialTextsView.setTheme(context, themeDark); mHourRadialSelectorView.setTheme(context, themeDark); mMinuteRadialSelectorView.setTheme(context, themeDark); }
/** * Set the internal value as either AM or PM, and update the AM/PM circle displays. * @param amOrPm */ public void setAmOrPm(int amOrPm) { mAmPmCirclesView.setAmOrPm(amOrPm); mAmPmCirclesView.invalidate(); setValueForItem(AMPM_INDEX, amOrPm); }
@Override public void run() { mDoingMove = true; int value = reselectSelector(mDownDegrees, isInnerCircle[0], false, true); mLastValueSelected = value; mListener.onValueSelected(getCurrentItemShowing(), value, false); } }, TAP_TIMEOUT);
@Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } });
/** * 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); } }
/** * Set either the hour or the minute. Will set the internal value, and set the selection. */ private void setItem(int index, int value) { if (index == HOUR_INDEX) { setValueForItem(HOUR_INDEX, value); int hourDegrees = (value % 12) * HOUR_VALUE_TO_DEGREES_STEP_SIZE; mHourRadialSelectorView.setSelection(hourDegrees, isHourInnerCircle(value), false); mHourRadialSelectorView.invalidate(); } else if (index == MINUTE_INDEX) { setValueForItem(MINUTE_INDEX, value); int minuteDegrees = value * MINUTE_VALUE_TO_DEGREES_STEP_SIZE; mMinuteRadialSelectorView.setSelection(minuteDegrees, false, false); mMinuteRadialSelectorView.invalidate(); } }
@Override public void onClick(View v) { tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM){ amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } });
/** * Try to start keyboard mode with the specified key, as long as the timepicker is not in the * middle of a touch-event. * @param keyCode The key to use as the first press. Keyboard mode will not be started if the * key is not legal to start with. Or, pass in -1 to get into keyboard mode without a starting * key. */ private void tryStartingKbMode(int keyCode) { if (mTimePicker.trySettingInputEnabled(false) && (keyCode == -1 || addKeyIfLegal(keyCode))) { mInKbMode = true; mDoneButton.setEnabled(false); updateDisplay(false); } }
public static TimePickerDialog newInstance(OnTimeSetListener callback, int hourOfDay, int minute, boolean is24HourMode) { TimePickerDialog ret = new TimePickerDialog(); ret.initialize(callback, hourOfDay, minute, is24HourMode); return ret; }
@Override public void run() { mAmPmCirclesView.setAmOrPmPressed(mIsTouchingAmOrPm); mAmPmCirclesView.invalidate(); } }, TAP_TIMEOUT);
@Override public void onClick(View v) { if(mCallback != null) { mCallback.onTimeCleared(mTimePicker); } dismiss(); } });
@Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); tryVibrate(); } });
@Override public void onAnimationUpdate(ValueAnimator animation) { RadialTextsView.this.invalidate(); } }
@Override public void onAnimationUpdate(ValueAnimator animation) { RadialSelectorView.this.invalidate(); } }
public Node canReach(int key) { if (mChildren == null) { return null; } for (Node child : mChildren) { if (child.containsKey(key)) { return child; } } return null; } }
/** * Traverse the tree to see if the keys that have been typed so far are legal as is, * or may become legal as more keys are typed (excluding backspace). */ private boolean isTypedTimeLegalSoFar() { Node node = mLegalTimesTree; for (int keyCode : mTypedTimes) { node = node.canReach(keyCode); if (node == null) { return false; } } return true; }
/** * If the hours are showing, return the current hour. If the minutes are showing, return the * current minute. */ private int getCurrentlyShowingValue() { int currentIndex = getCurrentItemShowing(); if (currentIndex == HOUR_INDEX) { return mCurrentHoursOfDay; } else if (currentIndex == MINUTE_INDEX) { return mCurrentMinutes; } else { return -1; } }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AppCompatDialog(getActivity(), R.style.TimePickerDialog); }
@Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); tryVibrate(); } });