add new functions to utility-object

This commit is contained in:
Felix 2017-11-02 23:58:49 +01:00
parent be74287daf
commit 56a4addc14

View file

@ -0,0 +1,51 @@
package de.nicidienase.chaosflix.touch
import de.nicidienase.chaosflix.common.entities.recording.persistence.PersistentRecording
import java.util.*
import kotlin.collections.ArrayList
object Util {
fun getOptimalStream(recordings: List<PersistentRecording>): PersistentRecording {
val result = ArrayList<PersistentRecording>()
result.addAll(recordings.filter { it.isHighQuality && it.mimeType == "video/mp4" }.sortedBy { it.language.length })
result.addAll(recordings.filter { it.mimeType == "video/mp4" }.sortedBy { it.language.length })
result.addAll(recordings.filter { it.mimeType.startsWith("video/") }.sortedBy { it.language.length })
when {
result.size > 0 -> return result[0]
else -> return recordings.get(0)
}
}
fun getStringForTag(tag: String): String {
when (tag) {
"congress" -> return "Congress"
"sendezentrum" -> return "Sendezentrum"
"camp" -> return "Camp"
"broadcast/chaosradio" -> return "Chaosradio"
"eh" -> return "Easterhegg"
"gpn" -> return "GPN"
"froscon" -> return "FrOSCon"
"mrmcd" -> return "MRMCD"
"sigint" -> return "SIGINT"
"datenspuren" -> return "Datenspuren"
"fiffkon" -> return "FifFKon"
"blinkenlights" -> return "Blinkenlights"
"chaoscologne" -> return "1c2 Chaos Cologne"
"cryptocon" -> return "CryptoCon"
"other conferences" -> return "Other Conferences"
"denog" -> return "DENOG"
"vcfb" -> return "Vintage Computing Festival Berlin"
"hackover" -> return "Hackover"
"netzpolitik" -> return "Das ist Netzpolitik!"
else -> return tag
}
}
val orderedConferencesList: List<String> = Arrays.asList(
"congress", "sendezentrum", "camp",
"gpn", "mrmcd", "broadcast/chaosradio",
"eh", "froscon", "sigint",
"datenspuren", "fiffkon", "cryptocon")
}