From 5e6a3e0f67d85e39ddcb99c3c630628da3ad97f6 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Tue, 17 Dec 2024 13:11:30 +0200 Subject: [PATCH] Fix ANR caused by URL checking for Github URL with query --- .../screens/modmanager/ModManagementScreen.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/core/src/com/unciv/ui/screens/modmanager/ModManagementScreen.kt b/core/src/com/unciv/ui/screens/modmanager/ModManagementScreen.kt index d830b963a01e1..dcc15b6f963f3 100644 --- a/core/src/com/unciv/ui/screens/modmanager/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/screens/modmanager/ModManagementScreen.kt @@ -414,15 +414,19 @@ class ModManagementScreen private constructor( actualDownloadButton.onClick { actualDownloadButton.setText("Downloading...".tr()) actualDownloadButton.disable() - val repo = GithubAPI.Repo.parseUrl(textField.text) - if (repo == null) { - ToastPopup("«RED»{Invalid link!}«»", this@ModManagementScreen) - actualDownloadButton.setText("Download".tr()) - actualDownloadButton.enable() - } else - downloadMod(repo, { - actualDownloadButton.setText("{Downloading...} ${it}%".tr()) - }) { popup.close() } + Concurrency.run { + val repo = GithubAPI.Repo.parseUrl(textField.text) + if (repo == null) { + Concurrency.runOnGLThread { + ToastPopup("«RED»{Invalid link!}«»", this@ModManagementScreen) + actualDownloadButton.setText("Download".tr()) + actualDownloadButton.enable() + } + } else + downloadMod(repo, { + actualDownloadButton.setText("{Downloading...} ${it}%".tr()) + }) { popup.close() } + } } popup.add(actualDownloadButton).row() popup.addCloseButton()