mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 19:04:38 -06:00
[Vulcan/Hebe] Add getting attachments in homework.
This commit is contained in:
parent
d0baf02750
commit
459bbf78b2
@ -200,6 +200,14 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getEvent(eventFull: EventFull) {
|
override fun getEvent(eventFull: EventFull) {
|
||||||
|
if (loginStore.mode != LOGIN_MODE_VULCAN_API) {
|
||||||
|
eventFull.homeworkBody = ""
|
||||||
|
|
||||||
|
EventBus.getDefault().postSticky(EventGetEvent(eventFull))
|
||||||
|
completed()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
login(LOGIN_METHOD_VULCAN_API) {
|
login(LOGIN_METHOD_VULCAN_API) {
|
||||||
val list = data.app.db.eventDao().getAllNow(data.profileId).filter { !it.addedManually }
|
val list = data.app.db.eventDao().getAllNow(data.profileId).filter { !it.addedManually }
|
||||||
VulcanApiAttachments(data, list, eventFull, EventFull::class) { _ ->
|
VulcanApiAttachments(data, list, eventFull, EventFull::class) { _ ->
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.hebe
|
package pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.hebe
|
||||||
|
|
||||||
|
import pl.szczodrzynski.edziennik.asJsonObjectList
|
||||||
import pl.szczodrzynski.edziennik.data.api.VULCAN_HEBE_ENDPOINT_HOMEWORK
|
import pl.szczodrzynski.edziennik.data.api.VULCAN_HEBE_ENDPOINT_HOMEWORK
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.DataVulcan
|
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.DataVulcan
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.ENDPOINT_VULCAN_HEBE_HOMEWORK
|
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.ENDPOINT_VULCAN_HEBE_HOMEWORK
|
||||||
@ -11,8 +12,10 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.VulcanHebe
|
|||||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||||
|
import pl.szczodrzynski.edziennik.getJsonArray
|
||||||
import pl.szczodrzynski.edziennik.getLong
|
import pl.szczodrzynski.edziennik.getLong
|
||||||
import pl.szczodrzynski.edziennik.getString
|
import pl.szczodrzynski.edziennik.getString
|
||||||
|
import pl.szczodrzynski.edziennik.utils.Utils
|
||||||
|
|
||||||
class VulcanHebeHomework(
|
class VulcanHebeHomework(
|
||||||
override val data: DataVulcan,
|
override val data: DataVulcan,
|
||||||
@ -56,6 +59,22 @@ class VulcanHebeHomework(
|
|||||||
teamId = teamId
|
teamId = teamId
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val attachments = exam.getJsonArray("Attachments")
|
||||||
|
?.asJsonObjectList()
|
||||||
|
?: return@forEach
|
||||||
|
|
||||||
|
for (attachment in attachments) {
|
||||||
|
val fileName = attachment.getString("Name") ?: continue
|
||||||
|
val url = attachment.getString("Link") ?: continue
|
||||||
|
val attachmentName = "$fileName:$url"
|
||||||
|
val attachmentId = Utils.crc32(attachmentName.toByteArray())
|
||||||
|
|
||||||
|
eventObject.addAttachment(
|
||||||
|
id = attachmentId,
|
||||||
|
name = attachmentName
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
data.eventList.add(eventObject)
|
data.eventList.add(eventObject)
|
||||||
data.metadataList.add(
|
data.metadataList.add(
|
||||||
Metadata(
|
Metadata(
|
||||||
|
@ -93,6 +93,25 @@ open class Event(
|
|||||||
var attachmentIds: MutableList<Long>? = null
|
var attachmentIds: MutableList<Long>? = null
|
||||||
var attachmentNames: MutableList<String>? = null
|
var attachmentNames: MutableList<String>? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an attachment
|
||||||
|
* @param id attachment ID
|
||||||
|
* @param name file name incl. extension
|
||||||
|
* @return a Event to which the attachment has been added
|
||||||
|
*/
|
||||||
|
fun addAttachment(id: Long, name: String): Event {
|
||||||
|
if (attachmentIds == null) attachmentIds = mutableListOf()
|
||||||
|
if (attachmentNames == null) attachmentNames = mutableListOf()
|
||||||
|
attachmentIds?.add(id)
|
||||||
|
attachmentNames?.add(name)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearAttachments() {
|
||||||
|
attachmentIds = null
|
||||||
|
attachmentNames = null
|
||||||
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
var showAsUnseen: Boolean? = null
|
var showAsUnseen: Boolean? = null
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user