detail: remove unlikelytobenull calls
bad
This commit is contained in:
@@ -41,7 +41,6 @@ import org.oxycblt.auxio.util.collectImmediately
|
||||
import org.oxycblt.auxio.util.getPlural
|
||||
import org.oxycblt.auxio.util.navigateSafe
|
||||
import org.oxycblt.auxio.util.showToast
|
||||
import org.oxycblt.auxio.util.unlikelyToBeNull
|
||||
import org.oxycblt.musikr.Album
|
||||
import org.oxycblt.musikr.Music
|
||||
import org.oxycblt.musikr.MusicParent
|
||||
@@ -106,7 +105,8 @@ class AlbumDetailFragment : DetailFragment<Album, Song>() {
|
||||
}
|
||||
|
||||
override fun onOpenParentMenu() {
|
||||
listModel.openMenu(R.menu.detail_album, unlikelyToBeNull(detailModel.currentAlbum.value))
|
||||
val currentAlbum = detailModel.currentAlbum.value ?: return
|
||||
listModel.openMenu(R.menu.detail_album, currentAlbum)
|
||||
}
|
||||
|
||||
override fun onOpenMenu(item: Song) {
|
||||
@@ -140,7 +140,7 @@ class AlbumDetailFragment : DetailFragment<Album, Song>() {
|
||||
// Add a QoL behavior where navigation to the artist will occur if the artist
|
||||
// name is pressed.
|
||||
setOnClickListener {
|
||||
detailModel.showArtist(unlikelyToBeNull(detailModel.currentAlbum.value))
|
||||
detailModel.showArtist(album)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +154,11 @@ class AlbumDetailFragment : DetailFragment<Album, Song>() {
|
||||
}
|
||||
|
||||
binding.detailPlayButton?.setOnClickListener {
|
||||
playbackModel.play(unlikelyToBeNull(detailModel.currentAlbum.value))
|
||||
playbackModel.play(album)
|
||||
}
|
||||
binding.detailShuffleButton?.setOnClickListener {
|
||||
playbackModel.shuffle(unlikelyToBeNull(detailModel.currentAlbum.value))
|
||||
playbackModel.shuffle(album)
|
||||
playbackModel.shuffle(album)
|
||||
}
|
||||
setToolbarPlaybackButtonsEnabled(true)
|
||||
updatePlayback(
|
||||
@@ -183,7 +184,8 @@ class AlbumDetailFragment : DetailFragment<Album, Song>() {
|
||||
// Songs should be scrolled to if the album matches, or a new detail
|
||||
// fragment should be launched otherwise.
|
||||
is Show.SongAlbumDetails -> {
|
||||
if (unlikelyToBeNull(detailModel.currentAlbum.value) == show.song.album) {
|
||||
val currentAlbum = detailModel.currentAlbum.value ?: return
|
||||
if (currentAlbum == show.song.album) {
|
||||
L.d("Navigating to a ${show.song} in this album")
|
||||
scrollToAlbumSong(show.song)
|
||||
detailModel.toShow.consume()
|
||||
@@ -197,7 +199,8 @@ class AlbumDetailFragment : DetailFragment<Album, Song>() {
|
||||
// If the album matches, no need to do anything. Otherwise launch a new
|
||||
// detail fragment.
|
||||
is Show.AlbumDetails -> {
|
||||
if (unlikelyToBeNull(detailModel.currentAlbum.value) == show.album) {
|
||||
val currentAlbum = detailModel.currentAlbum.value ?: return
|
||||
if (currentAlbum == show.album) {
|
||||
L.d("Navigating to the top of this album")
|
||||
binding.detailRecycler.scrollToPosition(0)
|
||||
detailModel.toShow.consume()
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.oxycblt.auxio.util.collectImmediately
|
||||
import org.oxycblt.auxio.util.getPlural
|
||||
import org.oxycblt.auxio.util.navigateSafe
|
||||
import org.oxycblt.auxio.util.showToast
|
||||
import org.oxycblt.auxio.util.unlikelyToBeNull
|
||||
import org.oxycblt.musikr.Album
|
||||
import org.oxycblt.musikr.Artist
|
||||
import org.oxycblt.musikr.Music
|
||||
@@ -110,7 +109,8 @@ class ArtistDetailFragment : DetailFragment<Artist, Music>() {
|
||||
}
|
||||
|
||||
override fun onOpenParentMenu() {
|
||||
listModel.openMenu(R.menu.detail_parent, unlikelyToBeNull(detailModel.currentArtist.value))
|
||||
val currentArtist = detailModel.currentArtist.value ?: return
|
||||
listModel.openMenu(R.menu.detail_parent, currentArtist)
|
||||
}
|
||||
|
||||
override fun onOpenMenu(item: Music) {
|
||||
@@ -182,10 +182,10 @@ class ArtistDetailFragment : DetailFragment<Artist, Music>() {
|
||||
}
|
||||
|
||||
binding.detailPlayButton?.setOnClickListener {
|
||||
playbackModel.play(unlikelyToBeNull(detailModel.currentArtist.value))
|
||||
playbackModel.play(artist)
|
||||
}
|
||||
binding.detailShuffleButton?.setOnClickListener {
|
||||
playbackModel.shuffle(unlikelyToBeNull(detailModel.currentArtist.value))
|
||||
playbackModel.shuffle(artist)
|
||||
}
|
||||
updatePlayback(
|
||||
playbackModel.song.value,
|
||||
@@ -306,7 +306,7 @@ class ArtistDetailFragment : DetailFragment<Artist, Music>() {
|
||||
}
|
||||
|
||||
private fun updatePlayback(song: Song?, parent: MusicParent?, isPlaying: Boolean) {
|
||||
val currentArtist = unlikelyToBeNull(detailModel.currentArtist.value)
|
||||
val currentArtist = detailModel.currentArtist.value ?: return
|
||||
val playingItem =
|
||||
when (parent) {
|
||||
// Always highlight a playing album if it's from this artist, and if the currently
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.oxycblt.auxio.util.collectImmediately
|
||||
import org.oxycblt.auxio.util.getPlural
|
||||
import org.oxycblt.auxio.util.navigateSafe
|
||||
import org.oxycblt.auxio.util.showToast
|
||||
import org.oxycblt.auxio.util.unlikelyToBeNull
|
||||
import org.oxycblt.musikr.Artist
|
||||
import org.oxycblt.musikr.Genre
|
||||
import org.oxycblt.musikr.Music
|
||||
@@ -108,7 +107,8 @@ class GenreDetailFragment : DetailFragment<Genre, Music>() {
|
||||
}
|
||||
|
||||
override fun onOpenParentMenu() {
|
||||
listModel.openMenu(R.menu.detail_parent, unlikelyToBeNull(detailModel.currentGenre.value))
|
||||
val genre = detailModel.currentGenre.value ?: return
|
||||
listModel.openMenu(R.menu.detail_parent, genre)
|
||||
}
|
||||
|
||||
override fun onOpenMenu(item: Music) {
|
||||
@@ -146,10 +146,10 @@ class GenreDetailFragment : DetailFragment<Genre, Music>() {
|
||||
context.getPlural(R.plurals.fmt_song_count, genre.songs.size),
|
||||
)
|
||||
binding.detailPlayButton?.setOnClickListener {
|
||||
playbackModel.play(unlikelyToBeNull(detailModel.currentGenre.value))
|
||||
playbackModel.play(genre)
|
||||
}
|
||||
binding.detailShuffleButton?.setOnClickListener {
|
||||
playbackModel.shuffle(unlikelyToBeNull(detailModel.currentGenre.value))
|
||||
playbackModel.shuffle(genre)
|
||||
}
|
||||
setToolbarPlaybackButtonsEnabled(true)
|
||||
updatePlayback(
|
||||
@@ -266,7 +266,7 @@ class GenreDetailFragment : DetailFragment<Genre, Music>() {
|
||||
}
|
||||
|
||||
private fun updatePlayback(song: Song?, parent: MusicParent?, isPlaying: Boolean) {
|
||||
val currentGenre = unlikelyToBeNull(detailModel.currentGenre.value)
|
||||
val currentGenre = detailModel.currentGenre.value ?: return
|
||||
val playingItem =
|
||||
when (parent) {
|
||||
// Always highlight a playing artist if it's from this genre, and if the currently
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.oxycblt.auxio.util.context
|
||||
import org.oxycblt.auxio.util.getPlural
|
||||
import org.oxycblt.auxio.util.navigateSafe
|
||||
import org.oxycblt.auxio.util.showToast
|
||||
import org.oxycblt.auxio.util.unlikelyToBeNull
|
||||
import org.oxycblt.musikr.Music
|
||||
import org.oxycblt.musikr.MusicParent
|
||||
import org.oxycblt.musikr.Playlist
|
||||
@@ -187,9 +186,10 @@ class PlaylistDetailFragment :
|
||||
}
|
||||
|
||||
override fun onOpenParentMenu() {
|
||||
val currentPlaylist = detailModel.currentPlaylist.value ?: return
|
||||
listModel.openMenu(
|
||||
R.menu.detail_playlist,
|
||||
unlikelyToBeNull(detailModel.currentPlaylist.value),
|
||||
currentPlaylist
|
||||
)
|
||||
}
|
||||
|
||||
@@ -251,13 +251,13 @@ class PlaylistDetailFragment :
|
||||
binding.detailPlayButton?.apply {
|
||||
isEnabled = playable
|
||||
setOnClickListener {
|
||||
playbackModel.play(unlikelyToBeNull(detailModel.currentPlaylist.value))
|
||||
playbackModel.play(playlist)
|
||||
}
|
||||
}
|
||||
binding.detailShuffleButton?.apply {
|
||||
isEnabled = playable
|
||||
setOnClickListener {
|
||||
playbackModel.shuffle(unlikelyToBeNull(detailModel.currentPlaylist.value))
|
||||
playbackModel.shuffle(playlist)
|
||||
}
|
||||
}
|
||||
setToolbarPlaybackButtonsEnabled(playable)
|
||||
|
||||
Reference in New Issue
Block a user