use of android.icu.util.Calendar in project android_frameworks_base by DirtyUnicorns.
the class SimpleMonthView method onDayClicked.
/**
* Called when the user clicks on a day. Handles callbacks to the
* {@link OnDayClickListener} if one is set.
*
* @param day the day that was clicked
*/
private boolean onDayClicked(int day) {
if (!isValidDayOfMonth(day) || !isDayEnabled(day)) {
return false;
}
if (mOnDayClickListener != null) {
final Calendar date = Calendar.getInstance();
date.set(mYear, mMonth, day);
mOnDayClickListener.onDayClick(this, date);
}
// This is a no-op if accessibility is turned off.
mTouchHelper.sendEventForVirtualView(day, AccessibilityEvent.TYPE_VIEW_CLICKED);
return true;
}
use of android.icu.util.Calendar in project android_frameworks_base by DirtyUnicorns.
the class SimpleMonthView method setMonthParams.
/**
* Sets all the parameters for displaying this week.
* <p>
* Parameters have a default value and will only update if a new value is
* included, except for focus month, which will always default to no focus
* month if no value is passed in. The only required parameter is the week
* start.
*
* @param selectedDay the selected day of the month, or -1 for no selection
* @param month the month
* @param year the year
* @param weekStart which day the week should start on, valid values are
* {@link Calendar#SUNDAY} through {@link Calendar#SATURDAY}
* @param enabledDayStart the first enabled day
* @param enabledDayEnd the last enabled day
*/
void setMonthParams(int selectedDay, int month, int year, int weekStart, int enabledDayStart, int enabledDayEnd) {
mActivatedDay = selectedDay;
if (isValidMonth(month)) {
mMonth = month;
}
mYear = year;
mCalendar.set(Calendar.MONTH, mMonth);
mCalendar.set(Calendar.YEAR, mYear);
mCalendar.set(Calendar.DAY_OF_MONTH, 1);
mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
if (isValidDayOfWeek(weekStart)) {
mWeekStart = weekStart;
} else {
mWeekStart = mCalendar.getFirstDayOfWeek();
}
// Figure out what day today is.
final Calendar today = Calendar.getInstance();
mToday = -1;
mDaysInMonth = getDaysInMonth(mMonth, mYear);
for (int i = 0; i < mDaysInMonth; i++) {
final int day = i + 1;
if (sameDay(day, today)) {
mToday = day;
}
}
mEnabledDayStart = MathUtils.constrain(enabledDayStart, 1, mDaysInMonth);
mEnabledDayEnd = MathUtils.constrain(enabledDayEnd, mEnabledDayStart, mDaysInMonth);
updateMonthYearLabel();
updateDayOfWeekLabels();
// Invalidate cached accessibility information.
mTouchHelper.invalidateRoot();
invalidate();
}
use of android.icu.util.Calendar in project android_frameworks_base by AOSPA.
the class DatePickerSpinnerDelegate method getMaxDate.
@Override
public Calendar getMaxDate() {
final Calendar maxDate = Calendar.getInstance();
maxDate.setTimeInMillis(mCalendarView.getMaxDate());
return maxDate;
}
use of android.icu.util.Calendar in project android_frameworks_base by AOSPA.
the class DatePickerSpinnerDelegate method getMinDate.
@Override
public Calendar getMinDate() {
final Calendar minDate = Calendar.getInstance();
minDate.setTimeInMillis(mCalendarView.getMinDate());
return minDate;
}
use of android.icu.util.Calendar in project android_frameworks_base by AOSPA.
the class DatePickerSpinnerDelegate method getCalendarForLocale.
/**
* Gets a calendar for locale bootstrapped with the value of a given calendar.
*
* @param oldCalendar The old calendar.
* @param locale The locale.
*/
private Calendar getCalendarForLocale(Calendar oldCalendar, Locale locale) {
if (oldCalendar == null) {
return Calendar.getInstance(locale);
} else {
final long currentTimeMillis = oldCalendar.getTimeInMillis();
Calendar newCalendar = Calendar.getInstance(locale);
newCalendar.setTimeInMillis(currentTimeMillis);
return newCalendar;
}
}
Aggregations