use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class CalendarViewAdapter method buildWeekDate.
private String buildWeekDate() {
// Calculate the start of the week, taking into account the "first day of the week"
// setting.
Time t = new Time(mTimeZone);
t.set(mMilliTime);
int firstDayOfWeek = Utils.getFirstDayOfWeek(mContext);
int dayOfWeek = t.getWeekDay();
int diff = dayOfWeek - firstDayOfWeek;
if (diff != 0) {
if (diff < 0) {
diff += 7;
}
t.setDay(t.getDay() - diff);
t.normalize();
}
long weekStartTime = t.toMillis();
// The end of the week is 6 days after the start of the week
long weekEndTime = weekStartTime + DateUtils.WEEK_IN_MILLIS - DateUtils.DAY_IN_MILLIS;
// If week start and end is in 2 different months, use short months names
Time t1 = new Time(mTimeZone);
t1.set(weekEndTime);
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
if (t.getMonth() != t1.getMonth()) {
flags |= DateUtils.FORMAT_ABBREV_MONTH;
}
mStringBuilder.setLength(0);
String date = DateUtils.formatDateRange(mContext, mFormatter, weekStartTime, weekEndTime, flags, mTimeZone).toString();
return date;
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class SimpleWeekView method setWeekParams.
/**
* Sets all the parameters for displaying this week. The only required
* parameter is the week number. Other 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. See
* {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
*
* @param params A map of the new parameters, see
* {@link #VIEW_PARAMS_HEIGHT}
* @param tz The time zone this view should reference times in
*/
public void setWeekParams(HashMap<String, Integer> params, String tz) {
if (!params.containsKey(VIEW_PARAMS_WEEK)) {
throw new InvalidParameterException("You must specify the week number for this view");
}
setTag(params);
mTimeZone = tz;
// We keep the current value for any params not present
if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
mHeight = params.get(VIEW_PARAMS_HEIGHT);
if (mHeight < MIN_HEIGHT) {
mHeight = MIN_HEIGHT;
}
}
if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
}
mHasSelectedDay = mSelectedDay != -1;
if (params.containsKey(VIEW_PARAMS_NUM_DAYS)) {
mNumDays = params.get(VIEW_PARAMS_NUM_DAYS);
}
if (params.containsKey(VIEW_PARAMS_SHOW_WK_NUM)) {
if (params.get(VIEW_PARAMS_SHOW_WK_NUM) != 0) {
mShowWeekNum = true;
} else {
mShowWeekNum = false;
}
}
mNumCells = mShowWeekNum ? mNumDays + 1 : mNumDays;
// Allocate space for caching the day numbers and focus values
mDayNumbers = new String[mNumCells];
mFocusDay = new boolean[mNumCells];
mOddMonth = new boolean[mNumCells];
mWeek = params.get(VIEW_PARAMS_WEEK);
int julianMonday = Utils.getJulianMondayFromWeeksSinceEpoch(mWeek);
Time time = new Time(tz);
time.setJulianDay(julianMonday);
// If we're showing the week number calculate it based on Monday
int i = 0;
if (mShowWeekNum) {
mDayNumbers[0] = NumberFormat.getInstance().format(time.getWeekNumber());
i++;
}
if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
}
// Dec 27th 1969 -Jan 2nd, 1970
if (time.getWeekDay() != mWeekStart) {
int diff = time.getWeekDay() - mWeekStart;
if (diff < 0) {
diff += 7;
}
time.setDay(time.getDay() - diff);
time.normalize();
}
mFirstJulianDay = Time.getJulianDay(time.toMillis(), time.getGmtOffset());
mFirstMonth = time.getMonth();
// Figure out what day today is
Time today = new Time(tz);
today.set(System.currentTimeMillis());
mHasToday = false;
mToday = -1;
int focusMonth = params.containsKey(VIEW_PARAMS_FOCUS_MONTH) ? params.get(VIEW_PARAMS_FOCUS_MONTH) : DEFAULT_FOCUS_MONTH;
for (; i < mNumCells; i++) {
if (time.getDay() == 1) {
mFirstMonth = time.getMonth();
}
mOddMonth[i] = (time.getMonth() % 2) == 1;
if (time.getMonth() == focusMonth) {
mFocusDay[i] = true;
} else {
mFocusDay[i] = false;
}
if (time.getYear() == today.getYear() && time.getYearDay() == today.getYearDay()) {
mHasToday = true;
mToday = i;
}
mDayNumbers[i] = NumberFormat.getInstance().format(time.getDay());
time.setDay(time.getDay() + 1);
time.normalize();
}
// new month undo it
if (time.getDay() == 1) {
time.setDay(time.getDay() - 1);
time.normalize();
}
mLastMonth = time.getMonth();
updateSelectionPositions();
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class SimpleWeekView method onHoverEvent.
@Override
public boolean onHoverEvent(MotionEvent event) {
Context context = getContext();
// only send accessibility events if accessibility and exploration are
// on.
AccessibilityManager am = (AccessibilityManager) context.getSystemService(Service.ACCESSIBILITY_SERVICE);
if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
return super.onHoverEvent(event);
}
if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
Time hover = getDayFromLocation(event.getX());
if (hover != null && (mLastHoverTime == null || hover.compareTo(mLastHoverTime) != 0)) {
Long millis = hover.toMillis();
String date = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_SHOW_DATE);
AccessibilityEvent accessEvent = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
accessEvent.getText().add(date);
sendAccessibilityEventUnchecked(accessEvent);
mLastHoverTime = hover;
}
}
return true;
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class SimpleWeekView method getDayFromLocation.
/**
* Calculates the day that the given x position is in, accounting for week
* number. Returns a Time referencing that day or null if
*
* @param x The x position of the touch event
* @return A time object for the tapped day or null if the position wasn't
* in a day
*/
public Time getDayFromLocation(float x) {
int dayStart = mPadding;
if (x < dayStart || x > mWidth - mPadding) {
return null;
}
// Selection is (x - start) / (pixels/day) == (x -s) * day / pixels
int dayPosition = (int) ((x - dayStart) * mNumDays / (mWidth - dayStart - mPadding));
int day = mFirstJulianDay + dayPosition;
Time time = new Time(mTimeZone);
if (mWeek == 0) {
// This week is weird...
if (day < Utils.EPOCH_JULIAN_DAY) {
day++;
} else if (day == Utils.EPOCH_JULIAN_DAY) {
time.set(1, 0, 1970);
time.normalize();
return time;
}
}
time.setJulianDay(day);
return time;
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class MonthByWeekAdapter method setDayParameters.
private void setDayParameters(Time day) {
day.setTimezone(mHomeTimeZone);
Time currTime = new Time(mHomeTimeZone);
currTime.set(mController.getTime());
day.setHour(currTime.getHour());
day.setMinute(currTime.getMinute());
day.setAllDay(false);
day.normalize();
}
Aggregations