From 19857643403cc5b2340e208a3330c034876baaa6 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sat, 20 Nov 2021 14:07:09 +0300 Subject: [PATCH] Fix ConcurrentModificationException caused by coroutines --- .../mealient/data/recipes/impl/RecipePagingSourceFactory.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipePagingSourceFactory.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipePagingSourceFactory.kt index 2070107..a3c14e6 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipePagingSourceFactory.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipePagingSourceFactory.kt @@ -13,6 +13,7 @@ class RecipePagingSourceFactory @Inject constructor( ) : () -> PagingSource { private val sources: MutableList> = mutableListOf() + @Synchronized override fun invoke(): PagingSource { Timber.v("invoke() called") val newSource = recipeStorage.queryRecipes() @@ -20,6 +21,7 @@ class RecipePagingSourceFactory @Inject constructor( return newSource } + @Synchronized fun invalidate() { Timber.v("invalidate() called") for (source in sources) {