Skip to content

Commit

Permalink
- MainActivity: parallel update checks (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobi823 committed Feb 20, 2025
1 parent 51e0c28 commit f54c93c
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ import de.marmaro.krt.ffupdater.settings.DataStoreHelper
import de.marmaro.krt.ffupdater.settings.ForegroundSettings
import de.marmaro.krt.ffupdater.settings.NoUnmeteredNetworkException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

@Keep
class MainActivity : AppCompatActivity() {
Expand Down Expand Up @@ -193,8 +197,10 @@ class MainActivity : AppCompatActivity() {
}

showLoadAnimationDuringExecution {
apps.forEach {
updateMetadataOf(it)
coroutineScope {
apps.map {
async { updateMetadataOf(it) }
}.awaitAll()
}
}
}
Expand All @@ -210,8 +216,9 @@ class MainActivity : AppCompatActivity() {
private suspend fun updateMetadataOf(app: App): InstalledAppStatus? {
try {
recyclerView.notifyAppChange(app, null)
val updateStatus = app.findImpl()
.findStatusOrUseRecentCache(applicationContext)
val updateStatus = withContext(Dispatchers.IO) {
app.findImpl().findStatusOrUseRecentCache(applicationContext)
}
recyclerView.notifyAppChange(app, updateStatus)
recyclerView.notifyClearedErrorForApp(app)
return updateStatus
Expand Down

0 comments on commit f54c93c

Please sign in to comment.