show the current track at the Albums screen too
This commit is contained in:
parent
d1afa24e65
commit
8220d2e33c
2 changed files with 42 additions and 0 deletions
|
@ -16,14 +16,24 @@ import com.simplemobiletools.musicplayer.helpers.ARTIST
|
|||
import com.simplemobiletools.musicplayer.helpers.RESTART_PLAYER
|
||||
import com.simplemobiletools.musicplayer.helpers.TRACK
|
||||
import com.simplemobiletools.musicplayer.models.*
|
||||
import com.simplemobiletools.musicplayer.services.MusicService
|
||||
import kotlinx.android.synthetic.main.activity_albums.*
|
||||
import kotlinx.android.synthetic.main.view_current_track_bar.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
// Artists -> Albums -> Tracks
|
||||
class AlbumsActivity : SimpleActivity() {
|
||||
private var bus: EventBus? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_albums)
|
||||
|
||||
bus = EventBus.getDefault()
|
||||
bus!!.register(this)
|
||||
|
||||
val artistType = object : TypeToken<Artist>() {}.type
|
||||
val artist = Gson().fromJson<Artist>(intent.getStringExtra(ARTIST), artistType)
|
||||
title = artist.title
|
||||
|
@ -68,10 +78,36 @@ class AlbumsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_track_bar.setOnClickListener {
|
||||
Intent(this, TrackActivity::class.java).apply {
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateCurrentTrackBar()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
bus?.unregister(this)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
updateMenuItemColors(menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
private fun updateCurrentTrackBar() {
|
||||
current_track_bar.updateColors()
|
||||
current_track_bar.updateCurrentTrack(MusicService.mCurrTrack)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun trackChangedEvent(event: Events.TrackChanged) {
|
||||
current_track_bar.updateCurrentTrack(event.track)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,4 +12,10 @@
|
|||
android:clipToPadding="false"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<include
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/view_current_track_bar"
|
||||
android:layout_alignParentBottom="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in a new issue