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 fec47ca2..e95f87d6 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
@@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.api.v2.vulcan.*
import pl.szczodrzynski.edziennik.api.v2.vulcan.data.api.VulcanApiDictionaries
import pl.szczodrzynski.edziennik.api.v2.vulcan.data.api.VulcanApiEvents
import pl.szczodrzynski.edziennik.api.v2.vulcan.data.api.VulcanApiGrades
+import pl.szczodrzynski.edziennik.api.v2.vulcan.data.api.VulcanApiNotices
import pl.szczodrzynski.edziennik.utils.Utils
class VulcanData(val data: DataVulcan, val onSuccess: () -> Unit) {
@@ -55,6 +56,10 @@ class VulcanData(val data: DataVulcan, val onSuccess: () -> Unit) {
data.startProgress(R.string.edziennik_progress_endpoint_homework)
VulcanApiEvents(data, isHomework = true) { onSuccess() }
}
+ ENDPOINT_VULCAN_API_NOTICES -> {
+ data.startProgress(R.string.edziennik_progress_endpoint_notices)
+ VulcanApiNotices(data) { onSuccess() }
+ }
else -> onSuccess()
}
}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/api/VulcanApiNotices.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/api/VulcanApiNotices.kt
new file mode 100644
index 00000000..c891cbd2
--- /dev/null
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/api/VulcanApiNotices.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) Kacper Ziubryniewicz 2019-10-23
+ */
+
+package pl.szczodrzynski.edziennik.api.v2.vulcan.data.api
+
+import pl.szczodrzynski.edziennik.api.v2.VULCAN_API_ENDPOINT_NOTICES
+import pl.szczodrzynski.edziennik.api.v2.vulcan.DataVulcan
+import pl.szczodrzynski.edziennik.api.v2.vulcan.ENDPOINT_VULCAN_API_NOTICES
+import pl.szczodrzynski.edziennik.api.v2.vulcan.data.VulcanApi
+import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS
+import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata
+import pl.szczodrzynski.edziennik.data.db.modules.notices.Notice
+import pl.szczodrzynski.edziennik.getJsonArray
+import pl.szczodrzynski.edziennik.getLong
+import pl.szczodrzynski.edziennik.getString
+import pl.szczodrzynski.edziennik.utils.models.Date
+
+class VulcanApiNotices(override val data: DataVulcan, val onSuccess: () -> Unit) : VulcanApi(data) {
+ companion object {
+ const val TAG = "VulcanApi"
+ }
+
+ init {
+ apiGet(TAG, VULCAN_API_ENDPOINT_NOTICES) { json, _ ->
+ json.getJsonArray("Data")?.forEach { noticeEl ->
+ val notice = noticeEl.asJsonObject
+
+ val id = notice.getLong("Id") ?: return@forEach
+ val text = notice.getString("TrescUwagi") ?: return@forEach
+ val teacherId = notice.getLong("IdPracownik") ?: -1
+ val addedDate = Date.fromY_m_d(notice.getString("DataWpisuTekst")).inMillis
+
+ val noticeObject = Notice(
+ profileId,
+ id,
+ text,
+ profile!!.currentSemester,
+ Notice.TYPE_NEUTRAL,
+ teacherId
+ )
+
+ data.noticeList.add(noticeObject)
+ data.metadataList.add(Metadata(
+ profileId,
+ Metadata.TYPE_NOTICE,
+ id,
+ profile?.empty ?: false,
+ profile?.empty ?: false,
+ addedDate
+ ))
+ }
+
+ data.setSyncNext(ENDPOINT_VULCAN_API_NOTICES, SYNC_ALWAYS)
+ onSuccess()
+ }
+ }
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1fb474fa..3deb4994 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -954,4 +954,5 @@
Pobieranie słowników...
Synchronizuję...
[%d%%] %s
+ Pobieranie uwag...