From d94c63d0ea1fec78bbd92e9f58c8a3473584f52f Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Oct 2020 23:11:19 +0200 Subject: [PATCH] open Track activity from Songs on click too --- .../musicplayer/activities/SongsActivity.kt | 7 ++++++- .../musicplayer/activities/TrackActivity.kt | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SongsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SongsActivity.kt index 705b38ea..52c82da4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SongsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SongsActivity.kt @@ -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 } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt index 6ead4dfc..c6caeeca 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt @@ -27,8 +27,7 @@ class TrackActivity : SimpleActivity() { } val trackType = object : TypeToken() {}.type - val song = Gson().fromJson(intent.getStringExtra(TRACK), trackType) - title = song.title + val track = Gson().fromJson(intent.getStringExtra(TRACK), trackType) } override fun onResume() {