mirror of
https://github.com/NiciDieNase/chaosflix
synced 2025-02-17 05:28:24 +00:00
Common: fix saving of recordings
This commit is contained in:
parent
23e224ae73
commit
823bf90031
2 changed files with 10 additions and 9 deletions
|
@ -23,13 +23,12 @@ data class RecordingDto(
|
|||
@SerializedName("event_url")
|
||||
var eventUrl: String = "",
|
||||
@SerializedName("conference_url")
|
||||
var conferenceUrl: String = "",
|
||||
var recordingID: Long
|
||||
var conferenceUrl: String = ""
|
||||
) {
|
||||
|
||||
init {
|
||||
val recordingID: Long
|
||||
get() {
|
||||
val strings = url.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
recordingID = (strings[strings.size - 1]).toLong()
|
||||
return (strings[strings.size - 1]).toLong()
|
||||
}
|
||||
|
||||
fun getEventString():String {
|
||||
|
|
|
@ -2,7 +2,6 @@ package de.nicidienase.chaosflix.common.mediadata.sync
|
|||
|
||||
import android.arch.lifecycle.LiveData
|
||||
import de.nicidienase.chaosflix.common.ChaosflixDatabase
|
||||
import de.nicidienase.chaosflix.common.ChaosflixUtil
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.ConferenceDto
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.ConferencesWrapper
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.EventDto
|
||||
|
@ -105,10 +104,13 @@ class Downloader(private val recordingApi: RecordingService,
|
|||
return@runOnBackgroundThread
|
||||
}
|
||||
try {
|
||||
val recordings = response.body()?.recordings?.let { recordings ->
|
||||
return@let saveRecordings(event, recordings)
|
||||
val recordingDtos = response.body()?.recordings
|
||||
if(recordingDtos != null){
|
||||
val recordings: List<Recording> = saveRecordings(event, recordingDtos)
|
||||
updateState.postValue(LiveEvent(DownloaderState.DONE, data = recordings))
|
||||
} else {
|
||||
updateState.postValue(LiveEvent(DownloaderState.DONE))
|
||||
}
|
||||
updateState.postValue(LiveEvent(DownloaderState.DONE, data = recordings))
|
||||
} catch (e: Exception){
|
||||
updateState.postValue(LiveEvent(DownloaderState.DONE, error = "Error updating Recordings for ${event.title}"))
|
||||
e.printStackTrace()}
|
||||
|
|
Loading…
Add table
Reference in a new issue