use of android.icu.util.Calendar in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
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 android_frameworks_base by ResurrectionRemix.
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 android_frameworks_base by ResurrectionRemix.
the class CalendarViewLegacyDelegate method setUpAdapter.
/**
* Creates a new adapter if necessary and sets up its parameters.
*/
private void setUpAdapter() {
if (mAdapter == null) {
mAdapter = new WeeksAdapter(mContext);
mAdapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
if (mOnDateChangeListener != null) {
Calendar selectedDay = mAdapter.getSelectedDay();
mOnDateChangeListener.onSelectedDayChange(mDelegator, selectedDay.get(Calendar.YEAR), selectedDay.get(Calendar.MONTH), selectedDay.get(Calendar.DAY_OF_MONTH));
}
}
});
mListView.setAdapter(mAdapter);
}
// refresh the view with the new parameters
mAdapter.notifyDataSetChanged();
}
use of android.icu.util.Calendar in project android_frameworks_base by ResurrectionRemix.
the class CalendarViewLegacyDelegate 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 static 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