use of com.instructure.candroid.model.DateWindow 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