From b72324805fc2e32b7f6d2b60234877224c0666ab Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Tue, 5 Nov 2019 18:20:41 +0100 Subject: [PATCH] [APIv2] Move onSuccess from callback to an argument --- .../api/v2/idziennik/data/IdziennikData.kt | 20 +++---- .../api/v2/librus/data/LibrusData.kt | 52 +++++++++---------- .../v2/mobidziennik/data/MobidziennikData.kt | 4 +- .../api/v2/vulcan/data/VulcanData.kt | 18 +++---- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikData.kt index c1ab81f3..64064a83 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikData.kt @@ -41,43 +41,43 @@ class IdziennikData(val data: DataIdziennik, val onSuccess: () -> Unit) { when (endpointId) { ENDPOINT_IDZIENNIK_WEB_TIMETABLE -> { data.startProgress(R.string.edziennik_progress_endpoint_timetable) - IdziennikWebTimetable(data) { onSuccess() } + IdziennikWebTimetable(data, onSuccess) } ENDPOINT_IDZIENNIK_WEB_GRADES -> { data.startProgress(R.string.edziennik_progress_endpoint_grades) - IdziennikWebGrades(data) { onSuccess() } + IdziennikWebGrades(data, onSuccess) } ENDPOINT_IDZIENNIK_WEB_PROPOSED_GRADES -> { data.startProgress(R.string.edziennik_progress_endpoint_proposed_grades) - IdziennikWebProposedGrades(data) { onSuccess() } + IdziennikWebProposedGrades(data, onSuccess) } ENDPOINT_IDZIENNIK_WEB_EXAMS -> { data.startProgress(R.string.edziennik_progress_endpoint_exams) - IdziennikWebExams(data) { onSuccess() } + IdziennikWebExams(data, onSuccess) } ENDPOINT_IDZIENNIK_WEB_NOTICES -> { data.startProgress(R.string.edziennik_progress_endpoint_notices) - IdziennikWebNotices(data) { onSuccess() } + IdziennikWebNotices(data, onSuccess) } ENDPOINT_IDZIENNIK_WEB_ANNOUNCEMENTS -> { data.startProgress(R.string.edziennik_progress_endpoint_announcements) - IdziennikWebAnnouncements(data) { onSuccess() } + IdziennikWebAnnouncements(data, onSuccess) } ENDPOINT_IDZIENNIK_WEB_ATTENDANCE -> { data.startProgress(R.string.edziennik_progress_endpoint_attendance) - IdziennikWebAttendance(data) { onSuccess() } + IdziennikWebAttendance(data, onSuccess) } ENDPOINT_IDZIENNIK_API_CURRENT_REGISTER -> { data.startProgress(R.string.edziennik_progress_endpoint_lucky_number) - IdziennikApiCurrentRegister(data) { onSuccess() } + IdziennikApiCurrentRegister(data, onSuccess) } ENDPOINT_IDZIENNIK_API_MESSAGES_INBOX -> { data.startProgress(R.string.edziennik_progress_endpoint_messages_inbox) - IdziennikApiMessagesInbox(data) { onSuccess() } + IdziennikApiMessagesInbox(data, onSuccess) } ENDPOINT_IDZIENNIK_API_MESSAGES_SENT -> { data.startProgress(R.string.edziennik_progress_endpoint_messages_outbox) - IdziennikApiMessagesSent(data) { onSuccess() } + IdziennikApiMessagesSent(data, onSuccess) } else -> onSuccess() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusData.kt index 1d07ffd1..7075e552 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusData.kt @@ -45,96 +45,96 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) { */ ENDPOINT_LIBRUS_API_ME -> { data.startProgress(R.string.edziennik_progress_endpoint_student_info) - LibrusApiMe(data) { onSuccess() } + LibrusApiMe(data, onSuccess) } ENDPOINT_LIBRUS_API_SCHOOLS -> { data.startProgress(R.string.edziennik_progress_endpoint_school_info) - LibrusApiSchools(data) { onSuccess() } + LibrusApiSchools(data, onSuccess) } ENDPOINT_LIBRUS_API_CLASSES -> { data.startProgress(R.string.edziennik_progress_endpoint_classes) - LibrusApiClasses(data) { onSuccess() } + LibrusApiClasses(data, onSuccess) } ENDPOINT_LIBRUS_API_VIRTUAL_CLASSES -> { data.startProgress(R.string.edziennik_progress_endpoint_teams) - LibrusApiVirtualClasses(data) { onSuccess() } + LibrusApiVirtualClasses(data, onSuccess) } ENDPOINT_LIBRUS_API_UNITS -> { data.startProgress(R.string.edziennik_progress_endpoint_units) - LibrusApiUnits(data) { onSuccess() } + LibrusApiUnits(data, onSuccess) } ENDPOINT_LIBRUS_API_USERS -> { data.startProgress(R.string.edziennik_progress_endpoint_teachers) - LibrusApiUsers(data) { onSuccess() } + LibrusApiUsers(data, onSuccess) } ENDPOINT_LIBRUS_API_SUBJECTS -> { data.startProgress(R.string.edziennik_progress_endpoint_subjects) - LibrusApiSubjects(data) { onSuccess() } + LibrusApiSubjects(data, onSuccess) } ENDPOINT_LIBRUS_API_CLASSROOMS -> { data.startProgress(R.string.edziennik_progress_endpoint_classrooms) - LibrusApiClassrooms(data) { onSuccess() } + LibrusApiClassrooms(data, onSuccess) } // TODO push config // TODO timetable ENDPOINT_LIBRUS_API_NORMAL_GRADES -> { data.startProgress(R.string.edziennik_progress_endpoint_grades) - LibrusApiGrades(data) { onSuccess() } + LibrusApiGrades(data, onSuccess) } ENDPOINT_LIBRUS_API_NORMAL_GC -> { data.startProgress(R.string.edziennik_progress_endpoint_grade_categories) - LibrusApiGradeCategories(data) { onSuccess() } + LibrusApiGradeCategories(data, onSuccess) } // TODO grades ENDPOINT_LIBRUS_API_EVENT_TYPES -> { data.startProgress(R.string.edziennik_progress_endpoint_event_types) - LibrusApiEventTypes(data) { onSuccess() } + LibrusApiEventTypes(data, onSuccess) } ENDPOINT_LIBRUS_API_EVENTS -> { data.startProgress(R.string.edziennik_progress_endpoint_events) - LibrusApiEvents(data) { onSuccess() } + LibrusApiEvents(data, onSuccess) } ENDPOINT_LIBRUS_API_HOMEWORK -> { data.startProgress(R.string.edziennik_progress_endpoint_homework) - LibrusApiHomework(data) { onSuccess() } + LibrusApiHomework(data, onSuccess) } ENDPOINT_LIBRUS_API_LUCKY_NUMBER -> { data.startProgress(R.string.edziennik_progress_endpoint_lucky_number) - LibrusApiLuckyNumber(data) { onSuccess() } + LibrusApiLuckyNumber(data, onSuccess) } ENDPOINT_LIBRUS_API_NOTICE_TYPES -> { data.startProgress(R.string.edziennik_progress_endpoint_notice_types) - LibrusApiNoticeTypes(data) { onSuccess() } + LibrusApiNoticeTypes(data, onSuccess) } ENDPOINT_LIBRUS_API_NOTICES -> { data.startProgress(R.string.edziennik_progress_endpoint_notices) - LibrusApiNotices(data) { onSuccess() } + LibrusApiNotices(data, onSuccess) } ENDPOINT_LIBRUS_API_ATTENDANCE_TYPES -> { data.startProgress(R.string.edziennik_progress_endpoint_attendance_types) - LibrusApiAttendanceTypes(data) { onSuccess() } + LibrusApiAttendanceTypes(data, onSuccess) } ENDPOINT_LIBRUS_API_ATTENDANCES -> { data.startProgress(R.string.edziennik_progress_endpoint_attendance) - LibrusApiAttendances(data) { onSuccess() } + LibrusApiAttendances(data, onSuccess) } ENDPOINT_LIBRUS_API_ANNOUNCEMENTS -> { data.startProgress(R.string.edziennik_progress_endpoint_announcements) - LibrusApiAnnouncements(data) { onSuccess() } + LibrusApiAnnouncements(data, onSuccess) } ENDPOINT_LIBRUS_API_PT_MEETINGS -> { data.startProgress(R.string.edziennik_progress_endpoint_pt_meetings) - LibrusApiPtMeetings(data) { onSuccess() } + LibrusApiPtMeetings(data, onSuccess) } ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES -> { data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_day_types) - LibrusApiTeacherFreeDayTypes(data) { onSuccess() } + LibrusApiTeacherFreeDayTypes(data, onSuccess) } ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS -> { data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_days) - LibrusApiTeacherFreeDays(data) { onSuccess() } + LibrusApiTeacherFreeDays(data, onSuccess) } /** @@ -142,11 +142,11 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) { */ ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK -> { data.startProgress(R.string.edziennik_progress_endpoint_homework) - LibrusSynergiaHomework(data) { onSuccess() } + LibrusSynergiaHomework(data, onSuccess) } ENDPOINT_LIBRUS_SYNERGIA_INFO -> { data.startProgress(R.string.edziennik_progress_endpoint_student_info) - LibrusSynergiaInfo(data) { onSuccess() } + LibrusSynergiaInfo(data, onSuccess) } /** @@ -154,11 +154,11 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) { */ ENDPOINT_LIBRUS_MESSAGES_RECEIVED -> { data.startProgress(R.string.edziennik_progress_endpoint_messages_inbox) - LibrusMessagesGetList(data, type = Message.TYPE_RECEIVED) { onSuccess() } + LibrusMessagesGetList(data, type = Message.TYPE_RECEIVED, onSuccess = onSuccess) } ENDPOINT_LIBRUS_MESSAGES_SENT -> { data.startProgress(R.string.edziennik_progress_endpoint_messages_outbox) - LibrusMessagesGetList(data, type = Message.TYPE_SENT) { onSuccess() } + LibrusMessagesGetList(data, type = Message.TYPE_SENT, onSuccess = onSuccess) } else -> onSuccess() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/MobidziennikData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/MobidziennikData.kt index e287d1db..e6f2aca5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/MobidziennikData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/MobidziennikData.kt @@ -42,7 +42,7 @@ class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) { when (endpointId) { ENDPOINT_MOBIDZIENNIK_API_MAIN -> { data.startProgress(R.string.edziennik_progress_endpoint_data) - MobidziennikApi(data) { onSuccess() } + MobidziennikApi(data, onSuccess) } ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_INBOX -> { data.startProgress(R.string.edziennik_progress_endpoint_messages_inbox) @@ -75,4 +75,4 @@ class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) { else -> onSuccess() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/VulcanData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/VulcanData.kt index e7bcff7f..432a21d2 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/VulcanData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/VulcanData.kt @@ -38,39 +38,39 @@ class VulcanData(val data: DataVulcan, val onSuccess: () -> Unit) { when (endpointId) { ENDPOINT_VULCAN_API_DICTIONARIES -> { data.startProgress(R.string.edziennik_progress_endpoint_dictionaries) - VulcanApiDictionaries(data) { onSuccess() } + VulcanApiDictionaries(data, onSuccess) } ENDPOINT_VULCAN_API_GRADES -> { data.startProgress(R.string.edziennik_progress_endpoint_grades) - VulcanApiGrades(data) { onSuccess() } + VulcanApiGrades(data, onSuccess) } ENDPOINT_VULCAN_API_GRADES_SUMMARY -> { data.startProgress(R.string.edziennik_progress_endpoint_proposed_grades) - VulcanApiProposedGrades(data) { onSuccess() } + VulcanApiProposedGrades(data, onSuccess) } ENDPOINT_VULCAN_API_EVENTS -> { data.startProgress(R.string.edziennik_progress_endpoint_events) - VulcanApiEvents(data, isHomework = false) { onSuccess() } + VulcanApiEvents(data, isHomework = false, onSuccess = onSuccess) } ENDPOINT_VULCAN_API_HOMEWORK -> { data.startProgress(R.string.edziennik_progress_endpoint_homework) - VulcanApiEvents(data, isHomework = true) { onSuccess() } + VulcanApiEvents(data, isHomework = true, onSuccess = onSuccess) } ENDPOINT_VULCAN_API_NOTICES -> { data.startProgress(R.string.edziennik_progress_endpoint_notices) - VulcanApiNotices(data) { onSuccess() } + VulcanApiNotices(data, onSuccess) } ENDPOINT_VULCAN_API_ATTENDANCE -> { data.startProgress(R.string.edziennik_progress_endpoint_attendance) - VulcanApiAttendance(data) { onSuccess() } + VulcanApiAttendance(data, onSuccess) } ENDPOINT_VULCAN_API_MESSAGES_INBOX -> { data.startProgress(R.string.edziennik_progress_endpoint_messages_inbox) - VulcanApiMessagesInbox(data) { onSuccess() } + VulcanApiMessagesInbox(data, onSuccess) } ENDPOINT_VULCAN_API_MESSAGES_SENT -> { data.startProgress(R.string.edziennik_progress_endpoint_messages_outbox) - VulcanApiMessagesSent(data) { onSuccess() } + VulcanApiMessagesSent(data, onSuccess) } else -> onSuccess() }