Skip to content

Commit e514cfc

Browse files
committed
重构歌词相关代码(部分)
1 parent 88e4079 commit e514cfc

File tree

91 files changed

+3385
-4811
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3385
-4811
lines changed

app/build.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
alias(libs.plugins.application)
66
alias(libs.plugins.kotlin)
77
alias(libs.plugins.kotlin.parcelize)
8+
alias(libs.plugins.kotlin.serialization)
89
alias(libs.plugins.ksp)
910
alias(libs.plugins.room)
1011
}
@@ -214,6 +215,7 @@ androidComponents {
214215

215216
dependencies {
216217
implementation(libs.kotlinx.coroutines)
218+
implementation(libs.kotlinx.serialization.json)
217219

218220
implementation(libs.appcompat)
219221
implementation(libs.cardview)

app/src/main/java/remix/myplayer/App.kt

-12
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,6 @@ class App : MultiDexApplication() {
5959
}
6060

6161
private fun checkMigration() {
62-
if (!SPUtil.getValue(context, SPUtil.LYRIC_KEY.NAME, SPUtil.LYRIC_KEY.LYRIC_RESET_ON_16000, false)) {
63-
SPUtil.deleteFile(this, SPUtil.LYRIC_KEY.NAME)
64-
SPUtil.putValue(context, SPUtil.LYRIC_KEY.NAME, SPUtil.LYRIC_KEY.LYRIC_RESET_ON_16000, true)
65-
SPUtil.putValue(context, SPUtil.LYRIC_KEY.NAME, SPUtil.LYRIC_KEY.PRIORITY_LYRIC, SPUtil.LYRIC_KEY.DEFAULT_PRIORITY)
66-
try {
67-
DiskCache.getLrcDiskCache().delete()
68-
} catch (e: Exception) {
69-
Timber.v(e)
70-
}
71-
}
72-
7362
val oldVersion = SPUtil.getValue(context, SETTING_KEY.NAME, SETTING_KEY.VERSION, 1)
7463
if (oldVersion < SETTING_KEY.NEWEST_VERSION) {
7564
if (oldVersion == 1) {
@@ -84,7 +73,6 @@ class App : MultiDexApplication() {
8473
}
8574

8675
private fun setUp() {
87-
DiskCache.init(this, "lyric")
8876
setApplicationLanguage(this)
8977
Completable
9078
.fromAction {

app/src/main/java/remix/myplayer/bean/misc/LyricPriority.kt

-48
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package remix.myplayer.helper
2+
3+
import remix.myplayer.lyrics.LyricsLine
4+
import remix.myplayer.ui.widget.desktop.DesktopLyricsView
5+
6+
object LyricsHelper {
7+
fun getDesktopLyricsContent(
8+
lyrics: List<LyricsLine>, offset: Int, progress: Int, duration: Int
9+
): DesktopLyricsView.Content {
10+
if (lyrics.isEmpty()) {
11+
return DesktopLyricsView.Content(LyricsLine.LYRICS_LINE_NO_LRC, null, 1, 1)
12+
}
13+
val progressWithOffset = progress + offset
14+
val index = lyrics.binarySearchBy(progressWithOffset) { it.time }.let {
15+
if (it < 0) -(it + 1) - 1 else it
16+
}
17+
if (index < 0) {
18+
check(index == -1)
19+
return DesktopLyricsView.Content(null, lyrics[0], 1, 1)
20+
}
21+
check(index < lyrics.size)
22+
return DesktopLyricsView.Content(
23+
lyrics[index],
24+
lyrics.getOrNull(index + 1),
25+
progressWithOffset,
26+
lyrics.getOrNull(index + 1)?.time ?: (duration + offset)
27+
)
28+
}
29+
}

app/src/main/java/remix/myplayer/helper/MusicServiceRemote.kt

-5
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,4 @@ object MusicServiceRemote {
163163
fun getOperation(): Int {
164164
return service?.operation ?: Command.NEXT
165165
}
166-
167-
@JvmStatic
168-
fun setLyricOffset(offset: Int) {
169-
service?.setLyricOffset(offset)
170-
}
171166
}

app/src/main/java/remix/myplayer/lyric/DefaultLrcParser.kt

-149
This file was deleted.

app/src/main/java/remix/myplayer/lyric/ILrcParser.kt

-16
This file was deleted.

app/src/main/java/remix/myplayer/lyric/ILrcView.kt

-35
This file was deleted.

0 commit comments

Comments
 (0)