Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove !! operators #537

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading