mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-27 06:30:29 +00:00
apply some refactoring recommendations
This commit is contained in:
parent
02f55a0cba
commit
91dfbccad4
4 changed files with 26 additions and 28 deletions
|
@ -25,13 +25,13 @@ data class ConferenceDto(
|
|||
val conferenceID: Long
|
||||
get() = getIdFromUrl()
|
||||
|
||||
val eventsByTags: Map<String, List<EventDto>> by lazy { getEventsMap(events) }
|
||||
val sensibleTags: Set<String>
|
||||
private val eventsByTags: Map<String, List<EventDto>> by lazy { getEventsMap(events) }
|
||||
private val sensibleTags: Set<String>
|
||||
val tagsUsefull: Boolean
|
||||
|
||||
init {
|
||||
sensibleTags = ConferenceUtil.getSensibleTags(eventsByTags.keys, acronym)
|
||||
tagsUsefull = sensibleTags.size > 0
|
||||
tagsUsefull = sensibleTags.isNotEmpty()
|
||||
}
|
||||
|
||||
private fun getEventsMap(events: List<EventDto>?): Map<String, List<EventDto>> {
|
||||
|
@ -39,15 +39,15 @@ data class ConferenceDto(
|
|||
val untagged = ArrayList<EventDto>()
|
||||
if (events != null) {
|
||||
for (event in events) {
|
||||
if (event.tags?.isNotEmpty() ?: false) {
|
||||
if (event.tags?.isNotEmpty() == true) {
|
||||
for (tag in event.tags!!) {
|
||||
|
||||
val list: MutableList<EventDto>
|
||||
if (map.keys.contains(tag)) {
|
||||
list = map[tag]!!
|
||||
} else {
|
||||
list = ArrayList<EventDto>()
|
||||
map.put(tag, list)
|
||||
list = ArrayList()
|
||||
map[tag] = list
|
||||
}
|
||||
list.add(event)
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ data class ConferenceDto(
|
|||
}
|
||||
}
|
||||
if (untagged.size > 0) {
|
||||
map.put("untagged", untagged)
|
||||
map["untagged"] = untagged
|
||||
}
|
||||
}
|
||||
return map
|
||||
|
|
|
@ -12,11 +12,11 @@ import android.text.Spanned
|
|||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.EventDto
|
||||
|
||||
@Entity(tableName = "event",
|
||||
foreignKeys = arrayOf(ForeignKey(
|
||||
entity = Conference::class,
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
parentColumns = (arrayOf("id")),
|
||||
childColumns = arrayOf("conferenceId"))),
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = Conference::class,
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
parentColumns = (arrayOf("id")),
|
||||
childColumns = arrayOf("conferenceId"))],
|
||||
indices = [
|
||||
Index("guid", unique = true),
|
||||
Index("frontendLink"),
|
||||
|
@ -82,8 +82,7 @@ data class Event(
|
|||
parcel.createStringArray(),
|
||||
parcel.createStringArray(),
|
||||
parcel.createTypedArrayList(RelatedEvent),
|
||||
parcel.createTypedArrayList(Recording)) {
|
||||
}
|
||||
parcel.createTypedArrayList(Recording))
|
||||
|
||||
@Ignore
|
||||
constructor(event: EventDto, conferenceId: Long = 0) : this(
|
||||
|
|
|
@ -10,15 +10,17 @@ import android.os.Parcelable
|
|||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.RecordingDto
|
||||
|
||||
@Entity(tableName = "recording",
|
||||
foreignKeys = arrayOf(ForeignKey(
|
||||
entity = Event::class,
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
parentColumns = (arrayOf("id")),
|
||||
childColumns = arrayOf("eventId"))),
|
||||
indices = arrayOf(
|
||||
Index("eventId"),
|
||||
Index("url", unique = true),
|
||||
Index("backendId", unique = true)))
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = Event::class,
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
parentColumns = ([("id")]),
|
||||
childColumns = ["eventId"])],
|
||||
indices = [
|
||||
Index("eventId"),
|
||||
Index("url", unique = true),
|
||||
Index("backendId", unique = true)
|
||||
]
|
||||
)
|
||||
data class Recording(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var id: Long = 0,
|
||||
|
@ -60,8 +62,7 @@ data class Recording(
|
|||
parcel.readString() ?: "",
|
||||
parcel.readString() ?: "",
|
||||
parcel.readString() ?: "",
|
||||
parcel.readLong()) {
|
||||
}
|
||||
parcel.readLong())
|
||||
|
||||
@Ignore
|
||||
constructor(rec: RecordingDto, eventId: Long = 0) : this(
|
||||
|
|
|
@ -188,9 +188,7 @@ class Downloader(
|
|||
val conferenceId = database.conferenceDao().findConferenceByAcronymSync(acronym)?.id
|
||||
?: updateConferencesAndGet(acronym)
|
||||
|
||||
if (conferenceId == -1L) {
|
||||
throw IllegalStateException("Could not find Conference for event")
|
||||
}
|
||||
check(conferenceId != -1L) { "Could not find Conference for event" }
|
||||
|
||||
val persistentEvent = Event(event, conferenceId)
|
||||
val id = database.eventDao().insert(persistentEvent)
|
||||
|
|
Loading…
Reference in a new issue