add Room-Annotations

This commit is contained in:
Felix 2017-10-27 00:02:15 +02:00
parent f4abd64c0a
commit ee26005411
3 changed files with 68 additions and 62 deletions

View file

@ -1,5 +1,7 @@
package de.nicidienase.chaosflix.common.entities.recording
import android.arch.persistence.room.Entity
import android.arch.persistence.room.PrimaryKey
import android.os.Parcel
import android.os.Parcelable
@ -8,6 +10,7 @@ import com.google.gson.annotations.SerializedName
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
@Entity(tableName = "conference")
class Conference(
var acronym: String,
@SerializedName("aspect_ratio")
@ -30,15 +33,15 @@ class Conference(
var events: List<Event>
) : Parcelable, Comparable<Conference> {
// return Event.find(Event.class,"parent_conference_id = ? ", String.valueOf(this.getId()));
@PrimaryKey
val apiID: Long
val eventsByTags: HashMap<String, MutableList<Event>>
init {
eventsByTags = HashMap<String, MutableList<Event>>()
val untagged = ArrayList<Event>()
for (event in this.events) {
if (event.tags.size > 0) {
if (event.tags.isNotEmpty()) {
for (tag in event.tags) {
if (tag != null) {
@ -61,13 +64,10 @@ class Conference(
if (untagged.size > 0) {
eventsByTags.put("untagged", untagged)
}
val strings = url.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
apiID = (strings[strings.size - 1]).toLong()
}
val apiID: Int
get() {
val strings = url.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
return Integer.parseInt(strings[strings.size - 1])
}
protected constructor(`in`: Parcel) : this(
`in`.readString(),

View file

@ -1,36 +1,42 @@
package de.nicidienase.chaosflix.common.entities.recording
import android.arch.persistence.room.Embedded
import android.arch.persistence.room.Entity
import android.arch.persistence.room.PrimaryKey
import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
@Entity(tableName = "event")
class Event(@SerializedName("conference_id") var conferenceId: Long,
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: List<String>,
var tags: List<String>,
var date: String,
@SerializedName("release_date") var releaseDate: String,
@SerializedName("updated_at") var updatedAt: String,
var length: Int = 0,
@SerializedName("thumb_url") var thumbUrl: String,
@SerializedName("poster_url") var posterUrl: String,
@SerializedName("frontend_link") var frontendLink: String,
var url: String,
@SerializedName("conference_url") var conferenceUrl: String,
var recordings: List<Recording>,
var metadata: Metadata,
var isPromoted: Boolean = false
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: List<String>,
var tags: List<String>,
var date: String,
@SerializedName("release_date") var releaseDate: String,
@SerializedName("updated_at") var updatedAt: String,
var length: Int = 0,
@SerializedName("thumb_url") var thumbUrl: String,
@SerializedName("poster_url") var posterUrl: String,
@SerializedName("frontend_link") var frontendLink: String,
var url: String,
@SerializedName("conference_url") var conferenceUrl: String,
var recordings: List<Recording>,
@Embedded var metadata: Metadata,
var isPromoted: Boolean = false
) : Parcelable, Comparable<Event> {
@SerializedName("view_count") var viewCount: Int = 0
@PrimaryKey
val apiID: Int
@SerializedName("view_count")
var viewCount: Int = 0
init {
@ -43,27 +49,27 @@ class Event(@SerializedName("conference_id") var conferenceId: Long,
protected constructor(`in`: Parcel) : this(
conferenceId = `in`.readLong(),
guid = `in`.readString(),
title = `in`.readString(),
subtitle = `in`.readString(),
slug = `in`.readString(),
link = `in`.readString(),
description = `in`.readString(),
originalLanguage = `in`.readString(),
persons = `in`.createStringArrayList(),
tags = `in`.createStringArrayList(),
date = `in`.readString(),
releaseDate = `in`.readString(),
updatedAt = `in`.readString(),
length = `in`.readInt(),
thumbUrl = `in`.readString(),
posterUrl = `in`.readString(),
frontendLink = `in`.readString(),
url = `in`.readString(),
conferenceUrl = `in`.readString(),
recordings = `in`.createTypedArrayList(Recording.CREATOR),
metadata = `in`.readParcelable(Metadata::class.java.classLoader)
conferenceId = `in`.readLong(),
guid = `in`.readString(),
title = `in`.readString(),
subtitle = `in`.readString(),
slug = `in`.readString(),
link = `in`.readString(),
description = `in`.readString(),
originalLanguage = `in`.readString(),
persons = `in`.createStringArrayList(),
tags = `in`.createStringArrayList(),
date = `in`.readString(),
releaseDate = `in`.readString(),
updatedAt = `in`.readString(),
length = `in`.readInt(),
thumbUrl = `in`.readString(),
posterUrl = `in`.readString(),
frontendLink = `in`.readString(),
url = `in`.readString(),
conferenceUrl = `in`.readString(),
recordings = `in`.createTypedArrayList(Recording.CREATOR),
metadata = `in`.readParcelable(Metadata::class.java.classLoader)
)
override fun writeToParcel(dest: Parcel, flags: Int) {

View file

@ -1,11 +1,12 @@
package de.nicidienase.chaosflix.common.entities.recording
import android.arch.persistence.room.Entity
import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
@Entity(tableName = "recording")
class Recording(
var size: Int = 0,
var length: Int = 0,
@ -30,17 +31,16 @@ class Recording(
var conferenceUrl: String
) : Parcelable {
val apiID: Int
get() {
val strings = url!!.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
return Integer.parseInt(strings[strings.size - 1])
}
val apiID: Long
val parentEventID: Long
get() {
val split = eventUrl!!.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
return java.lang.Long.parseLong(split[split.size - 1])
}
init {
val strings = url!!.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
apiID = (strings[strings.size - 1]).toLong()
val split = eventUrl!!.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
parentEventID = (split[split.size - 1]).toLong()
}
protected constructor(`in`: Parcel) : this(
`in`.readInt(),