Skip to content

Commit

Permalink
[LyricsDialog] implement MVVM && cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chr56 committed May 2, 2023
1 parent 74613a7 commit 067f1b5
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ data class LyricsInfo(
fun availableSources(): Set<LyricsSource> = lyricsList.map { it.source }.toSet()
val activatedLyrics: AbsLyrics? get() = lyricsList.getOrNull(activatedLyricsNumber)

fun isActive(index: Int) = index == activatedLyricsNumber

private inline fun <reified L> findFirst(): L? {
for (lyric in lyricsList) {
if (lyric is L) return lyric
Expand All @@ -33,8 +35,8 @@ data class LyricsInfo(

fun createAmended(absLyrics: AbsLyrics): LyricsInfo = insect(this, absLyrics)

fun replaceActivated(index: Int): LyricsInfo = setActive(this,index)
fun replaceActivated(lyrics: AbsLyrics): LyricsInfo? = setActive(this,lyrics)
fun replaceActivated(index: Int): LyricsInfo = setActive(this, index)
fun replaceActivated(lyrics: AbsLyrics): LyricsInfo? = setActive(this, lyrics)

companion object {
val EMPTY = LyricsInfo(Song.EMPTY_SONG, ArrayList(), -1)
Expand Down
Loading

0 comments on commit 067f1b5

Please sign in to comment.