From e733a2f3c0bdec46e6461cc8d6c32592b1aa9a52 Mon Sep 17 00:00:00 2001 From: OneWay Date: Sun, 22 Nov 2026 18:15:50 +0800 Subject: [PATCH] perf(import): resolve imported file names off the main thread Importing dictionaries queried the content resolver for each file name on the main thread, blocking the UI while the provider answered. Resolve the display name on the IO dispatcher so the query no longer runs on the main thread. --- .../example/research/feature/import/DictionaryImportManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/research/feature/import/DictionaryImportManager.kt b/app/src/main/java/com/example/research/feature/import/DictionaryImportManager.kt index bb43a0b..f48bcca 100644 --- a/app/src/main/java/com/example/research/feature/import/DictionaryImportManager.kt +++ b/app/src/main/java/com/example/research/feature/import/DictionaryImportManager.kt @@ -55,7 +55,7 @@ class DictionaryImportManager( try { for ((index, uri) in uris.withIndex()) { currentCoroutineContext().ensureActive() - val fileName = getFileName(uri) ?: continue + val fileName = withContext(Dispatchers.IO) { getFileName(uri) } ?: continue if (SafeFileName.validate(fileName) == null) { deferredErrors += context.getString(R.string.import_invalid_file_name, fileName) continue