mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[APIv2/Vulcan] Add getting team if it doesn't exist
This commit is contained in:
parent
9e6741d542
commit
2a7535920e
@ -12,6 +12,8 @@ import io.github.wulkanowy.signer.signContent
|
|||||||
import pl.szczodrzynski.edziennik.api.v2.*
|
import pl.szczodrzynski.edziennik.api.v2.*
|
||||||
import pl.szczodrzynski.edziennik.api.v2.models.ApiError
|
import pl.szczodrzynski.edziennik.api.v2.models.ApiError
|
||||||
import pl.szczodrzynski.edziennik.api.v2.vulcan.DataVulcan
|
import pl.szczodrzynski.edziennik.api.v2.vulcan.DataVulcan
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.modules.teams.Team
|
||||||
|
import pl.szczodrzynski.edziennik.utils.Utils
|
||||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
@ -34,6 +36,22 @@ open class VulcanApi(open val data: DataVulcan) {
|
|||||||
|
|
||||||
d(tag, "Request: Vulcan/Api - $url")
|
d(tag, "Request: Vulcan/Api - $url")
|
||||||
|
|
||||||
|
if (data.teamList.size() == 0) {
|
||||||
|
profile?.getStudentData("studentClassName", null)?.also { name ->
|
||||||
|
val id = Utils.crc16(name.toByteArray()).toLong()
|
||||||
|
|
||||||
|
val teamObject = Team(
|
||||||
|
profileId,
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
Team.TYPE_CLASS,
|
||||||
|
"${data.schoolName}:$name",
|
||||||
|
-1
|
||||||
|
)
|
||||||
|
data.teamList.put(id, teamObject)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val startDate = when(profile?.empty) {
|
val startDate = when(profile?.empty) {
|
||||||
true -> profile?.getSemesterStart(profile?.currentSemester ?: 1)?.stringY_m_d
|
true -> profile?.getSemesterStart(profile?.currentSemester ?: 1)?.stringY_m_d
|
||||||
else -> Date.getToday().stepForward(0, -1, 0).stringY_m_d
|
else -> Date.getToday().stepForward(0, -1, 0).stringY_m_d
|
||||||
|
Loading…
x
Reference in New Issue
Block a user