music: simplify picker closing
Simplify picker closing navigation by avoiding weird communication via state change and instead simply navigate twice from NewPlaylistDialog. This is probably really stupid. But so is the other way.
This commit is contained in:
parent
6cfb50a10f
commit
d0a68353a7
5 changed files with 12 additions and 5 deletions
|
@ -127,7 +127,7 @@ class PlaylistDetailFragment :
|
|||
true
|
||||
}
|
||||
R.id.action_delete -> {
|
||||
musicModel.deletePlaylist(currentPlaylist)
|
||||
musicModel.createPlaylist()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.oxycblt.auxio.util.update
|
|||
|
||||
// TODO: Entirely rework music equality such that it's not completely UID-focused and actually
|
||||
// takes metadata into account
|
||||
// TODO: Reduce need for raw objects to save some memory
|
||||
|
||||
/**
|
||||
* Library-backed implementation of [Song].
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.ConcatAdapter
|
||||
|
@ -47,7 +48,7 @@ class AddToPlaylistDialog :
|
|||
ClickableListListener<PlaylistChoice>,
|
||||
NewPlaylistFooterAdapter.Listener {
|
||||
private val musicModel: MusicViewModel by activityViewModels()
|
||||
private val pickerModel: PlaylistPickerViewModel by activityViewModels()
|
||||
private val pickerModel: PlaylistPickerViewModel by viewModels()
|
||||
// Information about what playlist to name for is initially within the navigation arguments
|
||||
// as UIDs, as that is the only safe way to parcel playlist information.
|
||||
private val args: AddToPlaylistDialogArgs by navArgs()
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.view.LayoutInflater
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
@ -42,7 +43,7 @@ import org.oxycblt.auxio.util.unlikelyToBeNull
|
|||
@AndroidEntryPoint
|
||||
class NewPlaylistDialog : ViewBindingDialogFragment<DialogPlaylistNameBinding>() {
|
||||
private val musicModel: MusicViewModel by activityViewModels()
|
||||
private val pickerModel: PlaylistPickerViewModel by activityViewModels()
|
||||
private val pickerModel: PlaylistPickerViewModel by viewModels()
|
||||
// Information about what playlist to name for is initially within the navigation arguments
|
||||
// as UIDs, as that is the only safe way to parcel playlist information.
|
||||
private val args: NewPlaylistDialogArgs by navArgs()
|
||||
|
@ -62,6 +63,12 @@ class NewPlaylistDialog : ViewBindingDialogFragment<DialogPlaylistNameBinding>()
|
|||
musicModel.createPlaylist(name, pendingPlaylist.songs)
|
||||
pickerModel.dropPendingAddition()
|
||||
requireContext().showToast(R.string.lng_playlist_created)
|
||||
findNavController().apply {
|
||||
navigateUp()
|
||||
// Do an additional navigation away from the playlist addition dialog, if
|
||||
// needed. If that dialog isn't present, this should be a no-op. Hopefully.
|
||||
navigateUp()
|
||||
}
|
||||
}
|
||||
.setNegativeButton(R.string.lbl_cancel, null)
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
android:background="?attr/colorSurface"
|
||||
android:transitionGroup="true">
|
||||
|
||||
<!-- TODO: Try to align the queue bar with the playback bar. -->
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/explore_nav_host"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
|
|
Loading…
Reference in a new issue