use of hirondelle.date4j.DateTime in project instructure-android by instructure.
the class CalendarListRecyclerAdapter method getFirstStartDate.
private Calendar getFirstStartDate() {
int startDay = getStartDayOfWeek();
Calendar cal = Calendar.getInstance();
DateTime today = DateTime.forInstant(cal.getTime().getTime(), TimeZone.getDefault());
ArrayList<DateTime> dates = CalendarHelper.getFullWeeks(today.getMonth(), today.getYear(), startDay, false);
DateTime startDate = dates.get(0);
cal.set(startDate.getYear(), startDate.getMonth() - 1, startDate.getDay(), startDate.getHour(), startDate.getMinute(), startDate.getSecond());
return cal;
}
use of hirondelle.date4j.DateTime in project instructure-android by instructure.
the class CalendarListRecyclerAdapter method addItemForViewType.
/**
* A small helper method to make adding items to our adapter simpler
*
* @param s
* @return
*/
private boolean addItemForViewType(ScheduleItem s) {
Date d = s.getStartAt();
if (d == null) {
return false;
}
DateTime dateTime = DateTime.forInstant(d.getTime(), TimeZone.getDefault());
CalendarListViewFragment.CalendarView currentCalendarView = CalendarListViewFragment.CalendarView.fromInteger(mAdapterToCalendarCallback.getCurrentCalendarView());
if (currentCalendarView == CalendarListViewFragment.CalendarView.DAY_VIEW && mSelectedDay != null) {
if (dateTime.getDay().equals(mSelectedDay.getDay()) && dateTime.getMonth().equals(mSelectedDay.getMonth())) {
addOrUpdateItem(DateHelper.getCleanDate(d.getTime()), s);
}
} else if (currentCalendarView == CalendarListViewFragment.CalendarView.WEEK_VIEW && mSelectedDay != null) {
Date selectedDate = new Date(mSelectedDay.getMilliseconds(TimeZone.getDefault()));
DateWindow dateWindow = CanvasCalendarUtils.setSelectedWeekWindow(selectedDate, mIsStartDayMonday);
if (CanvasCalendarUtils.isWithinWeekWindow(d, dateWindow.getStart(), dateWindow.getEnd())) {
addOrUpdateItem(DateHelper.getCleanDate(d.getTime()), s);
}
} else if (currentCalendarView == CalendarListViewFragment.CalendarView.MONTH_VIEW) {
addOrUpdateItem(DateHelper.getCleanDate(d.getTime()), s);
}
return true;
}
Aggregations