Commit b28f5ca4 by Paul Woitaschek Committed by GitHub

Refactor unintuitive lateinit usage

parent 6cc7d058
...@@ -87,11 +87,10 @@ class PlaybackService : MediaLibraryService() { ...@@ -87,11 +87,10 @@ class PlaybackService : MediaLibraryService() {
// Only accept query with pattern "play [Title]" or "[Title]" // Only accept query with pattern "play [Title]" or "[Title]"
// Where [Title]: must be exactly matched // Where [Title]: must be exactly matched
// If no media with exact name found, play a random media instead // If no media with exact name found, play a random media instead
lateinit var mediaTitle: String val mediaTitle = if (query.startsWith("play ", ignoreCase = true)) {
if (query.lowercase().startsWith("play ")) { query.drop(5)
mediaTitle = query.subSequence(5, query.length).toString()
} else { } else {
mediaTitle = query query
} }
val item = MediaItemTree.getItemFromTitle(mediaTitle) ?: MediaItemTree.getRandomItem() val item = MediaItemTree.getItemFromTitle(mediaTitle) ?: MediaItemTree.getRandomItem()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment