open Track activity from Songs on click too

This commit is contained in:
tibbi 2020-10-06 23:11:19 +02:00
parent 9d9e065c4d
commit d94c63d0ea
2 changed files with 7 additions and 3 deletions

View file

@ -1,6 +1,7 @@
package com.simplemobiletools.musicplayer.activities
import android.content.ContentUris
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import com.google.gson.Gson
@ -9,6 +10,7 @@ import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.adapters.SongsAdapter
import com.simplemobiletools.musicplayer.extensions.getSongs
import com.simplemobiletools.musicplayer.helpers.ALBUM
import com.simplemobiletools.musicplayer.helpers.TRACK
import com.simplemobiletools.musicplayer.helpers.artworkUri
import com.simplemobiletools.musicplayer.models.Album
import com.simplemobiletools.musicplayer.models.AlbumHeader
@ -34,7 +36,10 @@ class SongsActivity : SimpleActivity() {
runOnUiThread {
SongsAdapter(this, items, songs_list) {
Intent(this, TrackActivity::class.java).apply {
putExtra(TRACK, Gson().toJson(it))
startActivity(this)
}
}.apply {
songs_list.adapter = this
}

View file

@ -27,8 +27,7 @@ class TrackActivity : SimpleActivity() {
}
val trackType = object : TypeToken<Song>() {}.type
val song = Gson().fromJson<Song>(intent.getStringExtra(TRACK), trackType)
title = song.title
val track = Gson().fromJson<Song>(intent.getStringExtra(TRACK), trackType)
}
override fun onResume() {