Search in sources :

Example 26 with ScheduleItem

use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.

the class ToDoListFragment method onRowClick.

private void onRowClick(ToDo toDo) {
    if (toDo == null) {
        return;
    }
    Bundle bundle = new Bundle();
    bundle.putParcelable(Const.SELECTED_ITEM, toDo);
    Navigation navigation = getNavigation();
    if (navigation != null) {
        if (toDo.getAssignment() != null) {
            // Launch assignment details fragment.
            navigation.addFragment(FragUtils.getFrag(AssignmentFragment.class, createBundle(toDo.getCanvasContext(), toDo.getAssignment())));
        } else if (toDo.getScheduleItem() != null) {
            // It's a Calendar event from the Upcoming API.
            ScheduleItem scheduleItem = toDo.getScheduleItem();
            String actionBarTitle = "";
            if (scheduleItem.getContextType() == CanvasContext.Type.COURSE) {
                actionBarTitle = toDo.getCanvasContext().getName();
            } else if (scheduleItem.getContextType() == CanvasContext.Type.USER) {
                actionBarTitle = getContext().getString(R.string.PersonalCalendar);
            }
            navigation.addFragment(FragUtils.getFrag(CalendarEventFragment.class, createBundle(toDo.getCanvasContext(), actionBarTitle, toDo.getScheduleItem())));
        }
    }
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) Navigation(com.instructure.interactions.Navigation) Bundle(android.os.Bundle)

Example 27 with ScheduleItem

use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.

the class CalendarListRecyclerAdapterTest method testAreContentsTheSame_noAssignmentDifferentDate.

@Test
public void testAreContentsTheSame_noAssignmentDifferentDate() {
    ScheduleItem scheduleItem1 = new ScheduleItem();
    scheduleItem1.setTitle("ScheduleItem1a");
    scheduleItem1.setStartAt(new Date(Calendar.getInstance().getTimeInMillis() - 1000));
    ScheduleItem scheduleItem2 = new ScheduleItem();
    scheduleItem2.setTitle("ScheduleItem1a");
    scheduleItem2.setStartAt(new Date(Calendar.getInstance().getTimeInMillis() + 1000));
    assertFalse(mAdapter.createItemCallback().areContentsTheSame(scheduleItem1, scheduleItem2));
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) Date(java.util.Date) Test(org.junit.Test)

Example 28 with ScheduleItem

use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.

the class CalendarListRecyclerAdapterTest method testAreContentsTheSame_differentAssignment.

@Test
public void testAreContentsTheSame_differentAssignment() {
    ScheduleItem scheduleItem1 = new ScheduleItem();
    scheduleItem1.setTitle("ScheduleItem1");
    Date date = new Date();
    scheduleItem1.setStartAt(date);
    Assignment assignment1 = new Assignment();
    assignment1.setDueAt(APIHelper.dateToString(new Date(Calendar.getInstance().getTimeInMillis() - 1000)));
    scheduleItem1.setAssignment(assignment1);
    ScheduleItem scheduleItem2 = new ScheduleItem();
    scheduleItem2.setTitle("ScheduleItem1");
    scheduleItem2.setStartAt(date);
    Assignment assignment2 = new Assignment();
    assignment2.setDueAt(APIHelper.dateToString(new Date(Calendar.getInstance().getTimeInMillis() + 1000)));
    scheduleItem2.setAssignment(assignment2);
    assertFalse(mAdapter.createItemCallback().areContentsTheSame(scheduleItem1, scheduleItem2));
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) Date(java.util.Date) Test(org.junit.Test)

Example 29 with ScheduleItem

use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.

the class CalendarListRecyclerAdapterTest method testAreContentsTheSame_nullAssignment.

@Test
public void testAreContentsTheSame_nullAssignment() {
    ScheduleItem scheduleItem1 = new ScheduleItem();
    scheduleItem1.setTitle("ScheduleItem1");
    Date date = new Date();
    scheduleItem1.setStartAt(date);
    Assignment assignment1 = new Assignment();
    assignment1.setDueAt(APIHelper.dateToString(date));
    scheduleItem1.setAssignment(assignment1);
    ScheduleItem scheduleItem2 = new ScheduleItem();
    scheduleItem2.setTitle("ScheduleItem1");
    scheduleItem2.setStartAt(date);
    Assignment assignment2 = null;
    scheduleItem2.setAssignment(assignment2);
    assertFalse(mAdapter.createItemCallback().areContentsTheSame(scheduleItem1, scheduleItem2));
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) Date(java.util.Date) Test(org.junit.Test)

Example 30 with ScheduleItem

use of com.instructure.canvasapi2.models.ScheduleItem in project instructure-android by instructure.

the class SyllabusRecyclerAdapterTest method areContentsTheSame_NotNullDifferentDate.

@Test
public void areContentsTheSame_NotNullDifferentDate() {
    ScheduleItem item = new ScheduleItem();
    item.setTitle("item");
    item.setStartAt(new Date(Calendar.getInstance().getTimeInMillis() + 1000));
    ScheduleItem item1 = new ScheduleItem();
    item1.setTitle("item");
    item1.setStartAt(new Date(Calendar.getInstance().getTimeInMillis() - 1000));
    assertFalse(mAdapter.createItemCallback().areContentsTheSame(item, item1));
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)29 Test (org.junit.Test)19 Date (java.util.Date)13 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)9 RestParams (com.instructure.canvasapi2.builders.RestParams)8 Assignment (com.instructure.canvasapi2.models.Assignment)7 ArrayList (java.util.ArrayList)5 View (android.view.View)3 Course (com.instructure.canvasapi2.models.Course)3 List (java.util.List)3 Drawable (android.graphics.drawable.Drawable)2 NonNull (android.support.annotation.NonNull)2 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 ToDo (com.instructure.canvasapi2.models.ToDo)2 Navigation (com.instructure.interactions.Navigation)2 DateTime (hirondelle.date4j.DateTime)2 Bundle (android.os.Bundle)1 TextView (android.widget.TextView)1 SyllabusRecyclerAdapter (com.instructure.candroid.adapter.SyllabusRecyclerAdapter)1