From 045cdf79f95fe60f082ca7c8b06ba3bae21c3f65 Mon Sep 17 00:00:00 2001 From: tva2000hn Date: Tue, 24 Sep 2019 19:58:12 +0700 Subject: [PATCH] Update LyricsActivity.kt --- .../retromusic/activities/LyricsActivity.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt index 45b58a8d..8a42d7e2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt @@ -7,6 +7,7 @@ import android.os.Build import android.os.Bundle import android.text.InputType import android.text.TextUtils +import android.util.Log import android.view.* import androidx.annotation.StringRes import androidx.core.content.ContextCompat @@ -151,8 +152,13 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage private fun showSyncedLyrics() { var content = "" try { - content = LyricUtil.getStringFromFile(song.title, song.artistName) + content = LyricUtil.getStringFromFile(song.data, song.artistName) } catch (e: Exception) { + try{ + content = LyricUtil.getStringFromFile(song.title, song.artistName) + } catch ( e2 : Exception){ + + } e.printStackTrace() } @@ -162,7 +168,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage input(hint = getString(R.string.paste_lyrics_here), prefill = content, 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) { updateSong() @@ -365,8 +371,12 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage private fun loadLRCLyrics() { val song = MusicPlayerRemote.currentSong - if (LyricUtil.isLrcFileExist(song.title, song.artistName)) { - showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName)) + if (LyricUtil.isLrcFile2Exist(song.data, 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 } } } -} \ No newline at end of file +}