Skip to content

Commit

Permalink
core: tweak AssetProvider prepare logic
Browse files Browse the repository at this point in the history
  • Loading branch information
LeHaine committed Jul 20, 2024
1 parent a31bc74 commit 07a27af
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/commonMain/kotlin/com/littlekt/AssetProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ open class AssetProvider(val context: Context) {
/** Updates to check if all assets have been loaded, and if so, prepare them. */
fun update() {
if (totalAssetsLoading.value > 0) return
if (job?.isActive != true) {
if (job?.isActive != true && assetsToPrepare.isNotEmpty()) {
val prepare = assetsToPrepare.toList()
assetsToPrepare.clear()
job =
KtScope.launch {
assetsToPrepare.fastForEach { it.prepare() }
assetsToPrepare.clear()
prepare.fastForEach { it.prepare() }
onFullyLoaded?.invoke()
}
}
Expand Down

0 comments on commit 07a27af

Please sign in to comment.