Search in sources :

Example 11 with Calendar

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;
}
Also used : Calendar(android.icu.util.Calendar)

Example 12 with Calendar

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();
}
Also used : Calendar(android.icu.util.Calendar) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 13 with Calendar

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;
}
Also used : Calendar(android.icu.util.Calendar)

Example 14 with Calendar

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;
}
Also used : Calendar(android.icu.util.Calendar)

Example 15 with Calendar

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;
    }
}
Also used : Calendar(android.icu.util.Calendar)

Aggregations

Calendar (android.icu.util.Calendar)233 Test (org.junit.Test)155 GregorianCalendar (android.icu.util.GregorianCalendar)135 Date (java.util.Date)96 JapaneseCalendar (android.icu.util.JapaneseCalendar)72 SimpleDateFormat (android.icu.text.SimpleDateFormat)69 ULocale (android.icu.util.ULocale)60 BuddhistCalendar (android.icu.util.BuddhistCalendar)53 ChineseCalendar (android.icu.util.ChineseCalendar)52 IslamicCalendar (android.icu.util.IslamicCalendar)48 TimeZone (android.icu.util.TimeZone)41 DateFormat (android.icu.text.DateFormat)37 HebrewCalendar (android.icu.util.HebrewCalendar)32 FieldPosition (java.text.FieldPosition)29 SimpleTimeZone (android.icu.util.SimpleTimeZone)26 ParsePosition (java.text.ParsePosition)23 TaiwanCalendar (android.icu.util.TaiwanCalendar)22 ParseException (java.text.ParseException)21 ChineseDateFormat (android.icu.text.ChineseDateFormat)17 IOException (java.io.IOException)16