File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
data/provider/src/main/kotlin/com/flixclusive/data/provider
domain/updater/src/main/kotlin/com/flixclusive/domain/updater Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import com.flixclusive.provider.Provider
3131import com.flixclusive.provider.settings.ProviderSettings
3232import dagger.hilt.android.qualifiers.ApplicationContext
3333import dalvik.system.PathClassLoader
34+ import kotlinx.coroutines.CompletableDeferred
3435import kotlinx.coroutines.flow.first
3536import kotlinx.coroutines.launch
3637import okhttp3.OkHttpClient
@@ -58,6 +59,7 @@ class ProviderManager @Inject constructor(
5859 private val classLoaders: MutableMap <PathClassLoader , Provider > = Collections .synchronizedMap(HashMap ())
5960
6061 private var notificationChannelHasBeenInitialized = false
62+ val initialization = CompletableDeferred <Unit >()
6163
6264 /* *
6365 * An observable map of provider data
@@ -117,6 +119,8 @@ class ProviderManager @Inject constructor(
117119
118120 notificationChannelHasBeenInitialized = true
119121 }
122+
123+ initialization.complete(Unit )
120124 }
121125 }
122126
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ class ProviderUpdaterUseCase @Inject constructor(
4343 private var notificationChannelHasBeenInitialized = false
4444
4545 suspend fun checkForUpdates (notify : Boolean ) {
46+ // Wait for providers to be initialized
47+ // To avoid ConcurrentModificationException
48+ providerManager.initialization.await()
49+
4650 val appSettingsProvider = appSettingsManager.providerSettings.data.first()
4751
4852 outdatedProviders.clear()
You can’t perform that action at this time.
0 commit comments