Adopt changes from stricter nullabilities

This commit is contained in:
tzugen 2021-05-26 23:21:56 +02:00
parent b30584f99c
commit e059d737bc
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
6 changed files with 30 additions and 48 deletions

View File

@ -258,7 +258,7 @@ class TrackCollectionFragment : Fragment() {
model.getMusicFolders(refresh)
if (playlistId != null) {
setTitle(playlistName)
setTitle(playlistName!!)
model.getPlaylist(playlistId, playlistName)
} else if (podcastChannelId != null) {
setTitle(getString(R.string.podcasts_label))
@ -282,12 +282,12 @@ class TrackCollectionFragment : Fragment() {
setTitle(name)
if (!isOffline() && Util.getShouldUseId3Tags()) {
if (isAlbum) {
model.getAlbum(refresh, id, name, parentId)
model.getAlbum(refresh, id!!, name, parentId!!)
} else {
model.getArtist(refresh, id, name)
model.getArtist(refresh, id!!, name)
}
} else {
model.getMusicDirectory(refresh, id, name, parentId)
model.getMusicDirectory(refresh, id!!, name, parentId!!)
}
}

View File

@ -43,9 +43,9 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
suspend fun getMusicDirectory(
refresh: Boolean,
id: String?,
id: String,
name: String?,
parentId: String?
parentId: String
) {
withContext(Dispatchers.IO) {
@ -121,7 +121,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
* TODO: This method should be moved to AlbumListModel,
* since it displays a list of albums by a specified artist.
*/
suspend fun getArtist(refresh: Boolean, id: String?, name: String?) {
suspend fun getArtist(refresh: Boolean, id: String, name: String?) {
withContext(Dispatchers.IO) {
val service = MusicServiceFactory.getMusicService()
@ -152,7 +152,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
}
}
suspend fun getAlbum(refresh: Boolean, id: String?, name: String?, parentId: String?) {
suspend fun getAlbum(refresh: Boolean, id: String, name: String?, parentId: String) {
withContext(Dispatchers.IO) {
@ -210,9 +210,9 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
val musicDirectory: MusicDirectory
if (Util.getShouldUseId3Tags()) {
musicDirectory = Util.getSongsFromSearchResult(service.starred2)
musicDirectory = Util.getSongsFromSearchResult(service.getStarred2())
} else {
musicDirectory = Util.getSongsFromSearchResult(service.starred)
musicDirectory = Util.getSongsFromSearchResult(service.getStarred())
}
currentDirectory.postValue(musicDirectory)
@ -239,7 +239,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
}
}
suspend fun getPlaylist(playlistId: String, playlistName: String?) {
suspend fun getPlaylist(playlistId: String, playlistName: String) {
withContext(Dispatchers.IO) {
val service = MusicServiceFactory.getMusicService()

View File

@ -429,10 +429,7 @@ class MediaPlayerController(
get() {
try {
val username = activeServerProvider.getActiveServer().userName
val (_, _, _, _, _, _, _, _, _, _, _, _, jukeboxRole) = getMusicService().getUser(
username
)
return jukeboxRole
return getMusicService().getUser(username).jukeboxRole
} catch (e: Exception) {
Timber.w(e, "Error getting user information")
}

View File

@ -1,20 +1,8 @@
/*
This file is part of Subsonic.
Subsonic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Subsonic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2009 (C) Sindre Mehus
* RestMusicService.kt
* Copyright (C) 2009-2021 Ultrasonic developers
*
* Distributed under terms of the GNU GPLv3 license.
*/
package org.moire.ultrasonic.service
@ -64,7 +52,6 @@ import timber.log.Timber
/**
* This Music Service implementation connects to a server using the Subsonic REST API
* @author Sindre Mehus
*/
open class RESTMusicService(
private val subsonicAPIClient: SubsonicAPIClient,
@ -109,7 +96,7 @@ open class RESTMusicService(
override fun getIndexes(
musicFolderId: String?,
refresh: Boolean
): Indexes? {
): Indexes {
val indexName = INDEXES_STORAGE_NAME + (musicFolderId ?: "")
val cachedIndexes = fileStorage.load(indexName, getIndexesSerializer())
@ -171,7 +158,7 @@ open class RESTMusicService(
id: String,
name: String?,
refresh: Boolean
): MusicDirectory? {
): MusicDirectory {
val response = responseChecker.callWithResponseCheck { api ->
api.getMusicDirectory(id).execute()
}
@ -268,7 +255,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getPlaylist(
id: String,
name: String?
name: String
): MusicDirectory {
val response = responseChecker.callWithResponseCheck { api ->
api.getPlaylist(id).execute()
@ -282,7 +269,7 @@ open class RESTMusicService(
@Throws(IOException::class)
private fun savePlaylist(
name: String?,
name: String,
playlist: MusicDirectory
) {
val playlistFile = FileUtil.getPlaylistFile(
@ -326,16 +313,14 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun createPlaylist(
id: String?,
name: String?,
id: String,
name: String,
entries: List<MusicDirectory.Entry>
) {
val pSongIds: MutableList<String> = ArrayList(entries.size)
for ((id1) in entries) {
if (id1 != null) {
pSongIds.add(id1)
}
pSongIds.add(id1)
}
responseChecker.callWithResponseCheck { api ->
api.createPlaylist(id, name, pSongIds.toList()).execute()
@ -400,8 +385,8 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getLyrics(
artist: String?,
title: String?
artist: String,
title: String
): Lyrics {
val response = responseChecker.callWithResponseCheck { api ->
api.getLyrics(artist, title).execute()
@ -587,7 +572,7 @@ open class RESTMusicService(
): Pair<InputStream, Boolean> {
val songOffset = if (offset < 0) 0 else offset
val response = subsonicAPIClient.stream(song.id!!, maxBitrate, songOffset)
val response = subsonicAPIClient.stream(song.id, maxBitrate, songOffset)
checkStreamResponseError(response)
if (response.stream == null) {
@ -704,7 +689,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getGenres(
refresh: Boolean
): List<Genre> {
): List<Genre>? {
val response = responseChecker.callWithResponseCheck { api -> api.getGenres().execute() }
return response.body()!!.genresList.toDomainEntityList()

View File

@ -226,7 +226,7 @@ class DownloadHandler(
}
}
} else {
root = musicService.getPlaylist(id, name)
root = musicService.getPlaylist(id, name!!)
}
getSongsRecursively(root, songs)
}

View File

@ -68,9 +68,9 @@ class ShareHandler(val context: Context) {
) {
@Throws(Throwable::class)
override fun doInBackground(): Share {
val ids: MutableList<String?> = ArrayList()
val ids: MutableList<String> = ArrayList()
if (shareDetails.Entries.isEmpty()) {
ids.add(fragment.arguments?.getString(Constants.INTENT_EXTRA_NAME_ID))
fragment.arguments?.getString(Constants.INTENT_EXTRA_NAME_ID)?.let { ids.add(it) }
} else {
for ((id) in shareDetails.Entries) {
ids.add(id)