Change parent artist navigation
Change the parent artist navigation so that its only enabled when an album is selected from LibraryFragment, otherwise dont enable it, as the user can just navigate up to see the parent artist.
This commit is contained in:
@@ -25,5 +25,4 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
// RecyclerView click listener
|
||||
// Dont ask why its here
|
||||
class ClickListener<T>(val onClick: (T) -> Unit)
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import org.oxycblt.auxio.ClickListener
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.databinding.FragmentAlbumDetailBinding
|
||||
import org.oxycblt.auxio.detail.adapters.DetailSongAdapter
|
||||
import org.oxycblt.auxio.music.MusicViewModel
|
||||
@@ -45,14 +46,23 @@ class AlbumDetailFragment : Fragment() {
|
||||
binding.songRecycler.applyDivider()
|
||||
binding.songRecycler.setHasFixedSize(true)
|
||||
|
||||
detailModel.navToParentArtist.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
findNavController().navigate(
|
||||
AlbumDetailFragmentDirections.actionShowParentArtist(album.artist.id)
|
||||
)
|
||||
// If the album was shown directly from LibraryFragment, then enable the ability
|
||||
// to navigate to the artist from the album. Don't do this if the album was shown
|
||||
// from ArtistDetailFragment, as you can just navigate up to see the parent artist.
|
||||
if (args.isFromLibrary) {
|
||||
detailModel.doneWithNavToParent()
|
||||
|
||||
detailModel.doneWithNavToParent()
|
||||
detailModel.navToParentArtist.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
findNavController().navigate(
|
||||
AlbumDetailFragmentDirections.actionShowParentArtist(album.artist.id)
|
||||
)
|
||||
|
||||
detailModel.doneWithNavToParent()
|
||||
}
|
||||
}
|
||||
|
||||
binding.artistName.setBackgroundResource(R.drawable.ripple)
|
||||
}
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment created.")
|
||||
|
||||
@@ -62,7 +62,7 @@ class ArtistDetailFragment : Fragment() {
|
||||
detailModel.isAlreadyNavigating = true
|
||||
|
||||
findNavController().navigate(
|
||||
ArtistDetailFragmentDirections.actionShowAlbum(album.id)
|
||||
ArtistDetailFragmentDirections.actionShowAlbum(album.id, false)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,6 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/artist_name"
|
||||
android:background="@drawable/ripple"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
<argument
|
||||
android:name="albumId"
|
||||
app:argType="long" />
|
||||
<argument
|
||||
android:name="isFromLibrary"
|
||||
app:argType="boolean" />
|
||||
<action
|
||||
android:id="@+id/action_show_parent_artist"
|
||||
app:enterAnim="@anim/fragment_fade_enter"
|
||||
|
||||
Reference in New Issue
Block a user