Update LyricsActivity.kt

This commit is contained in:
tva2000hn 2019-09-24 19:58:12 +07:00 committed by GitHub
parent da712f4576
commit 045cdf79f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.InputType import android.text.InputType
import android.text.TextUtils import android.text.TextUtils
import android.util.Log
import android.view.* import android.view.*
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
@ -151,8 +152,13 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
private fun showSyncedLyrics() { private fun showSyncedLyrics() {
var content = "" var content = ""
try { try {
content = LyricUtil.getStringFromFile(song.title, song.artistName) content = LyricUtil.getStringFromFile(song.data, song.artistName)
} catch (e: Exception) { } catch (e: Exception) {
try{
content = LyricUtil.getStringFromFile(song.title, song.artistName)
} catch ( e2 : Exception){
}
e.printStackTrace() e.printStackTrace()
} }
@ -162,7 +168,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
input(hint = getString(R.string.paste_lyrics_here), input(hint = getString(R.string.paste_lyrics_here),
prefill = content, prefill = content,
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) { _, input -> inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) { _, input ->
LyricUtil.writeLrcToLoc(song.title, song.artistName, input.toString()) LyricUtil.writeLrcToLoc(song.data, song.artistName, input.toString())
} }
positiveButton(android.R.string.ok) { positiveButton(android.R.string.ok) {
updateSong() updateSong()
@ -365,8 +371,12 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
private fun loadLRCLyrics() { private fun loadLRCLyrics() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) { if (LyricUtil.isLrcFile2Exist(song.data, song.artistName)) {
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName)) showLyricsLocal(LyricUtil.getLocalLyricFile(song.data, song.artistName))
} else {
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName))
}
} }
} }
@ -376,4 +386,4 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
} }
} }
} }
} }