mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-26 22:20:24 +00:00
Common/Touch: fix crash and reformatting
This commit is contained in:
parent
537391a458
commit
d3d97c9c5c
4 changed files with 37 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
package de.nicidienase.chaosflix.common.mediadata.entities.recording
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.lang.NumberFormatException
|
||||
|
||||
data class EventDto(@SerializedName("conference_id")
|
||||
var conferenceId: Long = 0,
|
||||
|
@ -41,14 +42,12 @@ data class EventDto(@SerializedName("conference_id")
|
|||
|
||||
init {
|
||||
val strings = url.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
|
||||
try {
|
||||
eventID = strings[strings.size - 1].toLong()
|
||||
} catch (ex: NumberFormatException) {
|
||||
} catch (e: NumberFormatException){
|
||||
eventID = 0
|
||||
}
|
||||
|
||||
val split = conferenceUrl.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
conferenceId = (split[split.size - 1]).toLong()
|
||||
}
|
||||
|
||||
fun getExtendedDescription(): String = "$description\n\nreleased at: $releaseDate\n\nTags: ${tags?.joinToString(", ")}"
|
||||
|
@ -67,6 +66,33 @@ data class EventDto(@SerializedName("conference_id")
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = guid.hashCode()
|
||||
result = 31 * result + title.hashCode()
|
||||
result = 31 * result + (subtitle?.hashCode() ?: 0)
|
||||
result = 31 * result + slug.hashCode()
|
||||
result = 31 * result + (link?.hashCode() ?: 0)
|
||||
result = 31 * result + (description?.hashCode() ?: 0)
|
||||
result = 31 * result + originalLanguage.hashCode()
|
||||
result = 31 * result + (persons?.contentHashCode() ?: 0)
|
||||
result = 31 * result + (tags?.contentHashCode() ?: 0)
|
||||
result = 31 * result + (date?.hashCode() ?: 0)
|
||||
result = 31 * result + releaseDate.hashCode()
|
||||
result = 31 * result + updatedAt.hashCode()
|
||||
result = 31 * result + length.hashCode()
|
||||
result = 31 * result + thumbUrl.hashCode()
|
||||
result = 31 * result + posterUrl.hashCode()
|
||||
result = 31 * result + (frontendLink?.hashCode() ?: 0)
|
||||
result = 31 * result + url.hashCode()
|
||||
result = 31 * result + (conferenceUrl?.hashCode() ?: 0)
|
||||
result = 31 * result + (recordings?.hashCode() ?: 0)
|
||||
result = 31 * result + (related?.hashCode() ?: 0)
|
||||
result = 31 * result + isPromoted.hashCode()
|
||||
result = 31 * result + eventID.hashCode()
|
||||
result = 31 * result + viewCount
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
class EventsResponse (var events: List<EventDto>)
|
|
@ -102,7 +102,7 @@ data class Event(
|
|||
thumbUrl = event.thumbUrl,
|
||||
frontendLink = event.frontendLink,
|
||||
url = event.url,
|
||||
conferenceUrl = event.conferenceUrl,
|
||||
conferenceUrl = event.conferenceUrl ?: "",
|
||||
isPromoted = event.isPromoted,
|
||||
viewCount = event.viewCount,
|
||||
persons = event.persons,
|
||||
|
|
|
@ -183,8 +183,7 @@ class Downloader(private val recordingApi: RecordingService,
|
|||
}
|
||||
|
||||
private fun saveEvent(event: EventDto): Event {
|
||||
val split = event.conferenceUrl.split("/")
|
||||
val acronym = split[split.size - 1]
|
||||
val acronym = event.conferenceUrl.split("/").last()
|
||||
val conferenceId = database.conferenceDao().findConferenceByAcronymSync(acronym)?.id
|
||||
?: updateConferencesAndGet(acronym)
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ class EventDetailsActivity : AppCompatActivity(),
|
|||
|
||||
private val PERMISSION_REQUEST_CODE: Int = 1;
|
||||
|
||||
private lateinit var casty: CastService
|
||||
private lateinit var castService: CastService
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_eventdetails)
|
||||
|
||||
casty = CastService(this)
|
||||
castService = CastService(this)
|
||||
|
||||
viewModel = ViewModelProviders.of(this, ViewModelFactory(this)).get(DetailsViewModel::class.java)
|
||||
viewModel.writeExternalStorageAllowed = hasWriteStoragePermission()
|
||||
|
@ -71,8 +71,8 @@ class EventDetailsActivity : AppCompatActivity(),
|
|||
}
|
||||
|
||||
override fun playItem(event: Event, recording: Recording, localFile: String?) {
|
||||
if (casty.connected) {
|
||||
casty.loadMediaAndPlay(recording, event)
|
||||
if (castService.connected) {
|
||||
castService.loadMediaAndPlay(recording, event)
|
||||
} else {
|
||||
if (localFile != null) {
|
||||
PlayerActivity.launch(this, event, localFile)
|
||||
|
@ -97,7 +97,7 @@ class EventDetailsActivity : AppCompatActivity(),
|
|||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
super.onCreateOptionsMenu(menu)
|
||||
menu?.let {
|
||||
casty.addMediaRouteMenuItem(it)
|
||||
castService.addMediaRouteMenuItem(it)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue