use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class SyllabusRecyclerAdapter method populateAdapter.
private void populateAdapter(List<ScheduleItem> scheduleItems) {
if (mCanvasContext.getType() == CanvasContext.Type.COURSE) {
Course course = (Course) mCanvasContext;
ScheduleItem syllabus = ScheduleItem.createSyllabus(course.getName(), course.getSyllabusBody());
addOrUpdateItem(mSyllabus, syllabus);
}
Date curDate = new Date();
// set a future date 7 days in the future, make it the end of the day to include every assignment within the next 7 days,
// including assignments that are due at the end of the 7th day
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 7);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
Date weekFutureDate = calendar.getTime();
for (ScheduleItem scheduleItem : scheduleItems) {
// if it is hidden we don't want to show it. This can happen when an event has multiple sections
if ((scheduleItem.isHidden())) {
continue;
}
Date dueDate = scheduleItem.getStartAt();
if (dueDate == null) {
addOrUpdateItem(mNoDate, scheduleItem);
} else if (dueDate.before(curDate)) {
addOrUpdateItem(mPast, scheduleItem);
} else if (((dueDate.after(curDate) && (dueDate.before(weekFutureDate))) || dueDate.equals(weekFutureDate))) {
addOrUpdateItem(mNext7Days, scheduleItem);
} else if (dueDate.after(weekFutureDate)) {
addOrUpdateItem(mFuture, scheduleItem);
}
}
}
use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class CalendarListRecyclerAdapterTest method testAreContentsTheSame_noAssignmentDifferentName.
@Test
public void testAreContentsTheSame_noAssignmentDifferentName() {
ScheduleItem scheduleItem1 = new ScheduleItem();
scheduleItem1.setTitle("ScheduleItem1a");
Date date = new Date();
scheduleItem1.setStartAt(date);
ScheduleItem scheduleItem2 = new ScheduleItem();
scheduleItem2.setTitle("ScheduleItem1b");
scheduleItem2.setStartAt(date);
assertFalse(mAdapter.createItemCallback().areContentsTheSame(scheduleItem1, scheduleItem2));
}
use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class CalendarListRecyclerAdapterTest method testAreContentsTheSame_noAssignmentSame.
@Test
public void testAreContentsTheSame_noAssignmentSame() {
ScheduleItem scheduleItem1 = new ScheduleItem();
scheduleItem1.setTitle("ScheduleItem1");
scheduleItem1.setStartAt(new Date());
assertTrue(mAdapter.createItemCallback().areContentsTheSame(scheduleItem1, scheduleItem1));
}
use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class CalendarListRecyclerAdapterTest method testAreContentsTheSame_sameAssignment.
@Test
public void testAreContentsTheSame_sameAssignment() {
ScheduleItem scheduleItem1 = new ScheduleItem();
scheduleItem1.setTitle("ScheduleItem1");
scheduleItem1.setStartAt(new Date());
Assignment assignment1 = new Assignment();
assignment1.setDueAt(APIHelper.dateToString(new Date()));
scheduleItem1.setAssignment(assignment1);
assertTrue(mAdapter.createItemCallback().areContentsTheSame(scheduleItem1, scheduleItem1));
}
use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.
the class SyllabusRecyclerAdapterTest method areContentsTheSame_NotNullSameDate.
@Test
public void areContentsTheSame_NotNullSameDate() {
ScheduleItem item = new ScheduleItem();
item.setTitle("item");
item.setStartAt(new Date());
assertTrue(mAdapter.createItemCallback().areContentsTheSame(item, item));
}
Aggregations