playback: simplify panel command

Simplify the Panel command from a sealed interface to a enum.

They held no data, better to use an enum and improve switch
performance.
This commit is contained in:
Alexander Capehart 2023-07-06 20:01:06 -06:00
parent 58848727f0
commit 7d42d016f1
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 10 additions and 10 deletions

View file

@ -304,9 +304,9 @@ class MainFragment :
if (panel == null) return if (panel == null) return
logD("Trying to update panel to $panel") logD("Trying to update panel to $panel")
when (panel) { when (panel) {
is OpenPanel.Main -> tryClosePlaybackPanel() OpenPanel.MAIN -> tryClosePlaybackPanel()
is OpenPanel.Playback -> tryOpenPlaybackPanel() OpenPanel.PLAYBACK -> tryOpenPlaybackPanel()
is OpenPanel.Queue -> tryOpenQueuePanel() OpenPanel.QUEUE -> tryOpenQueuePanel()
} }
playbackModel.openPanel.consume() playbackModel.openPanel.consume()
} }

View file

@ -572,16 +572,16 @@ constructor(
// --- UI CONTROL --- // --- UI CONTROL ---
/** Open the main panel, closing all other panels. */ /** Open the main panel, closing all other panels. */
fun openMain() = openImpl(OpenPanel.Main) fun openMain() = openImpl(OpenPanel.MAIN)
/** Open the playback panel, closing the queue panel if needed. */ /** Open the playback panel, closing the queue panel if needed. */
fun openPlayback() = openImpl(OpenPanel.Playback) fun openPlayback() = openImpl(OpenPanel.PLAYBACK)
/** /**
* Open the queue panel, assuming that it exists in the current layout, is collapsed, and with * Open the queue panel, assuming that it exists in the current layout, is collapsed, and with
* the playback panel already being expanded. * the playback panel already being expanded.
*/ */
fun openQueue() = openImpl(OpenPanel.Queue) fun openQueue() = openImpl(OpenPanel.QUEUE)
private fun openImpl(panel: OpenPanel) { private fun openImpl(panel: OpenPanel) {
val existing = openPanel.flow.value val existing = openPanel.flow.value
@ -641,16 +641,16 @@ constructor(
* *
* @author Alexander Capehart (OxygenCobalt) * @author Alexander Capehart (OxygenCobalt)
*/ */
sealed interface OpenPanel { enum class OpenPanel {
/** Open the main view, collapsing all other panels. */ /** Open the main view, collapsing all other panels. */
object Main : OpenPanel MAIN,
/** Open the playback panel, collapsing the queue panel if applicable. */ /** Open the playback panel, collapsing the queue panel if applicable. */
object Playback : OpenPanel PLAYBACK,
/** /**
* Open the queue panel, assuming that it exists in the current layout, is collapsed, and with * Open the queue panel, assuming that it exists in the current layout, is collapsed, and with
* the playback panel already being expanded. Do nothing if these conditions are not met. * the playback panel already being expanded. Do nothing if these conditions are not met.
*/ */
object Queue : OpenPanel QUEUE
} }
/** /**