Search in sources :

Example 36 with ScheduleItem

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

the class CalendarListRecyclerAdapter method refreshListView.

/**
 * This method will refresh the list view itself, and not effect the calendar view
 */
public void refreshListView() {
    clear();
    for (ScheduleItem s : mAllEvents) {
        addItemForViewType(s);
    }
    // (will also be called by cache, so won't interfere with cached behavior)
    if (mHasLoadedCalenderEvents && mHasLoadedAssignmentEvents) {
        mAdapterToCalendarCallback.hidePandaLoading();
        setAllPagesLoaded(true);
    }
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem)

Example 37 with ScheduleItem

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

the class CalendarEventManager_Test method getCalendarEvents.

public static void getCalendarEvents(StatusCallback<List<ScheduleItem>> callback) {
    Response response = new Response.Builder().code(200).message("todo").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "todo".getBytes())).addHeader("content-type", "application/json").build();
    List<ScheduleItem> scheduleItems = new ArrayList<>();
    retrofit2.Response<List<ScheduleItem>> response1 = retrofit2.Response.success(scheduleItems, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : Response(okhttp3.Response) ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 38 with ScheduleItem

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

the class ScheduleItemTest method getContextIdTest_Group.

@Test
public void getContextIdTest_Group() throws Exception {
    ScheduleItem scheduleItem = new ScheduleItem();
    scheduleItem.setContextCode("group_12345");
    assertEquals(12345, scheduleItem.getContextId());
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) Test(org.junit.Test)

Example 39 with ScheduleItem

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

the class ScheduleItemTest method getIdTest_Assignment.

@Test
public void getIdTest_Assignment() throws Exception {
    // can't set a schedule item's id to be a string by any exposed method, so use JSON parsing
    // to test it
    String scheduleItemJSON = "{\n\"all_day\": true,\n\"all_day_date\": \"2012-10-17\",\n\"created_at\": \"2012-10-06T01:09:52Z\",\n\"end_at\": \"2012-10-17T06:00:00Z\",\n\"id\": \"assignment_673956\",\n\"location_address\": null,\n\"location_name\": null,\n\"start_at\": \"2012-10-17T06:00:00Z\",\n\"title\": \"No Class\",\n\"updated_at\": \"2012-10-06T01:09:52Z\",\n\"workflow_state\": \"active\",\n\"description\": null,\n\"context_code\": \"course_833052\",\n\"child_events_count\": 0,\n\"parent_event_id\": null,\n\"hidden\": false,\n\"child_events\": [],\n\"url\": \"https://mobiledev.instructure.com/api/v1/calendar_events/673956\",\n\"html_url\": \"https://mobiledev.instructure.com/calendar?event_id=673956&include_contexts=course_833052#7b2273686f77223a2267726f75705f636f757273655f383333303532227d\"\n}";
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    ScheduleItem scheduleItem = gson.fromJson(scheduleItemJSON, ScheduleItem.class);
    assertEquals(673956, scheduleItem.getId());
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 40 with ScheduleItem

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

the class ScheduleItemTest method getIdTest_Number.

@Test
public void getIdTest_Number() throws Exception {
    ScheduleItem scheduleItem = new ScheduleItem();
    scheduleItem.setId(43243);
    assertEquals(43243, scheduleItem.getId());
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) 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