Skip to content

Commit

Permalink
Remove !! operators
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgCantor committed Nov 18, 2023
1 parent 2136c37 commit 7a0ff2c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.example.android.uamp.viewmodels

import android.net.Uri
import android.support.v4.media.MediaBrowserCompat
import android.support.v4.media.MediaBrowserCompat.MediaItem
import android.support.v4.media.MediaBrowserCompat.SubscriptionCallback
Expand Down Expand Up @@ -61,12 +62,12 @@ class MediaItemFragmentViewModel(
val itemsList = children.map { child ->
val subtitle = child.description.subtitle ?: ""
MediaItemData(
child.mediaId!!,
child.mediaId.orEmpty(),
child.description.title.toString(),
subtitle.toString(),
child.description.iconUri!!,
child.description.iconUri ?: Uri.EMPTY,
child.isBrowsable,
getResourceForMediaId(child.mediaId!!)
getResourceForMediaId(child.mediaId.orEmpty())
)
}
_mediaItems.postValue(itemsList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class NowPlayingFragmentViewModel(
// Only update media item once we have duration available
if (mediaMetadata.duration != 0L && mediaMetadata.id != null) {
val nowPlayingMetadata = NowPlayingMetadata(
mediaMetadata.id!!,
mediaMetadata.id.orEmpty(),
mediaMetadata.albumArtUri,
mediaMetadata.title?.trim(),
mediaMetadata.displaySubtitle?.trim(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class UsernameAndPasswordSignInFragment : Fragment() {

submitButton.text = getString(R.string.sign_in_submit_button_label)
submitButton.setOnClickListener {
onSignIn(userId!!, passwordInput.text.toString())
onSignIn(userId.orEmpty(), passwordInput.text.toString())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal class CastMediaItemConverter : MediaItemConverter {
mediaItem.mediaMetadata.discNumber?.let {
castMediaMetadata.putInt(MediaMetadata.KEY_DISC_NUMBER, it)
}
val mediaInfo = MediaInfo.Builder(mediaItem.localConfiguration!!.uri.toString())
val mediaInfo = MediaInfo.Builder(mediaItem.localConfiguration?.uri.toString())
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType(MimeTypes.AUDIO_MPEG)
mediaItem.localConfiguration?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ open class MusicService : MediaBrowserServiceCompat() {

switchToPlayer(
previousPlayer = null,
newPlayer = if (castPlayer?.isCastSessionAvailable == true) castPlayer!! else exoPlayer
newPlayer = if (castPlayer?.isCastSessionAvailable == true) {
castPlayer ?: exoPlayer
} else {
exoPlayer
}
)
notificationManager.showNotificationForPlayer(currentPlayer)

Expand Down Expand Up @@ -445,7 +449,7 @@ open class MusicService : MediaBrowserServiceCompat() {
* remote Cast receiver rather than play audio locally.
*/
override fun onCastSessionAvailable() {
switchToPlayer(currentPlayer, castPlayer!!)
castPlayer?.let { switchToPlayer(currentPlayer, it) }
}

/**
Expand Down Expand Up @@ -484,7 +488,7 @@ open class MusicService : MediaBrowserServiceCompat() {
override fun onPrepare(playWhenReady: Boolean) {
val recentSong = storage.loadRecentSong() ?: return
onPrepareFromMediaId(
recentSong.mediaId!!,
recentSong.mediaId.orEmpty(),
playWhenReady,
recentSong.description.extras
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class BrowseTree(

// Insert the album's root with an empty list for its children, and return the list.
return mutableListOf<MediaMetadataCompat>().also {
mediaIdToChildren[albumMetadata.id!!] = it
mediaIdToChildren[albumMetadata.id.orEmpty()] = it
}
}
}
Expand Down

0 comments on commit 7a0ff2c

Please sign in to comment.