From 92ff19b2068502574769440b84c55f7301966ce6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 14 Mar 2022 21:45:16 +0100 Subject: [PATCH] update all fragments after refetching files --- .../musicplayer/activities/MainActivity.kt | 9 +++++++-- .../simplemobiletools/musicplayer/extensions/Context.kt | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt index c9b68d7e..ba9c233b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt @@ -194,7 +194,11 @@ class MainActivity : SimpleActivity() { } } - updateAllDatabases() + updateAllDatabases { + getAllFragments().forEach { + it?.setupFragment(this) + } + } } private fun initFragments() { @@ -377,7 +381,8 @@ class MainActivity : SimpleActivity() { } } - private fun getAllFragments() = arrayListOf(playlists_fragment_holder, artists_fragment_holder, albums_fragment_holder, tracks_fragment_holder) + private fun getAllFragments() = + arrayListOf(playlists_fragment_holder, folders_fragment_holder, artists_fragment_holder, albums_fragment_holder, tracks_fragment_holder) @Subscribe(threadMode = ThreadMode.MAIN) fun trackChangedEvent(event: Events.TrackChanged) { diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/Context.kt index 6335ff84..e136199f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/Context.kt @@ -284,10 +284,11 @@ fun Context.getAllInitialTracks(): ArrayList { } // store new artists, albums and tracks into our local db, delete invalid items -fun Context.updateAllDatabases() { +fun Context.updateAllDatabases(callback: () -> Unit) { ensureBackgroundThread { updateCachedArtists { artists -> updateCachedAlbums(artists) + callback() } } }