Search in sources :

Example 16 with ScheduleItem

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

the class CalendarEventManager method getCalendarEvent.

public static void getCalendarEvent(long eventId, StatusCallback<ScheduleItem> callback, boolean forceNetwork) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).build();
        CalendarEventAPI.getCalendarEvent(eventId, adapter, params, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 17 with ScheduleItem

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

the class CalendarEventManager method getUpcomingEventsSynchronous.

@NonNull
public static List<ScheduleItem> getUpcomingEventsSynchronous(boolean forceNetwork) throws IOException {
    if (isTesting() || mTesting) {
        // TODO
        return new ArrayList();
    } else {
        final RestBuilder adapter = new RestBuilder();
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
        Response<List<ScheduleItem>> response = CalendarEventAPI.getUpcomingEventsSynchronous(adapter, params);
        return (response != null && response.isSuccessful() && response.body() != null) ? response.body() : new ArrayList();
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) ArrayList(java.util.ArrayList) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) ArrayList(java.util.ArrayList) List(java.util.List) NonNull(android.support.annotation.NonNull)

Example 18 with ScheduleItem

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

the class CalendarEventManager method deleteCalendarEvent.

public static void deleteCalendarEvent(long eventId, String cancelReason, StatusCallback<ScheduleItem> callback) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().build();
        CalendarEventAPI.deleteCalendarEvent(eventId, cancelReason, adapter, params, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 19 with ScheduleItem

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

the class CalendarEventManager method getAllCalendarEventsWithSubmissionsAirwolf.

public static void getAllCalendarEventsWithSubmissionsAirwolf(String airwolfDomain, String parentId, String studentId, String startDate, String endDate, ArrayList<String> canvasContexts, boolean forceNetwork, StatusCallback<List<ScheduleItem>> callback) {
    if (isTesting() || mTesting) {
    // TODO:
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withDomain(airwolfDomain).withAPIVersion("").withForceReadFromNetwork(forceNetwork).build();
        CalendarEventAPI.getAllCalendarEventsWithSubmissionAirwolf(parentId, studentId, startDate, endDate, canvasContexts, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 20 with ScheduleItem

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

the class ScheduleItemTest method getIdTest_AssignmentOverrides.

@Test
public void getIdTest_AssignmentOverrides() 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);
    AssignmentOverride assignmentOverride = new AssignmentOverride();
    assignmentOverride.setId(1234567);
    ArrayList<AssignmentOverride> assignmentOverrides = new ArrayList<>();
    assignmentOverrides.add(assignmentOverride);
    scheduleItem.setAssignmentOverrides(assignmentOverrides);
    assertEquals(1234567, scheduleItem.getId());
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) AssignmentOverride(com.instructure.canvasapi2.models.AssignmentOverride) 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