Search in sources :

Example 1 with AccountNotification

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

the class DetailViewActivity method routeFromIntent.

private void routeFromIntent(Intent intent) {
    DETAIL_FRAGMENT fragmentType = (DETAIL_FRAGMENT) intent.getExtras().getSerializable(Const.FRAGMENT_TYPE);
    if (fragmentType != null) {
        Student student = intent.getExtras().getParcelable(Const.STUDENT);
        switch(fragmentType) {
            case WEEK:
                Student user = intent.getExtras().getParcelable(Const.USER);
                Course course = (Course) intent.getExtras().getSerializable(Const.COURSE);
                if (user != null && course != null) {
                    addFragment(CourseWeekFragment.newInstance(user, course));
                }
                break;
            case ASSIGNMENT:
                Assignment assignment = intent.getExtras().getParcelable(Const.ASSIGNMENT);
                String courseName = intent.getExtras().getString(Const.NAME);
                addFragment(AssignmentFragment.newInstance(assignment, courseName, student), false);
                break;
            case ANNOUNCEMENT:
                DiscussionTopicHeader announcement = intent.getExtras().getParcelable(Const.ANNOUNCEMENT);
                String announcementCourseName = intent.getExtras().getString(Const.NAME);
                addFragment(AnnouncementFragment.newInstance(announcement, announcementCourseName, student), false);
                break;
            case EVENT:
                ScheduleItem item = intent.getExtras().getParcelable(Const.SCHEDULE_ITEM);
                addFragment(EventFragment.newInstance(item, student), false);
                break;
            case SYLLABUS:
                Course syllabusCourse = (Course) intent.getExtras().getSerializable(Const.COURSE);
                addFragment(CourseSyllabusFragment.newInstance(syllabusCourse, student), false);
                break;
            case ACCOUNT_NOTIFICATION:
                AccountNotification accountNotification = intent.getExtras().getParcelable(Const.ACCOUNT_NOTIFICATION);
                addFragment(AccountNotificationFragment.newInstance(accountNotification, student));
        }
    }
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) DiscussionTopicHeader(com.instructure.canvasapi2.models.DiscussionTopicHeader) Student(com.instructure.canvasapi2.models.Student) Course(com.instructure.canvasapi2.models.Course) AccountNotification(com.instructure.canvasapi2.models.AccountNotification)

Example 2 with AccountNotification

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

the class AccountNotificationManager method getAccountNotifications.

public static void getAccountNotifications(StatusCallback<List<AccountNotification>> callback, boolean forceNetwork) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
        AccountNotificationAPI.getAccountNotifications(adapter, params, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 3 with AccountNotification

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

the class AccountNotificationManager method getAllAccountNotifications.

public static void getAllAccountNotifications(StatusCallback<List<AccountNotification>> callback, boolean forceNetwork) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
        StatusCallback<List<AccountNotification>> depaginatedCallback = new ExhaustiveListCallback<AccountNotification>(callback) {

            @Override
            public void getNextPage(StatusCallback<List<AccountNotification>> callback, String nextUrl, boolean isCached) {
                AccountNotificationAPI.getAccountNotifications(adapter, params, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        AccountNotificationAPI.getAccountNotifications(adapter, params, depaginatedCallback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback) AccountNotification(com.instructure.canvasapi2.models.AccountNotification)

Example 4 with AccountNotification

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

the class AccountNotificationManager method deleteAccountNotification.

public static void deleteAccountNotification(long notificationId, StatusCallback<AccountNotification> callback) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().build();
        AccountNotificationAPI.deleteAccountNotification(notificationId, adapter, params, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 5 with AccountNotification

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

the class AccountNotificationManager method getAccountNotificationForStudentAirwolf.

public static void getAccountNotificationForStudentAirwolf(String airwolfDomain, String parentId, String studentId, String accountNotificationId, boolean forceNetwork, StatusCallback<AccountNotification> callback) {
    if (isTesting() || mTesting) {
        AccountNotificationManager_Test.getAccountNotificationForStudent(parentId, studentId, accountNotificationId, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withDomain(airwolfDomain).withForceReadFromNetwork(forceNetwork).withAPIVersion("").build();
        AccountNotificationAPI.getAccountNotificationForStudentById(adapter, params, parentId, studentId, accountNotificationId, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Aggregations

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)4 RestParams (com.instructure.canvasapi2.builders.RestParams)4 AccountNotification (com.instructure.canvasapi2.models.AccountNotification)3 StatusCallback (com.instructure.canvasapi2.StatusCallback)1 Assignment (com.instructure.canvasapi2.models.Assignment)1 Course (com.instructure.canvasapi2.models.Course)1 DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)1 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)1 Student (com.instructure.canvasapi2.models.Student)1 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)1 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)1 List (java.util.List)1 Response (okhttp3.Response)1