mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Refactor unintuitive lateinit usage
This commit is contained in:
parent
6cc7d058a8
commit
b28f5ca413
@ -87,11 +87,10 @@ class PlaybackService : MediaLibraryService() {
|
||||
// Only accept query with pattern "play [Title]" or "[Title]"
|
||||
// Where [Title]: must be exactly matched
|
||||
// If no media with exact name found, play a random media instead
|
||||
lateinit var mediaTitle: String
|
||||
if (query.lowercase().startsWith("play ")) {
|
||||
mediaTitle = query.subSequence(5, query.length).toString()
|
||||
val mediaTitle = if (query.startsWith("play ", ignoreCase = true)) {
|
||||
query.drop(5)
|
||||
} else {
|
||||
mediaTitle = query
|
||||
query
|
||||
}
|
||||
|
||||
val item = MediaItemTree.getItemFromTitle(mediaTitle) ?: MediaItemTree.getRandomItem()
|
||||
|
Loading…
x
Reference in New Issue
Block a user