Common: refactor Item and Dto Names

This commit is contained in:
Felix 2018-12-14 21:58:16 +01:00
parent dd4eb23251
commit 9c32a72766
45 changed files with 332 additions and 339 deletions

View file

@ -10,10 +10,10 @@ import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.ConferenceGroup
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.ConferenceGroupDao
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.EventDao
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRelatedEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.RelatedEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.RecordingDao
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.RelatedEventDao
import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEvent
@ -24,10 +24,10 @@ import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItemDao
@Database(entities = arrayOf(
PersistentConference::class,
PersistentEvent::class,
PersistentRecording::class,
PersistentRelatedEvent::class,
Conference::class,
Event::class,
Recording::class,
RelatedEvent::class,
ConferenceGroup::class,
PlaybackProgress::class,

View file

@ -1,12 +1,12 @@
package de.nicidienase.chaosflix.common
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
import java.util.*
import kotlin.collections.ArrayList
object ChaosflixUtil {
fun getOptimalRecording(recordings: List<PersistentRecording>): PersistentRecording? {
val result = ArrayList<PersistentRecording>()
fun getOptimalRecording(recordings: List<Recording>): Recording? {
val result = ArrayList<Recording>()
result.addAll(recordings.filter { it.isHighQuality && it.mimeType == "video/mp4" }.sortedBy { it.language.length })
result.addAll(recordings.filter { !it.isHighQuality && it.mimeType == "video/mp4" }.sortedBy { it.language.length })

View file

@ -14,8 +14,8 @@ import android.net.Uri
import android.os.Environment
import android.preference.PreferenceManager
import android.util.Log
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEvent
import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEventDao
import de.nicidienase.chaosflix.common.util.ThreadHandler
@ -88,7 +88,7 @@ class OfflineItemManager(context: Context,
}
}
fun download(event: PersistentEvent, recording: PersistentRecording): LiveData<Boolean> {
fun download(event: Event, recording: Recording): LiveData<Boolean> {
val result = MutableLiveData<Boolean>()
handler.runOnBackgroundThread {

View file

@ -3,7 +3,7 @@ package de.nicidienase.chaosflix.common.mediadata.entities.recording
import com.google.gson.annotations.SerializedName;
data class Conference(
data class ConferenceDto(
@SerializedName("acronym") var acronym: String = "",
@SerializedName("aspect_ratio") var aspectRatio: String = "",
@SerializedName("updated_at") var updatedAt: String = "",
@ -16,14 +16,14 @@ data class Conference(
@SerializedName("images_url") var imagesUrl: String = "",
@SerializedName("recordings_url") var recordingsUrl: String = "",
@SerializedName("url") var url: String = "",
@SerializedName("events") var events: List<Event>?
@SerializedName("events") var events: List<EventDto>?
) : Comparable<Conference> {
) : Comparable<ConferenceDto> {
val conferenceID: Long
get() = getIdFromUrl()
val eventsByTags: Map<String, List<Event>>
val eventsByTags: Map<String, List<EventDto>>
get() = getEventsMap(events)
val sensibleTags: Set<String>
val tagsUsefull: Boolean
@ -33,19 +33,19 @@ data class Conference(
tagsUsefull = sensibleTags.size > 0
}
private fun getEventsMap(events: List<Event>?): Map<String,List<Event>>{
val map = HashMap<String, MutableList<Event>>()
val untagged = ArrayList<Event>()
private fun getEventsMap(events: List<EventDto>?): Map<String,List<EventDto>>{
val map = HashMap<String, MutableList<EventDto>>()
val untagged = ArrayList<EventDto>()
if (events != null) {
for (event in events) {
if (event.tags?.isNotEmpty() ?: false) {
for (tag in event.tags!!) {
val list: MutableList<Event>
val list: MutableList<EventDto>
if (map.keys.contains(tag)) {
list = map[tag]!!
} else {
list = ArrayList<Event>()
list = ArrayList<EventDto>()
map.put(tag, list)
}
list.add(event)
@ -82,7 +82,7 @@ data class Conference(
return hashSet
}
override fun compareTo(other: Conference): Int {
override fun compareTo(other: ConferenceDto): Int {
return slug.compareTo(other.slug)
}
}

View file

@ -4,14 +4,14 @@ import java.util.*
import kotlin.collections.HashMap
data class ConferencesWrapper(var conferences: List<Conference>) {
data class ConferencesWrapper(var conferences: List<ConferenceDto>) {
val conferencesMap: Map<String, List<Conference>>
val conferencesMap: Map<String, List<ConferenceDto>>
get() = generateConferencesMap()
private fun generateConferencesMap(): HashMap<String, MutableList<Conference>> {
val map = HashMap<String,MutableList<Conference>>()
private fun generateConferencesMap(): HashMap<String, MutableList<ConferenceDto>> {
val map = HashMap<String,MutableList<ConferenceDto>>()
for (conference in conferences) {
val split = conference.slug.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
when (split[0]) {
@ -58,11 +58,11 @@ data class ConferencesWrapper(var conferences: List<Conference>) {
return map
}
private fun getListForTag(map: MutableMap<String,MutableList<Conference>>, s: String): MutableList<Conference> {
private fun getListForTag(map: MutableMap<String,MutableList<ConferenceDto>>, s: String): MutableList<ConferenceDto> {
if (map.keys.contains(s)) {
return map[s]!!
} else {
val list = ArrayList<Conference>()
val list = ArrayList<ConferenceDto>()
map.put(s, list)
return list
}

View file

@ -2,38 +2,38 @@ package de.nicidienase.chaosflix.common.mediadata.entities.recording
import com.google.gson.annotations.SerializedName
data class Event(@SerializedName("conference_id")
data class EventDto(@SerializedName("conference_id")
var conferenceId: Long = 0,
var guid: String = "",
var title: String = "",
var subtitle: String? = "",
var slug: String = "",
var link: String? = "",
var description: String? = "",
@SerializedName("original_language")
var guid: String = "",
var title: String = "",
var subtitle: String? = "",
var slug: String = "",
var link: String? = "",
var description: String? = "",
@SerializedName("original_language")
var originalLanguage: String = "",
var persons: Array<String>?,
var tags: Array<String>?,
var date: String? = "",
@SerializedName("release_date")
var persons: Array<String>?,
var tags: Array<String>?,
var date: String? = "",
@SerializedName("release_date")
var releaseDate: String = "",
@SerializedName("updated_at")
@SerializedName("updated_at")
var updatedAt: String = "",
var length: Long = 0,
@SerializedName("thumb_url")
var length: Long = 0,
@SerializedName("thumb_url")
var thumbUrl: String = "",
@SerializedName("poster_url")
@SerializedName("poster_url")
var posterUrl: String = "",
@SerializedName("frontend_link")
@SerializedName("frontend_link")
var frontendLink: String? = "",
var url: String = "",
@SerializedName("conference_url")
var url: String = "",
@SerializedName("conference_url")
var conferenceUrl: String = "",
var recordings: List<Recording>?,
var related: List<RelatedEvent>?,
@SerializedName("promoted")
var recordings: List<RecordingDto>?,
var related: List<RelatedEventDto>?,
@SerializedName("promoted")
var isPromoted: Boolean = false
) : Comparable<Event> {
) : Comparable<EventDto> {
var eventID: Long
@SerializedName("view_count")
@ -57,12 +57,12 @@ data class Event(@SerializedName("conference_id")
fun getSpeakerString(): String?
= persons?.joinToString(", ")
override fun compareTo(other: Event): Int {
override fun compareTo(other: EventDto): Int {
return slug.compareTo(other.slug)
}
override fun equals(other: Any?): Boolean {
return if (other is Event) {
return if (other is EventDto) {
guid == other.guid
} else {
super.equals(other)

View file

@ -2,7 +2,7 @@ package de.nicidienase.chaosflix.common.mediadata.entities.recording
import com.google.gson.annotations.SerializedName;
data class Recording(
data class RecordingDto(
var size: Int = 0,
var length: Int = 0,
@SerializedName("mime_type")

View file

@ -4,7 +4,7 @@ import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
open class RelatedEvent(
open class RelatedEventDto(
@SerializedName("event_guid") var eventGuid: String,
@SerializedName("weight") var weight: Int) : Parcelable {
constructor(parcel: Parcel) : this(
@ -21,12 +21,12 @@ open class RelatedEvent(
return 0
}
companion object CREATOR : Parcelable.Creator<RelatedEvent> {
override fun createFromParcel(parcel: Parcel): RelatedEvent {
return RelatedEvent(parcel)
companion object CREATOR : Parcelable.Creator<RelatedEventDto> {
override fun createFromParcel(parcel: Parcel): RelatedEventDto {
return RelatedEventDto(parcel)
}
override fun newArray(size: Int): Array<RelatedEvent?> {
override fun newArray(size: Int): Array<RelatedEventDto?> {
return arrayOfNulls(size)
}
}

View file

@ -6,11 +6,11 @@ import android.arch.persistence.room.Index
import android.arch.persistence.room.PrimaryKey
import android.os.Parcel
import android.os.Parcelable
import de.nicidienase.chaosflix.common.mediadata.entities.recording.Conference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.ConferenceDto
@Entity(tableName = "conference",
indices = [Index(value = ["acronym"], unique = true)])
data class PersistentConference(
data class Conference(
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var conferenceGroupId: Long = 0,
@ -27,7 +27,7 @@ data class PersistentConference(
var updatedAt: String = "",
var tagsUsefull: Boolean = false,
var lastReleasedAt: String = ""
) : Parcelable, Comparable<PersistentConference> {
) : Parcelable, Comparable<Conference> {
@Ignore
constructor(parcel: Parcel) : this(
@ -49,7 +49,7 @@ data class PersistentConference(
}
@Ignore
constructor(con: Conference) : this(
constructor(con: ConferenceDto) : this(
acronym = con.acronym,
aspectRatio = con.aspectRatio,
title = con.title,
@ -64,7 +64,7 @@ data class PersistentConference(
tagsUsefull = con.tagsUsefull,
lastReleasedAt = con.lastReleaseAt ?: "")
override fun compareTo(other: PersistentConference) = lastReleasedAt.compareTo(other.lastReleasedAt) * -1
override fun compareTo(other: Conference) = lastReleasedAt.compareTo(other.lastReleasedAt) * -1
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeLong(id)
@ -88,12 +88,12 @@ data class PersistentConference(
return 0
}
companion object CREATOR : Parcelable.Creator<PersistentConference> {
override fun createFromParcel(parcel: Parcel): PersistentConference {
return PersistentConference(parcel)
companion object CREATOR : Parcelable.Creator<Conference> {
override fun createFromParcel(parcel: Parcel): Conference {
return Conference(parcel)
}
override fun newArray(size: Int): Array<PersistentConference?> {
override fun newArray(size: Int): Array<Conference?> {
return arrayOfNulls(size)
}
}

View file

@ -5,28 +5,28 @@ import android.arch.persistence.room.Dao
import android.arch.persistence.room.Query
@Dao
abstract class ConferenceDao : BaseDao<PersistentConference>() {
abstract class ConferenceDao : BaseDao<Conference>() {
@Query("SELECT * FROM conference")
abstract fun getAllConferences(): LiveData<List<PersistentConference>>
abstract fun getAllConferences(): LiveData<List<Conference>>
@Query("SELECT * FROM conference WHERE title LIKE :search")
abstract fun findConferenceByTitle(search: String): LiveData<List<PersistentConference>>
abstract fun findConferenceByTitle(search: String): LiveData<List<Conference>>
@Query("SELECT * FROM conference WHERE id = :id LIMIT 1")
abstract fun findConferenceById(id: Long): LiveData<PersistentConference>
abstract fun findConferenceById(id: Long): LiveData<Conference>
@Query("SELECT * FROM conference WHERE acronym = :acronym LIMIT 1")
abstract fun findConferenceByAcronymSync(acronym: String): PersistentConference?
abstract fun findConferenceByAcronymSync(acronym: String): Conference?
@Query("SELECT * FROM conference WHERE conferenceGroupId = :id ORDER BY acronym DESC")
abstract fun findConferenceByGroup(id: Long): LiveData<List<PersistentConference>>
abstract fun findConferenceByGroup(id: Long): LiveData<List<Conference>>
@Query("DELETE FROM conference")
abstract fun delete()
override fun updateOrInsertInternal(item: PersistentConference) {
override fun updateOrInsertInternal(item: Conference) {
if (item.id != 0L) {
update(item)
} else {

View file

@ -9,11 +9,11 @@ import android.os.Parcel
import android.os.Parcelable
import android.text.Html
import android.text.Spanned
import de.nicidienase.chaosflix.common.mediadata.entities.recording.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.EventDto
@Entity(tableName = "event",
foreignKeys = arrayOf(ForeignKey(
entity = PersistentConference::class,
entity = Conference::class,
onDelete = ForeignKey.CASCADE,
parentColumns = (arrayOf("id")),
childColumns = arrayOf("conferenceId"))),
@ -22,7 +22,7 @@ import de.nicidienase.chaosflix.common.mediadata.entities.recording.Event
Index("frontendLink"),
Index("conferenceId")])
data class PersistentEvent(
data class Event(
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var conferenceId: Long = 0,
@ -50,12 +50,12 @@ data class PersistentEvent(
var tags: Array<String>? = null,
@Ignore
var related: List<PersistentRelatedEvent>? = null,
var related: List<RelatedEvent>? = null,
@Ignore
var recordings: List<PersistentRecording>? = null
) : Parcelable, Comparable<PersistentEvent> {
var recordings: List<Recording>? = null
) : Parcelable, Comparable<Event> {
override fun compareTo(other: PersistentEvent): Int = title.compareTo(other.title)
override fun compareTo(other: Event): Int = title.compareTo(other.title)
constructor(parcel: Parcel) : this(
parcel.readLong(),
@ -81,12 +81,12 @@ data class PersistentEvent(
parcel.readInt(),
parcel.createStringArray(),
parcel.createStringArray(),
parcel.createTypedArrayList(PersistentRelatedEvent),
parcel.createTypedArrayList(PersistentRecording)) {
parcel.createTypedArrayList(RelatedEvent),
parcel.createTypedArrayList(Recording)) {
}
@Ignore
constructor(event: Event,conferenceId: Long = 0) : this(
constructor(event: EventDto, conferenceId: Long = 0) : this(
conferenceId = conferenceId,
guid = event.guid,
title = event.title,
@ -107,8 +107,8 @@ data class PersistentEvent(
viewCount = event.viewCount,
persons = event.persons,
tags = event.tags,
related = event.related?.map { PersistentRelatedEvent(event.eventID,it) },
recordings = event.recordings?.map { PersistentRecording(it) }
related = event.related?.map { RelatedEvent(event.eventID,it) },
recordings = event.recordings?.map { Recording(it) }
)
fun getExtendedDescription(): Spanned {
@ -156,12 +156,12 @@ data class PersistentEvent(
return 0
}
companion object CREATOR : Parcelable.Creator<PersistentEvent> {
override fun createFromParcel(parcel: Parcel): PersistentEvent {
return PersistentEvent(parcel)
companion object CREATOR : Parcelable.Creator<Event> {
override fun createFromParcel(parcel: Parcel): Event {
return Event(parcel)
}
override fun newArray(size: Int): Array<PersistentEvent?> {
override fun newArray(size: Int): Array<Event?> {
return arrayOfNulls(size)
}
}

View file

@ -4,57 +4,57 @@ import android.arch.lifecycle.LiveData
import android.arch.persistence.room.*
@Dao
abstract class EventDao: BaseDao<PersistentEvent>() {
abstract class EventDao: BaseDao<Event>() {
@Query("SELECT * FROM event")
abstract fun getAllEvents(): LiveData<List<PersistentEvent>>
abstract fun getAllEvents(): LiveData<List<Event>>
@Query("SELECT * FROM event")
abstract fun getAllEventsSync(): List<PersistentEvent>
abstract fun getAllEventsSync(): List<Event>
@Query("SELECT * FROM event WHERE title LIKE :search ORDER BY title ASC")
abstract fun findEventByTitle(search: String): LiveData<PersistentEvent?>
abstract fun findEventByTitle(search: String): LiveData<Event?>
@Query("SELECT * FROM event WHERE id = :id ORDER BY title ASC")
abstract fun findEventById(id: Long): LiveData<PersistentEvent?>
abstract fun findEventById(id: Long): LiveData<Event?>
@Query("SELECT * FROM event WHERE guid = :guid LIMIT 1")
abstract fun findEventByGuid(guid: String): LiveData<PersistentEvent?>
abstract fun findEventByGuid(guid: String): LiveData<Event?>
@Query("SELECT * FROM event WHERE guid = :guid LIMIT 1")
abstract fun findEventByGuidSync(guid: String): PersistentEvent?
abstract fun findEventByGuidSync(guid: String): Event?
@Query("SELECT * FROM event WHERE id in (:ids)")
abstract fun findEventsByIds(ids: LongArray): LiveData<List<PersistentEvent>>
abstract fun findEventsByIds(ids: LongArray): LiveData<List<Event>>
@Query("SELECT * FROM event WHERE guid in (:ids)")
abstract fun findEventsByGUIDs(ids: List<String>): LiveData<List<PersistentEvent>>
abstract fun findEventsByGUIDs(ids: List<String>): LiveData<List<Event>>
@Query("SELECT * FROM event WHERE guid in (:guids)")
abstract fun findEventsByGUIDsSync(guids: List<String>): List<PersistentEvent>
abstract fun findEventsByGUIDsSync(guids: List<String>): List<Event>
@Query("SELECT * FROM event WHERE isPromoted IS 1")
abstract fun findPromotedEvents(): LiveData<List<PersistentEvent>>
abstract fun findPromotedEvents(): LiveData<List<Event>>
@Query("SELECT * FROM event WHERE conferenceId = :id ORDER BY title ASC")
abstract fun findEventsByConference(id: Long):LiveData<List<PersistentEvent>>
abstract fun findEventsByConference(id: Long):LiveData<List<Event>>
@Query("SELECT * FROM event WHERE conferenceId = :id ORDER BY title ASC")
abstract fun findEventsByConferenceSync(id: Long):List<PersistentEvent>
abstract fun findEventsByConferenceSync(id: Long):List<Event>
@Query("SELECT * FROM event INNER JOIN watchlist_item WHERE event.guid = watchlist_item.event_guid")
abstract fun findBookmarkedEvents(): LiveData<List<PersistentEvent>>
abstract fun findBookmarkedEvents(): LiveData<List<Event>>
@Query("SELECT * FROM event INNER JOIN playback_progress WHERE event.guid = playback_progress.event_guid")
abstract fun findInProgressEvents(): LiveData<List<PersistentEvent>>
abstract fun findInProgressEvents(): LiveData<List<Event>>
@Query("SELECT * FROM event WHERE frontendLink = :url ")
abstract fun findEventsByFrontendurl(url: String):LiveData<PersistentEvent?>
abstract fun findEventsByFrontendurl(url: String):LiveData<Event?>
@Query("DElETE FROM event")
abstract fun delete()
override fun updateOrInsertInternal(item: PersistentEvent) {
override fun updateOrInsertInternal(item: Event) {
if (item.id != 0L) {
update(item)
} else {

View file

@ -7,11 +7,11 @@ import android.arch.persistence.room.Index
import android.arch.persistence.room.PrimaryKey
import android.os.Parcel
import android.os.Parcelable
import de.nicidienase.chaosflix.common.mediadata.entities.recording.Recording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.RecordingDto
@Entity(tableName = "recording",
foreignKeys = arrayOf(ForeignKey(
entity = PersistentEvent::class,
entity = Event::class,
onDelete = ForeignKey.CASCADE,
parentColumns = (arrayOf("id")),
childColumns = arrayOf("eventId"))),
@ -19,7 +19,7 @@ import de.nicidienase.chaosflix.common.mediadata.entities.recording.Recording
Index("eventId"),
Index("url", unique = true),
Index("backendId", unique = true)))
data class PersistentRecording(
data class Recording(
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var eventId: Long = 0,
@ -64,7 +64,7 @@ data class PersistentRecording(
}
@Ignore
constructor(rec: Recording, eventId: Long = 0) : this(
constructor(rec: RecordingDto, eventId: Long = 0) : this(
eventId = eventId,
size = rec.size,
length = rec.length,
@ -108,12 +108,12 @@ data class PersistentRecording(
return 0
}
companion object CREATOR : Parcelable.Creator<PersistentRecording> {
override fun createFromParcel(parcel: Parcel): PersistentRecording {
return PersistentRecording(parcel)
companion object CREATOR : Parcelable.Creator<Recording> {
override fun createFromParcel(parcel: Parcel): Recording {
return Recording(parcel)
}
override fun newArray(size: Int): Array<PersistentRecording?> {
override fun newArray(size: Int): Array<Recording?> {
return arrayOfNulls(size)
}
}

View file

@ -5,22 +5,22 @@ import android.arch.persistence.room.Dao
import android.arch.persistence.room.Query
@Dao
abstract class RecordingDao: BaseDao<PersistentRecording>() {
abstract class RecordingDao: BaseDao<Recording>() {
@Query("SELECT * FROM recording")
abstract fun getAllRecordings(): LiveData<List<PersistentRecording>>
abstract fun getAllRecordings(): LiveData<List<Recording>>
@Query("SELECT * FROM recording WHERE id = :id LIMIT 1")
abstract fun findRecordingById(id: Long): LiveData<PersistentRecording>
abstract fun findRecordingById(id: Long): LiveData<Recording>
@Query("SELECT * FROM recording WHERE eventId = :id")
abstract fun findRecordingByEvent(id: Long): LiveData<List<PersistentRecording>>
abstract fun findRecordingByEvent(id: Long): LiveData<List<Recording>>
@Query("SELECT * FROM recording WHERE eventId = :id")
abstract fun findRecordingByEventSync(id: Long): List<PersistentRecording>
abstract fun findRecordingByEventSync(id: Long): List<Recording>
@Query("SELECT * FROM recording WHERE backendId = :backendId")
abstract fun findRecordingByBackendIdSync(backendId: Long): PersistentRecording?
abstract fun findRecordingByBackendIdSync(backendId: Long): Recording?
@Query("DELETE FROM recording WHERE eventId = :eventId")
abstract fun deleteRecordingsForEvent(eventId: Long)
@ -28,7 +28,7 @@ abstract class RecordingDao: BaseDao<PersistentRecording>() {
@Query("DElETE FROM recording")
abstract fun delete()
override fun updateOrInsertInternal(item: PersistentRecording) {
override fun updateOrInsertInternal(item: Recording) {
if (item.id != 0L) {
update(item)
} else {

View file

@ -7,11 +7,11 @@ import android.arch.persistence.room.Index
import android.arch.persistence.room.PrimaryKey
import android.os.Parcel
import android.os.Parcelable
import de.nicidienase.chaosflix.common.mediadata.entities.recording.RelatedEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.RelatedEventDto
@Entity(tableName = "related",
foreignKeys = arrayOf(ForeignKey(
entity = PersistentEvent::class,
entity = Event::class,
onDelete = ForeignKey.CASCADE,
parentColumns = arrayOf("id"),
childColumns = arrayOf("parentEventId"))),
@ -19,7 +19,7 @@ import de.nicidienase.chaosflix.common.mediadata.entities.recording.RelatedEvent
)
class PersistentRelatedEvent(
class RelatedEvent(
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var parentEventId: Long,
@ -34,7 +34,7 @@ class PersistentRelatedEvent(
}
@Ignore
constructor(parentEventId: Long, relatedEvent: RelatedEvent): this(
constructor(parentEventId: Long, relatedEvent: RelatedEventDto): this(
parentEventId= parentEventId,
relatedEventGuid = relatedEvent.eventGuid,
weight = relatedEvent.weight)
@ -50,12 +50,12 @@ class PersistentRelatedEvent(
return 0
}
companion object CREATOR : Parcelable.Creator<PersistentRelatedEvent> {
override fun createFromParcel(parcel: Parcel): PersistentRelatedEvent {
return PersistentRelatedEvent(parcel)
companion object CREATOR : Parcelable.Creator<RelatedEvent> {
override fun createFromParcel(parcel: Parcel): RelatedEvent {
return RelatedEvent(parcel)
}
override fun newArray(size: Int): Array<PersistentRelatedEvent?> {
override fun newArray(size: Int): Array<RelatedEvent?> {
return arrayOfNulls(size)
}
}

View file

@ -5,20 +5,20 @@ import android.arch.persistence.room.Dao
import android.arch.persistence.room.Query
@Dao
abstract class RelatedEventDao : BaseDao<PersistentRelatedEvent>() {
abstract class RelatedEventDao : BaseDao<RelatedEvent>() {
@Query("SELECT * FROM related WHERE parentEventId = :id")
abstract fun getRelatedEventsForEvent(id: Long): LiveData<List<PersistentRelatedEvent>>
abstract fun getRelatedEventsForEvent(id: Long): LiveData<List<RelatedEvent>>
@Query("SELECT * FROM related WHERE parentEventId = :id")
abstract fun getRelatedEventsForEventSync(id: Long): List<PersistentRelatedEvent>
abstract fun getRelatedEventsForEventSync(id: Long): List<RelatedEvent>
@Query("SELECT * FROM related WHERE parentEventId = :parentId AND relatedEventGuid = :related")
abstract fun findSpecificRelatedEventSync(parentId: Long, related: String): PersistentRelatedEvent?
abstract fun findSpecificRelatedEventSync(parentId: Long, related: String): RelatedEvent?
@Query("DElETE FROM related")
abstract fun delete()
override fun updateOrInsertInternal(item: PersistentRelatedEvent) {
override fun updateOrInsertInternal(item: RelatedEvent) {
if (item.id != 0L) {
update(item)
} else {

View file

@ -1,9 +1,9 @@
package de.nicidienase.chaosflix.common.mediadata.network
import de.nicidienase.chaosflix.common.mediadata.entities.recording.Conference
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.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.Recording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.EventDto
import de.nicidienase.chaosflix.common.mediadata.entities.recording.RecordingDto
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Path
@ -14,18 +14,18 @@ interface RecordingService {
fun getConferencesWrapper(): Call<ConferencesWrapper>
@GET("public/conferences/{id}")
fun getConference(@Path("id") id: Long): Call<Conference>
fun getConference(@Path("id") id: Long): Call<ConferenceDto>
@GET("public/conferences/{name}")
fun getConferenceByName(@Path("name") name: String): Call<Conference>
fun getConferenceByName(@Path("name") name: String): Call<ConferenceDto>
@GET("public/events/{id}")
fun getEvent(@Path("id") id: Long): Call<Event>
fun getEvent(@Path("id") id: Long): Call<EventDto>
@GET("public/events/{guid}")
fun getEventByGUID(@Path("guid") guid: String): Call<Event>
fun getEventByGUID(@Path("guid") guid: String): Call<EventDto>
@GET("public/recordings/{id}")
fun getRecording(@Path("id") id: Long): Call<Recording>
fun getRecording(@Path("id") id: Long): Call<RecordingDto>
}

View file

@ -3,8 +3,8 @@ package de.nicidienase.chaosflix.common.mediadata.sync
import android.content.Intent
import android.support.v4.app.JobIntentService
import de.nicidienase.chaosflix.common.DatabaseFactory
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.network.ApiFactory
class DownloadJobService : JobIntentService() {
@ -19,12 +19,12 @@ class DownloadJobService : JobIntentService() {
when (entityType) {
ENTITY_KEY_CONFERENCES -> downloader.updateConferencesAndGroups()
ENTITY_KEY_EVENTS -> {
val item = intent.getParcelableExtra<PersistentConference>(ITEM_KEY)
downloader.updateEventsForConference(item as PersistentConference)
val item = intent.getParcelableExtra<Conference>(ITEM_KEY)
downloader.updateEventsForConference(item as Conference)
}
ENTITY_KEY_RECORDINGS -> {
val item = intent.getParcelableExtra<PersistentEvent>(ITEM_KEY)
downloader.updateRecordingsForEvent(item as PersistentEvent)
val item = intent.getParcelableExtra<Event>(ITEM_KEY)
downloader.updateRecordingsForEvent(item as Event)
}
}
}

View file

@ -3,15 +3,15 @@ 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.Conference
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.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.Recording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.EventDto
import de.nicidienase.chaosflix.common.mediadata.entities.recording.RecordingDto
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.ConferenceGroup
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRelatedEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.RelatedEvent
import de.nicidienase.chaosflix.common.mediadata.network.RecordingService
import de.nicidienase.chaosflix.common.util.LiveEvent
import de.nicidienase.chaosflix.common.util.SingleLiveEvent
@ -28,8 +28,8 @@ class Downloader(private val recordingApi: RecordingService,
RUNNING, DONE
}
fun updateConferencesAndGroups(): LiveData<LiveEvent<DownloaderState, List<PersistentConference>, String>> {
val updateState = SingleLiveEvent<LiveEvent<DownloaderState, List<PersistentConference>, String>>()
fun updateConferencesAndGroups(): LiveData<LiveEvent<DownloaderState, List<Conference>, String>> {
val updateState = SingleLiveEvent<LiveEvent<DownloaderState, List<Conference>, String>>()
threadHandler.runOnBackgroundThread {
updateState.postValue(LiveEvent(DownloaderState.RUNNING,null, null))
val response: Response<ConferencesWrapper>?
@ -59,11 +59,11 @@ class Downloader(private val recordingApi: RecordingService,
private val TAG: String? = Downloader::class.simpleName
fun updateEventsForConference(conference: PersistentConference) : LiveData<LiveEvent<DownloaderState, List<PersistentEvent>, String>> {
val updateState = SingleLiveEvent<LiveEvent<DownloaderState, List<PersistentEvent>, String>>()
fun updateEventsForConference(conference: Conference) : LiveData<LiveEvent<DownloaderState, List<Event>, String>> {
val updateState = SingleLiveEvent<LiveEvent<DownloaderState, List<Event>, String>>()
updateState.postValue(LiveEvent(DownloaderState.RUNNING))
threadHandler.runOnBackgroundThread {
val response: Response<Conference>?
val response: Response<ConferenceDto>?
try {
response = recordingApi.getConferenceByName(conference.acronym).execute()
} catch (e: IOException){
@ -87,12 +87,12 @@ class Downloader(private val recordingApi: RecordingService,
return updateState
}
fun updateRecordingsForEvent(event: PersistentEvent) :
LiveData<LiveEvent<DownloaderState, List<PersistentRecording>, String>> {
val updateState = SingleLiveEvent<LiveEvent<DownloaderState, List<PersistentRecording>, String>>()
fun updateRecordingsForEvent(event: Event) :
LiveData<LiveEvent<DownloaderState, List<Recording>, String>> {
val updateState = SingleLiveEvent<LiveEvent<DownloaderState, List<Recording>, String>>()
updateState.postValue(LiveEvent(DownloaderState.RUNNING))
threadHandler.runOnBackgroundThread {
val response: Response<Event>?
val response: Response<EventDto>?
try {
response = recordingApi.getEventByGUID(event.guid).execute()
} catch (e: IOException){
@ -115,8 +115,8 @@ class Downloader(private val recordingApi: RecordingService,
return updateState
}
fun updateSingleEvent(guid: String): PersistentEvent? {
val request: Response<Event>?
fun updateSingleEvent(guid: String): Event? {
val request: Response<EventDto>?
try {
request = recordingApi.getEventByGUID(guid).execute()
} catch (e: IOException){
@ -144,11 +144,11 @@ class Downloader(private val recordingApi: RecordingService,
}
private fun saveConferences(conferencesWrapper: ConferencesWrapper): List<PersistentConference> {
private fun saveConferences(conferencesWrapper: ConferencesWrapper): List<Conference> {
return conferencesWrapper.conferencesMap.map { entry ->
val conferenceGroup: ConferenceGroup = getOrCreateConferenceGroup(entry.key)
val conferenceList = entry.value
.map { PersistentConference(it) }
.map { Conference(it) }
.map { it.conferenceGroupId = conferenceGroup.id; it }
database.conferenceDao().updateOrInsert(*conferenceList.toTypedArray())
database.conferenceGroupDao().deleteEmptyGroups()
@ -172,8 +172,8 @@ class Downloader(private val recordingApi: RecordingService,
return group
}
private fun saveEvents(persistentConference: PersistentConference, events: List<Event>): List<PersistentEvent> {
val persistantEvents = events.map { PersistentEvent(it,persistentConference.id) }
private fun saveEvents(persistentConference: Conference, events: List<EventDto>): List<Event> {
val persistantEvents = events.map { Event(it,persistentConference.id) }
database.eventDao().updateOrInsert(*persistantEvents.toTypedArray())
persistantEvents.forEach{
saveRelatedEvents(it)
@ -181,7 +181,7 @@ class Downloader(private val recordingApi: RecordingService,
return persistantEvents
}
private fun saveEvent(event: Event): PersistentEvent {
private fun saveEvent(event: EventDto): Event {
val split = event.conferenceUrl.split("/")
val acronym = split[split.size - 1]
val conferenceId = database.conferenceDao().findConferenceByAcronymSync(acronym)?.id
@ -191,7 +191,7 @@ class Downloader(private val recordingApi: RecordingService,
throw IllegalStateException("Could not find Conference for event")
}
val persistentEvent = PersistentEvent(event, conferenceId)
val persistentEvent = Event(event, conferenceId)
val id = database.eventDao().insert(persistentEvent)
persistentEvent.id = id
return persistentEvent
@ -205,14 +205,14 @@ class Downloader(private val recordingApi: RecordingService,
return conferences?.find { it.acronym == acronym }?.id ?: -1
}
private fun saveRelatedEvents(event: PersistentEvent): List<PersistentRelatedEvent> {
private fun saveRelatedEvents(event: Event): List<RelatedEvent> {
val list = event.related?.map { it.parentEventId = event.id; it }
database.relatedEventDao().updateOrInsert(*list?.toTypedArray()?: emptyArray())
return list ?: emptyList()
}
private fun saveRecordings(event: PersistentEvent,recordings: List<Recording>): List<PersistentRecording> {
val persistentRecordings = recordings.map { PersistentRecording(it, event.id) }
private fun saveRecordings(event: Event, recordings: List<RecordingDto>): List<Recording> {
val persistentRecordings = recordings.map { Recording(it, event.id) }
database.recordingDao().updateOrInsert(*persistentRecordings.toTypedArray())
return persistentRecordings
}

View file

@ -7,8 +7,8 @@ import android.arch.persistence.room.Index
import android.arch.persistence.room.PrimaryKey
import android.os.Parcel
import android.os.Parcelable
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
@Entity(tableName = "offline_event",
indices = arrayOf(Index(value = ["event_guid"], unique = true)))
@ -19,8 +19,8 @@ data class OfflineEvent(
@ColumnInfo(name = "download_reference") var downloadReference: Long,
@ColumnInfo(name = "local_path") var localPath: String) : Parcelable {
@Ignore var event: PersistentEvent? = null
@Ignore var recording: PersistentRecording? = null
@Ignore var event: Event? = null
@Ignore var recording: Recording? = null
constructor(parcel: Parcel) : this(
parcel.readLong(),
@ -28,8 +28,8 @@ data class OfflineEvent(
parcel.readLong(),
parcel.readLong(),
parcel.readString() ?: "") {
event = parcel.readParcelable(PersistentEvent::class.java.classLoader)
recording = parcel.readParcelable(PersistentRecording::class.java.classLoader)
event = parcel.readParcelable(Event::class.java.classLoader)
recording = parcel.readParcelable(Recording::class.java.classLoader)
}
override fun writeToParcel(parcel: Parcel, flags: Int) {

View file

@ -7,8 +7,8 @@ import de.nicidienase.chaosflix.common.ChaosflixDatabase
import de.nicidienase.chaosflix.common.OfflineItemManager
import de.nicidienase.chaosflix.common.PreferencesManager
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.ConferenceGroup
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.LiveConference
import de.nicidienase.chaosflix.common.mediadata.network.RecordingService
import de.nicidienase.chaosflix.common.mediadata.network.StreamingService
@ -49,30 +49,30 @@ class BrowseViewModel(
fun getConferencesByGroup(groupId: Long)
= database.conferenceDao().findConferenceByGroup(groupId)
fun getEventsforConference(conference: PersistentConference)
fun getEventsforConference(conference: Conference)
= database.eventDao().findEventsByConference(conference.id)
fun updateConferences()
= downloader.updateConferencesAndGroups()
fun updateEventsForConference(conference: PersistentConference)
fun updateEventsForConference(conference: Conference)
= downloader.updateEventsForConference(conference)
fun getBookmarkedEvents(): LiveData<List<PersistentEvent>> = updateAndGetEventsForGuids {
fun getBookmarkedEvents(): LiveData<List<Event>> = updateAndGetEventsForGuids {
database
.watchlistItemDao()
.getAllSync().map { it.eventGuid } }
fun getInProgressEvents(): LiveData<List<PersistentEvent>> = updateAndGetEventsForGuids {
fun getInProgressEvents(): LiveData<List<Event>> = updateAndGetEventsForGuids {
database
.playbackProgressDao()
.getAllSync()
.map { it.eventGuid } }
fun getPromotedEvents(): LiveData<List<PersistentEvent>> = database.eventDao().findPromotedEvents()
fun getPromotedEvents(): LiveData<List<Event>> = database.eventDao().findPromotedEvents()
private fun updateAndGetEventsForGuids(guidProvider: ()->List<String>):LiveData<List<PersistentEvent>>{
val result = MutableLiveData<List<PersistentEvent>>()
private fun updateAndGetEventsForGuids(guidProvider: ()->List<String>):LiveData<List<Event>>{
val result = MutableLiveData<List<Event>>()
handler.runOnBackgroundThread {
val guids = guidProvider.invoke()
val events = guids.map { downloader.updateSingleEvent(it) }.filterNotNull()
@ -103,23 +103,23 @@ class BrowseViewModel(
return result
}
fun getOfflineEvents(): LiveData<List<Pair<OfflineEvent,PersistentEvent>>> {
val result = MutableLiveData<List<Pair<OfflineEvent, PersistentEvent>>>()
fun getOfflineEvents(): LiveData<List<Pair<OfflineEvent,Event>>> {
val result = MutableLiveData<List<Pair<OfflineEvent, Event>>>()
handler.runOnBackgroundThread {
val offlineEventMap = database.offlineEventDao().getAllSync()
.map { it.eventGuid to it }.toMap()
val persistentEventMap = database.eventDao().findEventsByGUIDsSync(offlineEventMap.keys.toList())
.map { it.guid to it }.toMap()
val resultList = ArrayList<Pair<OfflineEvent, PersistentEvent>>()
val resultList = ArrayList<Pair<OfflineEvent, Event>>()
for (key in offlineEventMap.keys){
val offlineEvent = offlineEventMap[key]
var persistentEvent: PersistentEvent? = persistentEventMap[key]
if(persistentEvent == null){
persistentEvent = downloader.updateSingleEvent(key)
var event: Event? = persistentEventMap[key]
if(event == null){
event = downloader.updateSingleEvent(key)
}
if(persistentEvent != null && offlineEvent != null){
resultList.add(Pair(offlineEvent, persistentEvent))
if(event != null && offlineEvent != null){
resultList.add(Pair(offlineEvent, event))
}
}
result.postValue(resultList)

View file

@ -7,8 +7,8 @@ import android.os.Bundle
import de.nicidienase.chaosflix.common.ChaosflixDatabase
import de.nicidienase.chaosflix.common.OfflineItemManager
import de.nicidienase.chaosflix.common.PreferencesManager
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
import de.nicidienase.chaosflix.common.mediadata.sync.Downloader
import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
import de.nicidienase.chaosflix.common.util.LiveEvent
@ -30,14 +30,14 @@ class DetailsViewModel(
private val handler = ThreadHandler()
fun setEvent(persistentEvent: PersistentEvent): LiveData<PersistentEvent?> {
downloader.updateRecordingsForEvent(persistentEvent)
return database.eventDao().findEventByGuid(persistentEvent.guid)
fun setEvent(event: Event): LiveData<Event?> {
downloader.updateRecordingsForEvent(event)
return database.eventDao().findEventByGuid(event.guid)
}
fun getRecordingForEvent(persistentEvent: PersistentEvent): LiveData<List<PersistentRecording>> {
downloader.updateRecordingsForEvent(persistentEvent)
return database.recordingDao().findRecordingByEvent(persistentEvent.id)
fun getRecordingForEvent(event: Event): LiveData<List<Recording>> {
downloader.updateRecordingsForEvent(event)
return database.recordingDao().findRecordingByEvent(event.id)
}
fun getBookmarkForEvent(guid: String): LiveData<WatchlistItem?> =
@ -55,7 +55,7 @@ class DetailsViewModel(
}
}
fun download(event: PersistentEvent, recording: PersistentRecording)
fun download(event: Event, recording: Recording)
= offlineItemManager.download(event, recording)
private fun fileExists(guid: String): Boolean {
@ -63,7 +63,7 @@ class DetailsViewModel(
return offlineItem != null && File(offlineItem.localPath).exists()
}
fun deleteOfflineItem(event: PersistentEvent): LiveData<Boolean> {
fun deleteOfflineItem(event: Event): LiveData<Boolean> {
val result = MutableLiveData<Boolean>()
handler.runOnBackgroundThread {
database.offlineEventDao().getByEventGuidSync(event.guid)?.let {
@ -74,8 +74,8 @@ class DetailsViewModel(
return result
}
fun getRelatedEvents(event: PersistentEvent): LiveData<List<PersistentEvent>>{
val data = MutableLiveData<List<PersistentEvent>>()
fun getRelatedEvents(event: Event): LiveData<List<Event>>{
val data = MutableLiveData<List<Event>>()
handler.runOnBackgroundThread {
val guids = database.relatedEventDao().getRelatedEventsForEventSync(event.id).map { it.relatedEventGuid }
data.postValue(database.eventDao().findEventsByGUIDsSync(guids))
@ -83,7 +83,7 @@ class DetailsViewModel(
return data
}
fun playEvent(event: PersistentEvent) {
fun playEvent(event: Event) {
handler.runOnBackgroundThread {
val offlineEvent = database.offlineEventDao().getByEventGuidSync(event.guid)
@ -106,13 +106,13 @@ class DetailsViewModel(
}
}
fun playRecording(recording: PersistentRecording){
fun playRecording(recording: Recording){
val bundle = Bundle()
bundle.putParcelable(KEY_PLAY_RECORDING, recording)
state.postValue(LiveEvent(DetailsViewModelState.PlayOnlineItem, data = bundle))
}
fun offlineItemExists(event: PersistentEvent): LiveData<Boolean> {
fun offlineItemExists(event: Event): LiveData<Boolean> {
val liveData = MutableLiveData<Boolean>()
handler.runOnBackgroundThread {
database.offlineEventDao().getByEventGuidSync(event.guid)

View file

@ -25,9 +25,8 @@ import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import de.nicidienase.chaosflix.leanback.R;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event;
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.LiveConference;
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.Room;
@ -83,15 +82,15 @@ public class CardPresenter extends Presenter {
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
ImageCardView cardView = (ImageCardView) viewHolder.view;
cardView.setMainImageScaleType(ImageView.ScaleType.FIT_CENTER);
if (item instanceof PersistentConference) {
PersistentConference conference = (PersistentConference) item;
if (item instanceof Conference) {
Conference conference = (Conference) item;
cardView.setTitleText(conference.getTitle());
cardView.setContentText(conference.getAcronym());
if (conference.getLogoUrl() != null) {
loadImage(viewHolder.view.getContext(),conference.getLogoUrl(), cardView.getMainImageView());
}
} else if (item instanceof PersistentEvent) {
PersistentEvent event = (PersistentEvent) item;
} else if (item instanceof Event) {
Event event = (Event) item;
cardView.setTitleText(event.getTitle());
cardView.setContentText(event.getSubtitle());
// cardView.setContentText(android.text.TextUtils.join(", ",event.getPersons()));

View file

@ -2,7 +2,7 @@ package de.nicidienase.chaosflix.leanback
import android.support.v17.leanback.widget.ArrayObjectAdapter
import android.support.v17.leanback.widget.Presenter
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
class ChaosflixEventAdapter(presenter: Presenter): ArrayObjectAdapter(presenter) {
@ -12,7 +12,7 @@ class ChaosflixEventAdapter(presenter: Presenter): ArrayObjectAdapter(presenter)
override fun getId(position: Int): Long {
val item = get(position)
return if(item is PersistentEvent){
return if(item is Event){
item.id
} else {
-1;

View file

@ -7,7 +7,7 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.Room
import de.nicidienase.chaosflix.leanback.databinding.DetailViewBinding
@ -23,7 +23,7 @@ class EventDetailsDescriptionPresenter(private val context: Context) : Presenter
throw IllegalStateException("Wrong ViewHolder")
}
val dataHolder: DetailDataHolder
if (item is PersistentEvent) {
if (item is Event) {
val sb = StringBuilder()
val speaker = TextUtils.join(", ", item.persons ?: emptyArray())
sb.append(item.description)
@ -51,7 +51,7 @@ class EventDetailsDescriptionPresenter(private val context: Context) : Presenter
inner class DetailDataHolder internal constructor(val title: String, val subtitle: String?, val speakers: String, val description: String) {
internal constructor(event: PersistentEvent) : this(
internal constructor(event: Event) : this(
event.title,
event.subtitle,
TextUtils.join(", ", event.persons!!),

View file

@ -11,8 +11,8 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event;
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.Room;
import de.nicidienase.chaosflix.leanback.activities.DetailsActivity;
import de.nicidienase.chaosflix.leanback.activities.EventsActivity;
@ -30,18 +30,18 @@ public class ItemViewClickedListener implements OnItemViewClickedListener {
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
Log.d(TAG, "onItemClicked");
FragmentActivity activity = fragment.requireActivity();
if (item instanceof PersistentConference) {
PersistentConference conference = (PersistentConference) item;
if (item instanceof Conference) {
Conference conference = (Conference) item;
Bundle transition = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
((ImageCardView) itemViewHolder.view).getMainImageView(),
EventsActivity.Companion.getSHARED_ELEMENT_NAME()).toBundle();
EventsActivity.start(fragment.requireContext(), conference, transition);
// EventsActivity.start(fragment.requireContext(),conference);
} else if (item instanceof PersistentEvent) {
} else if (item instanceof Event) {
Bundle transistion = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
((ImageCardView) itemViewHolder.view).getMainImageView(),
DetailsActivity.Companion.getSHARED_ELEMENT_NAME()).toBundle();
PersistentEvent event = (PersistentEvent) item;
Event event = (Event) item;
DetailsActivity.start(fragment.requireContext(), event, transistion);
} else if (item instanceof Room) {
Bundle transition = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,

View file

@ -4,10 +4,9 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.FragmentActivity
import android.support.v7.app.AppCompatActivity
import android.view.WindowManager
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.Room
import de.nicidienase.chaosflix.leanback.R
@ -44,7 +43,7 @@ class DetailsActivity : FragmentActivity() {
val TYPE_STREAM = 1
@JvmStatic
fun start(context: Context, event: PersistentEvent, transition: Bundle? = null){
fun start(context: Context, event: Event, transition: Bundle? = null){
val i = Intent(context, DetailsActivity::class.java)
i.putExtra(DetailsActivity.TYPE, DetailsActivity.TYPE_RECORDING)
i.putExtra(DetailsActivity.EVENT, event)

View file

@ -4,14 +4,14 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.FragmentActivity
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.leanback.R
class EventsActivity : FragmentActivity() {
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val conference = intent.getParcelableExtra<PersistentConference>(CONFERENCE)
val conference = intent.getParcelableExtra<Conference>(CONFERENCE)
if (conference.tagsUsefull) {
// TODO determin if we should use a Browse or a Grid layout
}
@ -26,7 +26,7 @@ class EventsActivity : FragmentActivity() {
@JvmStatic
@JvmOverloads
fun start(context: Context, conference: PersistentConference, transition: Bundle? = null) {
fun start(context: Context, conference: Conference, transition: Bundle? = null) {
val i = Intent(context, EventsActivity::class.java)
i.putExtra(EventsActivity.CONFERENCE, conference)
if (transition != null) {

View file

@ -24,8 +24,8 @@ import de.nicidienase.chaosflix.BuildConfig;
import de.nicidienase.chaosflix.leanback.ChaosflixEventAdapter;
import de.nicidienase.chaosflix.leanback.R;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.ConferenceGroup;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event;
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.Group;
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.LiveConference;
import de.nicidienase.chaosflix.common.util.ConferenceUtil;
@ -54,15 +54,15 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
private BrowseViewModel viewModel;
private Map<String, ListRow> conferencesGroupRows = new HashMap<>();
private DiffCallback<PersistentEvent> eventDiffCallback = new DiffCallback<PersistentEvent>() {
private Map<String, ListRow> conferencesGroupRows = new HashMap<>();
private DiffCallback<Event> eventDiffCallback = new DiffCallback<Event>() {
@Override
public boolean areItemsTheSame(@NonNull PersistentEvent oldItem, @NonNull PersistentEvent newItem) {
public boolean areItemsTheSame(@NonNull Event oldItem, @NonNull Event newItem) {
return oldItem.getGuid().equals(newItem.getGuid());
}
@Override
public boolean areContentsTheSame(@NonNull PersistentEvent oldItem, @NonNull PersistentEvent newItem) {
public boolean areContentsTheSame(@NonNull Event oldItem, @NonNull Event newItem) {
return oldItem.getGuid().equals(newItem.getGuid());
}
};
@ -103,8 +103,8 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
conferencesSection = new SectionRow(new HeaderItem(getString(R.string.conferences)));
// Streams
// rowsAdapter.add(0, streamingSection);
// rowsAdapter.add(streamsDivider);
rowsAdapter.add(0, streamingSection);
rowsAdapter.add(streamsDivider);
// Recomendations
Row promotedRow = new ListRow(new HeaderItem("Promoted"), promotedAdapter);
@ -183,11 +183,8 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
viewModel.getLivestreams().observe(this, liveConferences -> {
if (liveConferences != null) {
// if (BuildConfig.DEBUG) {
// liveConferences.add(LiveConference.getDummyObject());
// }
addStreams(eventPresenter, liveConferences);
// errorFragment.dismiss();
}
});
}
@ -197,14 +194,14 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
if(conferences != null){
Collections.sort(conferences);
}
((ArrayObjectAdapter) row.getAdapter()).setItems(conferences, new DiffCallback<PersistentConference>() {
((ArrayObjectAdapter) row.getAdapter()).setItems(conferences, new DiffCallback<Conference>() {
@Override
public boolean areItemsTheSame(@NonNull PersistentConference oldItem, @NonNull PersistentConference newItem) {
public boolean areItemsTheSame(@NonNull Conference oldItem, @NonNull Conference newItem) {
return oldItem.getUrl().equals(newItem.getUrl());
}
@Override
public boolean areContentsTheSame(@NonNull PersistentConference oldItem, @NonNull PersistentConference newItem) {
public boolean areContentsTheSame(@NonNull Conference oldItem, @NonNull Conference newItem) {
return oldItem.getUpdatedAt().equals(newItem.getUpdatedAt());
}
});
@ -239,7 +236,7 @@ public class ConferencesBrowseFragment extends BrowseSupportFragment {
}
}
private ListRow buildRow(List<PersistentConference> conferences, CardPresenter cardPresenter, String tag, String description) {
private ListRow buildRow(List<Conference> conferences, CardPresenter cardPresenter, String tag, String description) {
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
listRowAdapter.addAll(0, conferences);
HeaderItem header = new HeaderItem(ConferenceUtil.getStringForTag(tag));

View file

@ -51,7 +51,7 @@ import com.google.android.exoplayer2.upstream.HttpDataSource
import com.google.android.exoplayer2.util.Util
import de.nicidienase.chaosflix.leanback.R
import de.nicidienase.chaosflix.common.ChaosflixUtil
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.Room
import de.nicidienase.chaosflix.common.viewmodel.DetailsViewModel
import de.nicidienase.chaosflix.common.viewmodel.PlayerViewModel
@ -66,7 +66,7 @@ class EventDetailsFragment : DetailsSupportFragment() {
private lateinit var detailsViewModel: DetailsViewModel
private lateinit var playerViewModel: PlayerViewModel
private var event: PersistentEvent? = null
private var event: Event? = null
private var room: Room? = null
private lateinit var rowsAdapter: ArrayObjectAdapter
@ -130,7 +130,7 @@ class EventDetailsFragment : DetailsSupportFragment() {
Handler().postDelayed(this::startEntranceTransition, 500);
}
private fun onCreateRecording(event: PersistentEvent, rowsAdapter: ArrayObjectAdapter) {
private fun onCreateRecording(event: Event, rowsAdapter: ArrayObjectAdapter) {
val detailsOverview = DetailsOverviewRow(event)
val actionAdapter = ArrayObjectAdapter()

View file

@ -23,8 +23,8 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.sync.Downloader
import de.nicidienase.chaosflix.common.viewmodel.BrowseViewModel
import de.nicidienase.chaosflix.common.viewmodel.ViewModelFactory
@ -66,7 +66,7 @@ class EventsBrowseFragment : BrowseSupportFragment() {
val conference = this.activity
?.intent
?.getParcelableExtra<PersistentConference>(EventsActivity.CONFERENCE)
?.getParcelableExtra<Conference>(EventsActivity.CONFERENCE)
if (conference == null) {
throw IllegalStateException("No conference passed")
}
@ -126,9 +126,9 @@ class EventsBrowseFragment : BrowseSupportFragment() {
}
}
private fun getEventsByTags(events: List<PersistentEvent>, conferenceAcronym: String): Map<String, List<PersistentEvent>> {
val eventsByTags = HashMap<String, MutableList<PersistentEvent>>()
val other = LinkedList<PersistentEvent>()
private fun getEventsByTags(events: List<Event>, conferenceAcronym: String): Map<String, List<Event>> {
val eventsByTags = HashMap<String, MutableList<Event>>()
val other = LinkedList<Event>()
for (event in events) {
val tags: List<String> = event
.tags
@ -151,7 +151,7 @@ class EventsBrowseFragment : BrowseSupportFragment() {
return eventsByTags
}
private fun updateRowForTag(cardPresenter: CardPresenter, tag: String, items: List<PersistentEvent>): Row {
private fun updateRowForTag(cardPresenter: CardPresenter, tag: String, items: List<Event>): Row {
var row = eventRows[tag]
val header: HeaderItem
val listRowAdapter: ArrayObjectAdapter
@ -165,12 +165,12 @@ class EventsBrowseFragment : BrowseSupportFragment() {
listRowAdapter = row.adapter as ArrayObjectAdapter
}
Collections.sort(items)
listRowAdapter.setItems(items, object : DiffCallback<PersistentEvent>() {
override fun areItemsTheSame(oldItem: PersistentEvent, newItem: PersistentEvent): Boolean {
listRowAdapter.setItems(items, object : DiffCallback<Event>() {
override fun areItemsTheSame(oldItem: Event, newItem: Event): Boolean {
return oldItem.guid == newItem.guid
}
override fun areContentsTheSame(oldItem: PersistentEvent, newItem: PersistentEvent): Boolean {
override fun areContentsTheSame(oldItem: Event, newItem: Event): Boolean {
return oldItem.title == newItem.title
}
@ -185,7 +185,7 @@ class EventsBrowseFragment : BrowseSupportFragment() {
activity?.windowManager?.defaultDisplay?.getMetrics(metrics)
}
private fun setupUIElements(conference: PersistentConference) {
private fun setupUIElements(conference: Conference) {
loadImage(conference.logoUrl, this::setBadgeDrawable)
title = conference.title // Badge, when set, takes precedent
@ -232,7 +232,7 @@ class EventsBrowseFragment : BrowseSupportFragment() {
private inner class ItemViewSelectedListener : OnItemViewSelectedListener {
override fun onItemSelected(itemViewHolder: Presenter.ViewHolder, item: Any,
rowViewHolder: RowPresenter.ViewHolder, row: Row) {
if (item is PersistentEvent) {
if (item is Event) {
try {
backgroundURI = URI(item.posterUrl)
} catch (e: URISyntaxException) {

View file

@ -1,7 +1,7 @@
package de.nicidienase.chaosflix.touch
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
interface OnEventSelectedListener {
fun onEventSelected(event: PersistentEvent);
fun onEventSelected(event: Event);
}

View file

@ -20,8 +20,8 @@ import android.view.MenuItem
import android.view.View
import android.widget.Toast
import de.nicidienase.chaosflix.touch.R
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.StreamUrl
import de.nicidienase.chaosflix.common.viewmodel.BrowseViewModel
import de.nicidienase.chaosflix.common.viewmodel.ViewModelFactory
@ -130,7 +130,7 @@ class BrowseActivity : AppCompatActivity(),
return super.onOptionsItemSelected(item)
}
override fun onConferenceSelected(conference: PersistentConference) {
override fun onConferenceSelected(conference: Conference) {
EventsListActivity.start(this, conference)
}
@ -237,7 +237,7 @@ class BrowseActivity : AppCompatActivity(),
ft.commit()
}
override fun onEventSelected(event: PersistentEvent) {
override fun onEventSelected(event: Event) {
EventDetailsActivity.launch(this, event)
}

View file

@ -8,10 +8,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.jetbrains.annotations.NotNull;
import de.nicidienase.chaosflix.R;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference;
import de.nicidienase.chaosflix.touch.databinding.FragmentTabPagerLayoutBinding;
import de.nicidienase.chaosflix.touch.browse.adapters.ConferenceGroupsFragmentPager;
@ -122,6 +120,6 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
}
public interface OnInteractionListener {
void onConferenceSelected(PersistentConference conference);
void onConferenceSelected(Conference conference);
}
}

View file

@ -1,19 +1,19 @@
package de.nicidienase.chaosflix.touch.browse.adapters
import com.squareup.picasso.Picasso
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.touch.R
import de.nicidienase.chaosflix.touch.browse.ConferencesTabBrowseFragment
import java.util.*
class ConferenceRecyclerViewAdapter(private val mListener: ConferencesTabBrowseFragment.OnInteractionListener?) : ItemRecyclerViewAdapter<PersistentConference>() {
override fun getFilteredProperties(item: PersistentConference): List<String> {
class ConferenceRecyclerViewAdapter(private val mListener: ConferencesTabBrowseFragment.OnInteractionListener?) : ItemRecyclerViewAdapter<Conference>() {
override fun getFilteredProperties(item: Conference): List<String> {
return listOf(item.title)
}
override val layout = R.layout.item_conference_cardview
override fun getComparator(): Comparator<in PersistentConference>? {
override fun getComparator(): Comparator<in Conference>? {
// return Comparator { o1, o2 -> o1.acronym.compareTo(o2.acronym) * -1 }
return null
}
@ -22,7 +22,7 @@ class ConferenceRecyclerViewAdapter(private val mListener: ConferencesTabBrowseF
return items.get(position).id
}
override fun onBindViewHolder(holder: ItemRecyclerViewAdapter<PersistentConference>.ViewHolder, position: Int) {
override fun onBindViewHolder(holder: ItemRecyclerViewAdapter<Conference>.ViewHolder, position: Int) {
holder.titleText.setText(items[position].title)
holder.subtitle.setText(items[position].acronym)
Picasso.with(holder.icon.context)

View file

@ -4,14 +4,14 @@ import android.support.v4.view.ViewCompat
import android.view.View
import com.squareup.picasso.Picasso
import de.nicidienase.chaosflix.touch.R
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.touch.OnEventSelectedListener
import java.util.*
open class EventRecyclerViewAdapter(val listener: OnEventSelectedListener) :
ItemRecyclerViewAdapter<PersistentEvent>() {
ItemRecyclerViewAdapter<Event>() {
override fun getComparator(): Comparator<in PersistentEvent>? {
override fun getComparator(): Comparator<in Event>? {
return Comparator { o1, o2 -> o1.title.compareTo(o2.title) }
}
@ -19,7 +19,7 @@ open class EventRecyclerViewAdapter(val listener: OnEventSelectedListener) :
return items.get(position).id
}
override fun getFilteredProperties(item: PersistentEvent): List<String> {
override fun getFilteredProperties(item: Event): List<String> {
return listOf(item.title,
item.subtitle,
item.description,
@ -31,7 +31,7 @@ open class EventRecyclerViewAdapter(val listener: OnEventSelectedListener) :
override val layout = R.layout.item_event_cardview
var showTags: Boolean = false
override fun onBindViewHolder(holder: ItemRecyclerViewAdapter<PersistentEvent>.ViewHolder, position: Int) {
override fun onBindViewHolder(holder: ItemRecyclerViewAdapter<Event>.ViewHolder, position: Int) {
val event = items[position]
holder.titleText.text = event.title

View file

@ -7,13 +7,13 @@ import android.view.View
import android.view.ViewGroup
import com.squareup.picasso.Picasso
import de.nicidienase.chaosflix.touch.R
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEvent
import de.nicidienase.chaosflix.touch.databinding.ItemOfflineEventBinding
import de.nicidienase.chaosflix.touch.OnEventSelectedListener
import de.nicidienase.chaosflix.common.viewmodel.BrowseViewModel
class OfflineEventAdapter(var items: List<Pair<OfflineEvent, PersistentEvent>>, val viewModel: BrowseViewModel, val listener: OnEventSelectedListener) :
class OfflineEventAdapter(var items: List<Pair<OfflineEvent, Event>>, val viewModel: BrowseViewModel, val listener: OnEventSelectedListener) :
RecyclerView.Adapter<OfflineEventAdapter.ViewHolder>() {
override fun onBindViewHolder(holder: OfflineEventAdapter.ViewHolder, position: Int) {

View file

@ -5,8 +5,8 @@ import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import de.nicidienase.chaosflix.touch.R
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.touch.OnEventSelectedListener
import de.nicidienase.chaosflix.touch.eventdetails.EventDetailsActivity
@ -19,7 +19,7 @@ class EventsListActivity : AppCompatActivity(), OnEventSelectedListener {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_events_list)
val conference = intent.getParcelableExtra<PersistentConference>(CONFERENCE_KEY)
val conference = intent.getParcelableExtra<Conference>(CONFERENCE_KEY)
if (savedInstanceState == null) {
val eventsListFragment = EventsListFragment.newInstance(EventsListFragment.TYPE_EVENTS, conference, numColumns)
@ -30,14 +30,14 @@ class EventsListActivity : AppCompatActivity(), OnEventSelectedListener {
}
}
override fun onEventSelected(event: PersistentEvent) {
override fun onEventSelected(event: Event) {
EventDetailsActivity.launch(this, event)
}
companion object {
val CONFERENCE_KEY = "conference_id"
fun start(context: Context, conference: PersistentConference) {
fun start(context: Context, conference: Conference) {
val i = Intent(context, EventsListActivity::class.java)
i.putExtra(CONFERENCE_KEY, conference)
context.startActivity(i)

View file

@ -21,8 +21,8 @@ import android.widget.SearchView;
import java.util.List;
import de.nicidienase.chaosflix.touch.R;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentConference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference;
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event;
import de.nicidienase.chaosflix.common.mediadata.sync.Downloader;
import de.nicidienase.chaosflix.touch.OnEventSelectedListener;
import de.nicidienase.chaosflix.touch.browse.BrowseFragment;
@ -45,13 +45,13 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
private OnEventSelectedListener listener;
private EventRecyclerViewAdapter eventAdapter;
private PersistentConference conference;
private Conference conference;
private LinearLayoutManager layoutManager;
private Snackbar snackbar;
private int type;
public static EventsListFragment newInstance(int type, PersistentConference conference, int columnCount) {
public static EventsListFragment newInstance(int type, Conference conference, int columnCount) {
EventsListFragment fragment = new EventsListFragment();
Bundle args = new Bundle();
args.putInt(ARG_TYPE, type);
@ -101,7 +101,7 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
eventAdapter.setHasStableIds(true);
binding.list.setAdapter(eventAdapter);
Observer<List<PersistentEvent>> listObserver = persistentEvents -> {
Observer<List<Event>> listObserver = persistentEvents -> {
if (persistentEvents != null) {
setEvents(persistentEvents);
if (persistentEvents.size() > 0) {
@ -151,8 +151,8 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ
snackbar.show();
}
private void setEvents(List<PersistentEvent> persistentEvents) {
eventAdapter.setItems(persistentEvents);
private void setEvents(List<Event> events) {
eventAdapter.setItems(events);
Parcelable layoutState = getArguments().getParcelable(LAYOUTMANAGER_STATE);
if (layoutState != null) { layoutManager.onRestoreInstanceState(layoutState); }

View file

@ -10,8 +10,8 @@ import android.os.Bundle
import android.support.v4.app.ActivityCompat
import android.support.v7.app.AppCompatActivity
import de.nicidienase.chaosflix.touch.R
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
import de.nicidienase.chaosflix.common.viewmodel.DetailsViewModel
import de.nicidienase.chaosflix.touch.OnEventSelectedListener
import de.nicidienase.chaosflix.common.viewmodel.ViewModelFactory
@ -30,7 +30,7 @@ class EventDetailsActivity : AppCompatActivity(),
viewModel = ViewModelProviders.of(this, ViewModelFactory(this)).get(DetailsViewModel::class.java)
viewModel.writeExternalStorageAllowed = hasWriteStoragePermission()
val event = intent.getParcelableExtra<PersistentEvent>(EXTRA_EVENT)
val event = intent.getParcelableExtra<Event>(EXTRA_EVENT)
showFragmentForEvent(event)
if (!ActivityCompat.shouldShowRequestPermissionRationale(this,
@ -39,7 +39,7 @@ class EventDetailsActivity : AppCompatActivity(),
}
}
private fun showFragmentForEvent(event: PersistentEvent, addToBackStack: Boolean = false) {
private fun showFragmentForEvent(event: Event, addToBackStack: Boolean = false) {
val detailsFragment = EventDetailsFragment.newInstance(event)
detailsFragment.allowEnterTransitionOverlap = true
@ -55,7 +55,7 @@ class EventDetailsActivity : AppCompatActivity(),
ft.commit()
}
override fun onEventSelected(event: PersistentEvent) {
override fun onEventSelected(event: Event) {
showFragmentForEvent(event, true)
}
@ -63,11 +63,11 @@ class EventDetailsActivity : AppCompatActivity(),
invalidateOptionsMenu()
}
override fun playItem(event: PersistentEvent, recording: PersistentRecording) {
override fun playItem(event: Event, recording: Recording) {
PlayerActivity.launch(this, event, recording)
}
override fun playItem(event: PersistentEvent, uri: String) {
override fun playItem(event: Event, uri: String) {
PlayerActivity.launch(this, event, uri)
}
@ -98,7 +98,7 @@ class EventDetailsActivity : AppCompatActivity(),
private val EXTRA_EVENT = "extra_event"
private val EXTRA_URI = "extra_uri"
fun launch(context: Context, event: PersistentEvent) {
fun launch(context: Context, event: Event) {
val intent = Intent(context, EventDetailsActivity::class.java)
intent.putExtra(EXTRA_EVENT, event)
context.startActivity(intent)

View file

@ -24,8 +24,8 @@ import com.squareup.picasso.Callback
import com.squareup.picasso.Picasso
import de.nicidienase.chaosflix.touch.R
import de.nicidienase.chaosflix.common.ChaosflixUtil
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
import de.nicidienase.chaosflix.common.viewmodel.DetailsViewModel
import de.nicidienase.chaosflix.touch.databinding.FragmentEventDetailsBinding
@ -38,7 +38,7 @@ class EventDetailsFragment : Fragment() {
private var listener: OnEventDetailsFragmentInteractionListener? = null
private var appBarExpanded: Boolean = false
private lateinit var event: PersistentEvent
private lateinit var event: Event
private var watchlistItem: WatchlistItem? = null
private var eventSelectedListener: OnEventSelectedListener? = null
private var selectDialog: AlertDialog? = null
@ -56,7 +56,7 @@ class EventDetailsFragment : Fragment() {
// sharedElementEnterTransition = transition
if (arguments != null) {
val parcelable = arguments?.getParcelable<PersistentEvent>(EVENT_PARAM)
val parcelable = arguments?.getParcelable<Event>(EVENT_PARAM)
if(parcelable != null){
event = parcelable
} else {
@ -137,14 +137,14 @@ class EventDetailsFragment : Fragment() {
}
}
DetailsViewModel.DetailsViewModelState.PlayOnlineItem -> {
liveEvent.data?.getParcelable<PersistentRecording>(DetailsViewModel.KEY_PLAY_RECORDING)?.let {
liveEvent.data?.getParcelable<Recording>(DetailsViewModel.KEY_PLAY_RECORDING)?.let {
listener?.playItem(event,it)
}
}
DetailsViewModel.DetailsViewModelState.SelectRecording -> {
val selectItems: Array<PersistentRecording> =
liveEvent.data?.getParcelableArray(DetailsViewModel.KEY_SELECT_RECORDINGS) as Array<PersistentRecording>
val selectItems: Array<Recording> =
liveEvent.data?.getParcelableArray(DetailsViewModel.KEY_SELECT_RECORDINGS) as Array<Recording>
selectRecording(selectItems.asList()) {
viewModel.playRecording(it)
}
@ -175,19 +175,19 @@ class EventDetailsFragment : Fragment() {
viewModel.playEvent(event)
}
private fun selectRecording(persistentRecordings: List<PersistentRecording>, action: (recording: PersistentRecording) -> Unit) {
val stream = ChaosflixUtil.getOptimalRecording(persistentRecordings)
private fun selectRecording(recordings: List<Recording>, action: (recording: Recording) -> Unit) {
val stream = ChaosflixUtil.getOptimalRecording(recordings)
if (stream != null && viewModel.getAutoselectRecording()) {
action.invoke(stream)
} else {
val items: List<String> = persistentRecordings.map { getStringForRecording(it) }
val items: List<String> = recordings.map { getStringForRecording(it) }
selectRecordingFromList(items, DialogInterface.OnClickListener { dialogInterface, i ->
action.invoke(persistentRecordings[i])
action.invoke(recordings[i])
})
}
}
private fun getStringForRecording(recording: PersistentRecording): String {
private fun getStringForRecording(recording: Recording): String {
return "${if (recording.isHighQuality) "HD" else "SD"} ${recording.folder} [${recording.language}]"
}
@ -304,7 +304,7 @@ class EventDetailsFragment : Fragment() {
}
}
private fun downloadRecording(recording: PersistentRecording) {
private fun downloadRecording(recording: Recording) {
viewModel.download(event, recording).observe(this, Observer {
if (it != null) {
val message = if (it) "Download started" else "Error starting download"
@ -316,15 +316,15 @@ class EventDetailsFragment : Fragment() {
interface OnEventDetailsFragmentInteractionListener {
fun onToolbarStateChange()
fun invalidateOptionsMenu()
fun playItem(event: PersistentEvent, recording: PersistentRecording)
fun playItem(event: PersistentEvent, uri: String)
fun playItem(event: Event, recording: Recording)
fun playItem(event: Event, uri: String)
}
companion object {
private val TAG = EventDetailsFragment::class.java.simpleName
private val EVENT_PARAM = "event_param"
fun newInstance(event: PersistentEvent): EventDetailsFragment {
fun newInstance(event: Event): EventDetailsFragment {
val fragment = EventDetailsFragment()
val args = Bundle()
args.putParcelable(EVENT_PARAM, event)

View file

@ -6,8 +6,8 @@ import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import de.nicidienase.chaosflix.touch.R
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.StreamUrl
class PlayerActivity : AppCompatActivity(), ExoPlayerFragment.OnMediaPlayerInteractionListener {
@ -20,8 +20,8 @@ class PlayerActivity : AppCompatActivity(), ExoPlayerFragment.OnMediaPlayerInter
val contentType = intent.getStringExtra(CONTENT_TYPE)
var playbackItem = PlaybackItem("Empty", "Empty", "", "")
if (contentType.equals(CONTENT_RECORDING)) {
val event = intent.extras.getParcelable<PersistentEvent>(EVENT_KEY)
val recording = intent.extras.getParcelable<PersistentRecording>(RECORDING_KEY)
val event = intent.extras.getParcelable<Event>(EVENT_KEY)
val recording = intent.extras.getParcelable<Recording>(RECORDING_KEY)
val recordingUri = intent.extras.getString(OFFLINE_URI)
playbackItem = PlaybackItem(
event?.title ?: "",
@ -64,7 +64,7 @@ class PlayerActivity : AppCompatActivity(), ExoPlayerFragment.OnMediaPlayerInter
val OFFLINE_URI = "recording_uri"
fun launch(context: Context, event: PersistentEvent, uri: String) {
fun launch(context: Context, event: Event, uri: String) {
val i = Intent(context, PlayerActivity::class.java)
i.putExtra(CONTENT_TYPE, CONTENT_RECORDING)
i.putExtra(PlayerActivity.EVENT_KEY, event)
@ -72,7 +72,7 @@ class PlayerActivity : AppCompatActivity(), ExoPlayerFragment.OnMediaPlayerInter
context.startActivity(i)
}
fun launch(context: Context, event: PersistentEvent, recording: PersistentRecording) {
fun launch(context: Context, event: Event, recording: Recording) {
val i = Intent(context, PlayerActivity::class.java)
i.putExtra(CONTENT_TYPE, CONTENT_RECORDING)
i.putExtra(PlayerActivity.EVENT_KEY, event)

View file

@ -12,7 +12,7 @@
<variable
name="event"
type="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent"/>
type="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event"/>
</data>
<LinearLayout

View file

@ -9,7 +9,7 @@
<variable
name="event"
type="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent"/>
type="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event"/>
</data>
<android.support.design.widget.CoordinatorLayout

View file

@ -12,7 +12,7 @@
<variable
name="event"
type="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent"/>
type="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event"/>
</data>
<LinearLayout