2019-04-20 05:29:45 +00:00
|
|
|
package code.name.monkey.retromusic.activities
|
2018-12-06 08:52:57 +00:00
|
|
|
|
2020-02-22 12:10:12 +00:00
|
|
|
import android.R.attr
|
2018-12-06 08:52:57 +00:00
|
|
|
import android.annotation.SuppressLint
|
2019-03-28 13:32:53 +00:00
|
|
|
import android.content.res.ColorStateList
|
2019-12-01 15:27:01 +00:00
|
|
|
import android.os.AsyncTask
|
|
|
|
import android.os.Build
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.text.InputType
|
|
|
|
import android.text.TextUtils
|
2019-12-30 11:01:50 +00:00
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.MenuItem
|
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
|
|
|
import android.view.WindowManager
|
2019-04-09 17:29:48 +00:00
|
|
|
import androidx.annotation.StringRes
|
2018-12-06 08:52:57 +00:00
|
|
|
import androidx.core.content.ContextCompat
|
2019-12-01 15:27:01 +00:00
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
import androidx.fragment.app.FragmentManager
|
|
|
|
import androidx.fragment.app.FragmentStatePagerAdapter
|
2018-12-25 14:58:47 +00:00
|
|
|
import androidx.viewpager.widget.ViewPager
|
2018-12-06 08:52:57 +00:00
|
|
|
import code.name.monkey.appthemehelper.ThemeStore
|
2019-12-30 11:01:50 +00:00
|
|
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
2020-02-22 12:10:12 +00:00
|
|
|
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
2019-12-30 11:01:50 +00:00
|
|
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
|
|
|
import code.name.monkey.appthemehelper.util.MaterialUtil
|
|
|
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
|
|
|
import code.name.monkey.appthemehelper.util.TintHelper
|
|
|
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
2019-12-01 15:27:01 +00:00
|
|
|
import code.name.monkey.retromusic.App
|
2018-12-06 08:52:57 +00:00
|
|
|
import code.name.monkey.retromusic.R
|
2019-05-16 18:52:48 +00:00
|
|
|
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
|
|
|
import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask
|
|
|
|
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
2019-12-01 15:27:01 +00:00
|
|
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|
|
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
|
|
|
import code.name.monkey.retromusic.lyrics.LrcHelper
|
|
|
|
import code.name.monkey.retromusic.lyrics.LrcView
|
2018-12-06 08:52:57 +00:00
|
|
|
import code.name.monkey.retromusic.model.Song
|
|
|
|
import code.name.monkey.retromusic.model.lyrics.Lyrics
|
2019-12-01 15:27:01 +00:00
|
|
|
import code.name.monkey.retromusic.util.LyricUtil
|
|
|
|
import code.name.monkey.retromusic.util.MusicUtil
|
|
|
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
|
|
import code.name.monkey.retromusic.util.RetroUtil
|
|
|
|
import com.afollestad.materialdialogs.LayoutMode
|
|
|
|
import com.afollestad.materialdialogs.MaterialDialog
|
2019-05-16 18:52:48 +00:00
|
|
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
2019-12-01 15:27:01 +00:00
|
|
|
import com.afollestad.materialdialogs.input.getInputLayout
|
|
|
|
import com.afollestad.materialdialogs.input.input
|
2019-12-30 11:01:50 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_lyrics.fab
|
|
|
|
import kotlinx.android.synthetic.main.activity_lyrics.tabs
|
|
|
|
import kotlinx.android.synthetic.main.activity_lyrics.toolbar
|
|
|
|
import kotlinx.android.synthetic.main.activity_lyrics.viewPager
|
|
|
|
import kotlinx.android.synthetic.main.fragment_lyrics.offlineLyrics
|
|
|
|
import kotlinx.android.synthetic.main.fragment_synced.lyricsView
|
2018-12-06 08:52:57 +00:00
|
|
|
import org.jaudiotagger.tag.FieldKey
|
|
|
|
import java.io.File
|
2019-12-30 11:01:50 +00:00
|
|
|
import java.util.EnumMap
|
2018-12-06 08:52:57 +00:00
|
|
|
|
2018-12-25 14:58:47 +00:00
|
|
|
class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPager.OnPageChangeListener {
|
2019-12-01 15:27:01 +00:00
|
|
|
override fun onPageScrollStateChanged(state: Int) {
|
|
|
|
when (state) {
|
|
|
|
ViewPager.SCROLL_STATE_IDLE -> fab.show()
|
2019-12-16 05:06:08 +00:00
|
|
|
ViewPager.SCROLL_STATE_DRAGGING,
|
|
|
|
ViewPager.SCROLL_STATE_SETTLING -> fab.hide()
|
2019-12-01 15:27:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onPageSelected(position: Int) {
|
|
|
|
PreferenceUtil.getInstance(this).lyricsOptions = position
|
|
|
|
if (position == 0) fab.text = getString(R.string.synced_lyrics)
|
|
|
|
else if (position == 1) fab.text = getString(R.string.lyrics)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onClick(v: View?) {
|
|
|
|
when (viewPager.currentItem) {
|
|
|
|
0 -> showSyncedLyrics()
|
|
|
|
1 -> showLyricsSaveDialog()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private lateinit var song: Song
|
|
|
|
private var lyricsString: String? = null
|
|
|
|
|
|
|
|
private val googleSearchLrcUrl: String
|
|
|
|
get() {
|
|
|
|
var baseUrl = "http://www.google.com/search?"
|
|
|
|
var query = song.title + "+" + song.artistName
|
|
|
|
query = "q=" + query.replace(" ", "+") + " .lrc"
|
|
|
|
baseUrl += query
|
|
|
|
return baseUrl
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContentView(R.layout.activity_lyrics)
|
|
|
|
setStatusbarColorAuto()
|
|
|
|
setTaskDescriptionColorAuto()
|
2019-12-05 18:18:54 +00:00
|
|
|
setNavigationbarColorAuto()
|
2019-12-01 15:27:01 +00:00
|
|
|
|
|
|
|
fab.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
|
2019-12-30 11:01:50 +00:00
|
|
|
ColorStateList.valueOf(
|
|
|
|
MaterialValueHelper.getPrimaryTextColor(
|
|
|
|
this,
|
|
|
|
ColorUtil.isColorLight(ThemeStore.accentColor(this))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.apply {
|
|
|
|
fab.setTextColor(this)
|
|
|
|
fab.iconTint = this
|
|
|
|
}
|
2019-12-01 15:27:01 +00:00
|
|
|
setupWakelock()
|
|
|
|
|
|
|
|
viewPager.apply {
|
|
|
|
adapter = PagerAdapter(supportFragmentManager)
|
|
|
|
currentItem = PreferenceUtil.getInstance(this@LyricsActivity).lyricsOptions
|
|
|
|
addOnPageChangeListener(this@LyricsActivity)
|
|
|
|
}
|
|
|
|
|
2019-12-16 05:06:08 +00:00
|
|
|
val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
|
|
|
toolbar.setBackgroundColor(toolbarColor)
|
|
|
|
tabs.setBackgroundColor(toolbarColor)
|
|
|
|
ToolbarContentTintHelper.colorBackButton(toolbar)
|
2019-12-22 16:36:11 +00:00
|
|
|
setSupportActionBar(toolbar)
|
2019-12-16 05:06:08 +00:00
|
|
|
tabs.setupWithViewPager(viewPager)
|
2019-12-30 11:01:50 +00:00
|
|
|
tabs.setSelectedTabIndicator(
|
|
|
|
TintHelper.createTintedDrawable(
|
|
|
|
ContextCompat.getDrawable(
|
|
|
|
this,
|
|
|
|
R.drawable.tab_indicator
|
|
|
|
), ThemeStore.accentColor(this)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
tabs.setTabTextColors(
|
|
|
|
ATHUtil.resolveColor(this, android.R.attr.textColorSecondary),
|
|
|
|
ThemeStore.accentColor(this)
|
|
|
|
)
|
2019-12-16 05:06:08 +00:00
|
|
|
tabs.setSelectedTabIndicatorColor(ThemeStore.accentColor(this))
|
|
|
|
|
2019-12-01 15:27:01 +00:00
|
|
|
fab.setOnClickListener(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onPlayingMetaChanged() {
|
|
|
|
super.onPlayingMetaChanged()
|
2019-12-16 05:06:08 +00:00
|
|
|
updateTitleSong()
|
2019-12-01 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onServiceConnected() {
|
|
|
|
super.onServiceConnected()
|
2019-12-16 05:06:08 +00:00
|
|
|
updateTitleSong()
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun updateTitleSong() {
|
2019-12-01 15:27:01 +00:00
|
|
|
song = MusicPlayerRemote.currentSong
|
|
|
|
toolbar.title = song.title
|
|
|
|
toolbar.subtitle = song.artistName
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun setupWakelock() {
|
|
|
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
|
|
if (item.itemId == android.R.id.home) {
|
2019-12-22 16:36:11 +00:00
|
|
|
finish()
|
|
|
|
return true
|
2019-12-01 15:27:01 +00:00
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(item)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun showSyncedLyrics() {
|
|
|
|
var content = ""
|
|
|
|
try {
|
2019-12-19 19:26:06 +00:00
|
|
|
content = LyricUtil.getStringFromFile(song.title, song.artistName)
|
2019-12-01 15:27:01 +00:00
|
|
|
} catch (e: Exception) {
|
|
|
|
e.printStackTrace()
|
|
|
|
}
|
|
|
|
|
2019-12-19 19:26:06 +00:00
|
|
|
val materialDialog = MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT))
|
2019-12-30 11:01:50 +00:00
|
|
|
.show {
|
|
|
|
cornerRadius(PreferenceUtil.getInstance(this@LyricsActivity).dialogCorner)
|
|
|
|
title(R.string.add_time_framed_lryics)
|
|
|
|
negativeButton(R.string.action_search) {
|
|
|
|
RetroUtil.openUrl(this@LyricsActivity, googleSearchLrcUrl)
|
|
|
|
}
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
positiveButton(android.R.string.ok) {
|
|
|
|
updateSong()
|
2019-12-19 19:26:06 +00:00
|
|
|
}
|
2019-12-30 11:01:50 +00:00
|
|
|
}
|
2019-12-19 19:26:06 +00:00
|
|
|
|
2019-12-01 15:27:01 +00:00
|
|
|
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun updateSong() {
|
2019-12-30 11:01:50 +00:00
|
|
|
val page =
|
|
|
|
supportFragmentManager.findFragmentByTag("android:switcher:" + R.id.viewPager + ":" + viewPager.currentItem)
|
2019-12-01 15:27:01 +00:00
|
|
|
if (viewPager.currentItem == 0 && page != null) {
|
|
|
|
(page as BaseLyricsFragment).upDateSong()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun showLyricsSaveDialog() {
|
|
|
|
val content: String = if (lyricsString == null) {
|
|
|
|
""
|
|
|
|
} else {
|
|
|
|
lyricsString!!
|
|
|
|
}
|
|
|
|
|
|
|
|
val materialDialog = MaterialDialog(
|
2019-12-30 11:01:50 +00:00
|
|
|
this, BottomSheet(LayoutMode.WRAP_CONTENT)
|
2019-12-01 15:27:01 +00:00
|
|
|
).show {
|
2019-12-19 19:26:06 +00:00
|
|
|
cornerRadius(PreferenceUtil.getInstance(this@LyricsActivity).dialogCorner)
|
2019-12-01 15:27:01 +00:00
|
|
|
title(R.string.add_lyrics)
|
|
|
|
negativeButton(R.string.action_search) {
|
2019-12-19 19:26:06 +00:00
|
|
|
RetroUtil.openUrl(this@LyricsActivity, getGoogleSearchUrl())
|
2019-12-01 15:27:01 +00:00
|
|
|
}
|
|
|
|
input(
|
2019-12-30 11:01:50 +00:00
|
|
|
hint = getString(R.string.paste_lyrics_here),
|
|
|
|
prefill = content,
|
|
|
|
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
2019-12-01 15:27:01 +00:00
|
|
|
) { _, input ->
|
|
|
|
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
|
|
|
fieldKeyValueMap[FieldKey.LYRICS] = input.toString()
|
|
|
|
WriteTagsAsyncTask(this@LyricsActivity).execute(
|
2019-12-30 11:01:50 +00:00
|
|
|
WriteTagsAsyncTask.LoadingInfo(
|
|
|
|
getSongPaths(song), fieldKeyValueMap, null
|
|
|
|
)
|
2019-12-01 15:27:01 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
positiveButton(android.R.string.ok) {
|
|
|
|
updateSong()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun getSongPaths(song: Song): ArrayList<String> {
|
|
|
|
val paths = ArrayList<String>(1)
|
|
|
|
paths.add(song.data)
|
|
|
|
return paths
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun getGoogleSearchUrl(): String {
|
|
|
|
var baseUrl = "http://www.google.com/search?"
|
|
|
|
var query = song.title + "+" + song.artistName
|
|
|
|
query = "q=" + query.replace(" ", "+") + " lyrics"
|
|
|
|
baseUrl += query
|
|
|
|
return baseUrl
|
|
|
|
}
|
|
|
|
|
|
|
|
class PagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(
|
2019-12-30 11:01:50 +00:00
|
|
|
fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
|
2019-12-01 15:27:01 +00:00
|
|
|
) {
|
2019-12-30 11:01:50 +00:00
|
|
|
|
2019-12-01 15:27:01 +00:00
|
|
|
class Tabs(
|
2019-12-30 11:01:50 +00:00
|
|
|
@StringRes val title: Int, val fragment: Fragment
|
2019-12-01 15:27:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
private var tabs = ArrayList<Tabs>()
|
|
|
|
|
|
|
|
init {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
|
|
tabs.add(Tabs(R.string.synced_lyrics, SyncedLyricsFragment()))
|
|
|
|
}
|
|
|
|
tabs.add(Tabs(R.string.normal_lyrics, OfflineLyricsFragment()))
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getItem(position: Int): Fragment {
|
|
|
|
return tabs[position].fragment
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getPageTitle(position: Int): CharSequence? {
|
|
|
|
return App.getContext().getString(tabs[position].title)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getCount(): Int {
|
|
|
|
return tabs.size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class BaseLyricsFragment : AbsMusicServiceFragment() {
|
|
|
|
abstract fun upDateSong()
|
|
|
|
|
|
|
|
override fun onPlayingMetaChanged() {
|
|
|
|
super.onPlayingMetaChanged()
|
|
|
|
upDateSong()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onServiceConnected() {
|
|
|
|
super.onServiceConnected()
|
|
|
|
upDateSong()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class OfflineLyricsFragment : BaseLyricsFragment() {
|
|
|
|
override fun upDateSong() {
|
|
|
|
loadSongLyrics()
|
|
|
|
}
|
|
|
|
|
|
|
|
private var updateLyricsAsyncTask: AsyncTask<*, *, *>? = null
|
|
|
|
private var lyrics: Lyrics? = null
|
|
|
|
|
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
private fun loadSongLyrics() {
|
|
|
|
if (updateLyricsAsyncTask != null) {
|
|
|
|
updateLyricsAsyncTask!!.cancel(false)
|
|
|
|
}
|
|
|
|
val song = MusicPlayerRemote.currentSong
|
|
|
|
updateLyricsAsyncTask = object : AsyncTask<Void?, Void?, Lyrics?>() {
|
|
|
|
override fun doInBackground(vararg params: Void?): Lyrics? {
|
|
|
|
val data = MusicUtil.getLyrics(song)
|
|
|
|
return if (TextUtils.isEmpty(data)) {
|
|
|
|
null
|
|
|
|
} else Lyrics.parse(song, data!!)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onPreExecute() {
|
|
|
|
super.onPreExecute()
|
|
|
|
lyrics = null
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onPostExecute(l: Lyrics?) {
|
|
|
|
lyrics = l
|
|
|
|
offlineLyrics?.visibility = View.VISIBLE
|
|
|
|
if (l == null) {
|
|
|
|
offlineLyrics?.setText(R.string.no_lyrics_found)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
(activity as LyricsActivity).lyricsString = l.text
|
|
|
|
offlineLyrics?.text = l.text
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onCancelled(s: Lyrics?) {
|
|
|
|
onPostExecute(null)
|
|
|
|
}
|
|
|
|
}.execute()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
|
|
super.onActivityCreated(savedInstanceState)
|
|
|
|
loadSongLyrics()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onDestroyView() {
|
|
|
|
super.onDestroyView()
|
|
|
|
if (updateLyricsAsyncTask != null && !updateLyricsAsyncTask!!.isCancelled) {
|
|
|
|
updateLyricsAsyncTask?.cancel(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onCreateView(
|
2019-12-30 11:01:50 +00:00
|
|
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
2019-12-01 15:27:01 +00:00
|
|
|
): View? {
|
|
|
|
return inflater.inflate(R.layout.fragment_lyrics, container, false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SyncedLyricsFragment : BaseLyricsFragment(), MusicProgressViewUpdateHelper.Callback {
|
|
|
|
override fun upDateSong() {
|
|
|
|
loadLRCLyrics()
|
|
|
|
}
|
|
|
|
|
|
|
|
private lateinit var updateHelper: MusicProgressViewUpdateHelper
|
|
|
|
override fun onCreateView(
|
2019-12-30 11:01:50 +00:00
|
|
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
2019-12-01 15:27:01 +00:00
|
|
|
): View? {
|
|
|
|
return inflater.inflate(R.layout.fragment_synced, container, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
updateHelper = MusicProgressViewUpdateHelper(this, 500, 1000)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
setupLyricsView()
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun setupLyricsView() {
|
|
|
|
lyricsView.apply {
|
|
|
|
val context = activity!!
|
|
|
|
setCurrentPlayLineColor(ThemeStore.accentColor(context))
|
|
|
|
setIndicatorTextColor(ThemeStore.accentColor(context))
|
2020-02-22 12:10:12 +00:00
|
|
|
setCurrentIndicateLineTextColor(resolveColor(activity, attr.textColorPrimary))
|
|
|
|
setNoLrcTextColor(resolveColor(activity, attr.textColorPrimary))
|
2019-12-01 15:27:01 +00:00
|
|
|
setOnPlayIndicatorLineListener(object : LrcView.OnPlayIndicatorLineListener {
|
|
|
|
override fun onPlay(time: Long, content: String) {
|
|
|
|
MusicPlayerRemote.seekTo(time.toInt())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onResume() {
|
|
|
|
super.onResume()
|
|
|
|
updateHelper.start()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onPause() {
|
|
|
|
super.onPause()
|
|
|
|
updateHelper.stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
|
|
|
lyricsView.updateTime(progress.toLong())
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun loadLRCLyrics() {
|
2019-12-19 19:29:02 +00:00
|
|
|
lyricsView.resetView("Empty")
|
2019-12-01 15:27:01 +00:00
|
|
|
val song = MusicPlayerRemote.currentSong
|
2019-12-19 19:26:06 +00:00
|
|
|
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
|
|
|
|
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName))
|
2019-12-01 15:27:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun showLyricsLocal(file: File?) {
|
|
|
|
if (file != null) {
|
|
|
|
lyricsView.setLrcData(LrcHelper.parseLrcFromFile(file))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-24 12:58:12 +00:00
|
|
|
}
|