From f43360a5b0a2a3734649300ff0016dfb093ec0b4 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sun, 10 Feb 2019 11:38:01 -0800 Subject: [PATCH] Repaired up navigation in TrackListActivity --- .../io/casey/musikcube/remote/Application.kt | 2 +- .../activity/FragmentActivityWithTransport.kt | 3 +++ .../ui/tracks/activity/TrackListActivity.kt | 5 ++++- .../ui/tracks/fragment/TrackListFragment.kt | 20 ++++++++++++------- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/Application.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/Application.kt index 77f689d5d..8f4e07d92 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/Application.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/Application.kt @@ -17,7 +17,7 @@ import javax.inject.Inject class Application : android.app.Application() { @Inject lateinit var gaplessService: GaplessHeaderService - @Inject lateinit var offlineDb: OfflineDb + @Inject @Suppress("unused") lateinit var offlineDb: OfflineDb override fun onCreate() { instance = this diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/activity/FragmentActivityWithTransport.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/activity/FragmentActivityWithTransport.kt index af4091aaa..c1c740672 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/activity/FragmentActivityWithTransport.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/activity/FragmentActivityWithTransport.kt @@ -11,7 +11,10 @@ import io.casey.musikcube.remote.ui.shared.fragment.TransportFragment abstract class FragmentActivityWithTransport: BaseActivity(), Filterable { protected lateinit var transport: TransportFragment + private set + protected lateinit var content: BaseFragment + private set override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/activity/TrackListActivity.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/activity/TrackListActivity.kt index 531bfb0f8..ae141a072 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/activity/TrackListActivity.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/activity/TrackListActivity.kt @@ -20,7 +20,10 @@ class TrackListActivity : FragmentActivityWithTransport(), Filterable { tracks.createOptionsMenu(menu) override fun onOptionsItemSelected(item: MenuItem): Boolean = - tracks.optionsItemSelected(item) + when (tracks.optionsItemSelected(item)) { + true -> true + false -> super.onOptionsItemSelected(item) + } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) = tracks.activityResult(requestCode, resultCode, data) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/fragment/TrackListFragment.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/fragment/TrackListFragment.kt index c52cbe875..c7353eba1 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/fragment/TrackListFragment.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/fragment/TrackListFragment.kt @@ -134,13 +134,19 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider { return true } - fun optionsItemSelected(item: MenuItem): Boolean { - if (item.itemId == R.id.action_edit) { - startActivityForResult(EditPlaylistActivity.getStartIntent( - appCompatActivity, categoryValue, categoryId), Track.RequestCode.EDIT_PLAYLIST) + fun optionsItemSelected(item: MenuItem): Boolean = + when (item.itemId == R.id.action_edit) { + true -> { + appCompatActivity.startActivityForResult( + EditPlaylistActivity.getStartIntent( + appCompatActivity, + categoryValue, + categoryId), + Track.RequestCode.EDIT_PLAYLIST) + true + } + else -> false } - return super.onOptionsItemSelected(item) - } fun activityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (requestCode == Track.RequestCode.EDIT_PLAYLIST && resultCode == AppCompatActivity.RESULT_OK && data != null) { @@ -154,7 +160,7 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider { buttonText = getString(R.string.button_view), buttonCb = { startActivity(TrackListActivity.getStartIntent( - appCompatActivity, Messages.Category.PLAYLISTS, playlistId, playlistName)) + appCompatActivity, Messages.Category.PLAYLISTS, playlistId, playlistName)) }) } }