mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[API/Librus] Fix LibrusApiTeacherFreeDays. (#123)
* [API/Librus] Remove LibrusApiTeacherFreeDayTypes * [API/Librus] Fix LibrusApiTeacherFreeDay * [API/Librus] LibrusApiTeacherFreeDay: Clean up values of unused variables * [API/Librus] LibrusApiTeacherFreeDay: Remove unnecessary variables * [API/Librus] LibrusApiTeacherFreeDay: Assign null to 'name' object
This commit is contained in:
parent
2b104e6463
commit
aa06868a4e
@ -182,10 +182,6 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
data.startProgress(R.string.edziennik_progress_endpoint_pt_meetings)
|
||||
LibrusApiPtMeetings(data, lastSync, onSuccess)
|
||||
}
|
||||
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES -> {
|
||||
data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_day_types)
|
||||
LibrusApiTeacherFreeDayTypes(data, lastSync, onSuccess)
|
||||
}
|
||||
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS -> {
|
||||
data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_days)
|
||||
LibrusApiTeacherFreeDays(data, lastSync, onSuccess)
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Kacper Ziubryniewicz 2019-10-19
|
||||
*/
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.TeacherAbsenceType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
|
||||
class LibrusApiTeacherFreeDayTypes(override val data: DataLibrus,
|
||||
override val lastSync: Long?,
|
||||
val onSuccess: (endpointId: Int) -> Unit
|
||||
) : LibrusApi(data, lastSync) {
|
||||
companion object {
|
||||
const val TAG = "LibrusApiTeacherFreeDayTypes"
|
||||
}
|
||||
|
||||
init {
|
||||
apiGet(TAG, "TeacherFreeDays/Types") { json ->
|
||||
val teacherAbsenceTypes = json.getJsonArray("Types")?.asJsonObjectList()
|
||||
|
||||
teacherAbsenceTypes?.forEach { teacherAbsenceType ->
|
||||
val id = teacherAbsenceType.getLong("Id") ?: return@forEach
|
||||
val name = teacherAbsenceType.getString("Name") ?: return@forEach
|
||||
|
||||
val teacherAbsenceTypeObject = TeacherAbsenceType(
|
||||
profileId,
|
||||
id,
|
||||
name
|
||||
)
|
||||
|
||||
data.teacherAbsenceTypes.put(id, teacherAbsenceTypeObject)
|
||||
}
|
||||
|
||||
data.setSyncNext(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES, 7 * DAY)
|
||||
onSuccess(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES)
|
||||
}
|
||||
}
|
||||
}
|
@ -36,22 +36,18 @@ class LibrusApiTeacherFreeDays(override val data: DataLibrus,
|
||||
val id = teacherAbsence.getLong("Id") ?: return@forEach
|
||||
val teacherId = teacherAbsence.getJsonObject("Teacher")?.getLong("Id")
|
||||
?: return@forEach
|
||||
val type = teacherAbsence.getJsonObject("Type").getLong("Id") ?: return@forEach
|
||||
val name = data.teacherAbsenceTypes.singleOrNull { it.id == type }?.name
|
||||
val dateFrom = Date.fromY_m_d(teacherAbsence.getString("DateFrom"))
|
||||
val dateTo = Date.fromY_m_d(teacherAbsence.getString("DateTo"))
|
||||
val timeFrom = teacherAbsence.getString("TimeFrom")?.let { Time.fromH_m_s(it) }
|
||||
val timeTo = teacherAbsence.getString("TimeTo")?.let { Time.fromH_m_s(it) }
|
||||
|
||||
val teacherAbsenceObject = TeacherAbsence(
|
||||
profileId = profileId,
|
||||
id = id,
|
||||
type = type,
|
||||
name = name,
|
||||
type = -1L,
|
||||
name = null,
|
||||
dateFrom = dateFrom,
|
||||
dateTo = dateTo,
|
||||
timeFrom = timeFrom,
|
||||
timeTo = timeTo,
|
||||
timeFrom = null,
|
||||
timeTo = null,
|
||||
teacherId = teacherId
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user