mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-10-14 19:27:09 -04:00
Stores: a finished install rebuilds the Installed tab and the Games list
This commit is contained in:
1 parent
b5ae6cc63f
commit
9c0f87a4c8
3 files changed
+20
-2
No files matched your search
@@ -922,8 +922,10 @@ class MainActivity : ComponentActivity() {
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
refreshWifiDiscovery()
|
||||
// Back from a store's sign-in page: the Stores chips show the account at once.
|
||||
// Back from a store's sign-in page: the Stores chips show the account at once. A store
|
||||
// install finishing while this screen is up rebuilds the Games list through the listener.
|
||||
if (gameStoresEnabled) com.droiddeck.launcher.stores.StoresState.refresh(this)
|
||||
com.droiddeck.launcher.stores.StoresState.libraryListener = { refreshAddedGames(); refresh() }
|
||||
com.droiddeck.launcher.ui.Motion.refresh(this)
|
||||
// Back from a session stopped behind a flood: open on its blue, before the first frame.
|
||||
com.droiddeck.launcher.ui.QuitFlood.take()?.let { c ->
|
||||
@@ -981,6 +983,8 @@ class MainActivity : ComponentActivity() {
|
||||
unregisterReceiver(wifiLocationReceiver)
|
||||
unregisterReceiver(mediaReceiver)
|
||||
ui.removeCallbacks(mediaRefresh)
|
||||
// An install finishing while this screen is away is picked up by onResume's refresh.
|
||||
com.droiddeck.launcher.stores.StoresState.libraryListener = null
|
||||
displayManager.unregisterDisplayListener(secondScreenDisplayListener)
|
||||
// The session covers the page by now; coming back finds it as it was.
|
||||
flood = null
|
||||
|
||||
@@ -129,6 +129,15 @@ object StoresState {
|
||||
}, "stores-uninstall").start()
|
||||
}
|
||||
|
||||
/** Told on the main thread when an install or removal changed what is on disk; the launcher rebuilds its Games list. */
|
||||
@Volatile var libraryListener: (() -> Unit)? = null
|
||||
|
||||
/** A game landed or went: the installed set is re-read and the launcher told. Any thread. */
|
||||
fun notifyLibraryChanged(context: Context) {
|
||||
refresh(context)
|
||||
main.post { libraryListener?.invoke() }
|
||||
}
|
||||
|
||||
/** Appends to the engine log with a clock, keeping the last 80 lines. Any thread. */
|
||||
fun logLine(text: String) {
|
||||
val stamped = "${CLOCK.format(Date())} $text"
|
||||
|
||||
@@ -207,8 +207,13 @@ object DownloadQueue {
|
||||
publishLocked()
|
||||
}
|
||||
when (item.entry.state) {
|
||||
DownloadState.INSTALLED -> StoresState.logLine("installed \"${item.entry.name}\" → ${result}")
|
||||
DownloadState.INSTALLED -> {
|
||||
StoresState.logLine("installed \"${item.entry.name}\" → ${result}")
|
||||
// The folder is on disk and registered: the Installed tab and the Games list follow.
|
||||
StoresState.notifyLibraryChanged(context)
|
||||
}
|
||||
DownloadState.FAILED -> StoresState.logLine("${item.entry.store.label}: \"${item.entry.name}\" failed: $error")
|
||||
DownloadState.CANCELLED -> StoresState.notifyLibraryChanged(context)
|
||||
else -> {}
|
||||
}
|
||||
StoreDownloadService.finish(context, item.entry.key)
|
||||
|
||||
Reference in new issue
Block a user