use of android.icu.util.Calendar in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class DateTimeView method computeNextMidnight.
/**
* @param timeZone the timezone we are in
* @return the timepoint in millis at UTC at midnight in the current timezone
*/
private long computeNextMidnight(TimeZone timeZone) {
Calendar c = Calendar.getInstance();
c.setTimeZone(libcore.icu.DateUtilsBridge.icuTimeZone(timeZone));
c.add(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTimeInMillis();
}
use of android.icu.util.Calendar in project platform_frameworks_base by android.
the class CalendarViewLegacyDelegate method setMinDate.
@Override
public void setMinDate(long minDate) {
mTempDate.setTimeInMillis(minDate);
if (isSameDate(mTempDate, mMinDate)) {
return;
}
mMinDate.setTimeInMillis(minDate);
// make sure the current date is not earlier than
// the new min date since the latter is used for
// calculating the indices in the adapter thus
// avoiding out of bounds error
Calendar date = mAdapter.mSelectedDate;
if (date.before(mMinDate)) {
mAdapter.setSelectedDay(mMinDate);
}
// reinitialize the adapter since its range depends on min date
mAdapter.init();
if (date.before(mMinDate)) {
setDate(mTempDate.getTimeInMillis());
} else {
// we go to the current date to force the ListView to query its
// adapter for the shown views since we have changed the adapter
// range and the base from which the later calculates item indices
// note that calling setDate will not work since the date is the same
goTo(date, false, true, false);
}
}
use of android.icu.util.Calendar in project platform_frameworks_base by android.
the class TwilightService method calculateTwilightState.
/**
* Calculates the twilight state for a specific location and time.
*
* @param location the location to use
* @param timeMillis the reference time to use
* @return the calculated {@link TwilightState}, or {@code null} if location is {@code null}
*/
private static TwilightState calculateTwilightState(Location location, long timeMillis) {
if (location == null) {
return null;
}
final CalendarAstronomer ca = new CalendarAstronomer(location.getLongitude(), location.getLatitude());
final Calendar noon = Calendar.getInstance();
noon.setTimeInMillis(timeMillis);
noon.set(Calendar.HOUR_OF_DAY, 12);
noon.set(Calendar.MINUTE, 0);
noon.set(Calendar.SECOND, 0);
noon.set(Calendar.MILLISECOND, 0);
ca.setTime(noon.getTimeInMillis());
long sunriseTimeMillis = ca.getSunRiseSet(true);
long sunsetTimeMillis = ca.getSunRiseSet(false);
if (sunsetTimeMillis < timeMillis) {
noon.add(Calendar.DATE, 1);
ca.setTime(noon.getTimeInMillis());
sunriseTimeMillis = ca.getSunRiseSet(true);
} else if (sunriseTimeMillis > timeMillis) {
noon.add(Calendar.DATE, -1);
ca.setTime(noon.getTimeInMillis());
sunsetTimeMillis = ca.getSunRiseSet(false);
}
return new TwilightState(sunriseTimeMillis, sunsetTimeMillis);
}
use of android.icu.util.Calendar in project platform_frameworks_base by android.
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;
}
Aggregations