From 5a3fe765da10cd18cb4fde1a0af027f26713d385 Mon Sep 17 00:00:00 2001 From: vojtasmrcek Date: Thu, 2 Nov 2023 10:39:56 +0100 Subject: [PATCH] Clear views with delay to fix a crash --- .../org/wordpress/aztec/placeholders/PlaceholderManager.kt | 5 +++-- settings.gradle | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/media-placeholders/src/main/java/org/wordpress/aztec/placeholders/PlaceholderManager.kt b/media-placeholders/src/main/java/org/wordpress/aztec/placeholders/PlaceholderManager.kt index c4898c100..ff95be985 100644 --- a/media-placeholders/src/main/java/org/wordpress/aztec/placeholders/PlaceholderManager.kt +++ b/media-placeholders/src/main/java/org/wordpress/aztec/placeholders/PlaceholderManager.kt @@ -20,6 +20,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlinx.coroutines.withContext import org.wordpress.aztec.AztecAttributes import org.wordpress.aztec.AztecContentChangeWatcher import org.wordpress.aztec.AztecText @@ -519,7 +520,7 @@ class PlaceholderManager( } } - private suspend fun clearAllViews() { + private suspend fun clearAllViews() = withContext(Dispatchers.Main){ positionToIdMutex.withLock { for (placeholder in positionToId) { container.findViewWithTag(placeholder.uuid)?.let { @@ -664,7 +665,7 @@ class PlaceholderManager( } override fun beforeHtmlProcessed(source: String): String { - runBlocking { + launch { clearAllViews() } return source diff --git a/settings.gradle b/settings.gradle index ed67ef1fb..811816072 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,6 @@ pluginManagement { gradle.ext.kotlinVersion = '1.6.10' - gradle.ext.agpVersion = '8.1.0' + gradle.ext.agpVersion = '8.1.2' gradle.ext.automatticPublishToS3Version = '0.8.0' plugins {