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.
This commit is contained in:
1 parent
27f77f2eba
commit
e733a2f3c0
1 file changed
+1
-1
@@ -55,7 +55,7 @@ class DictionaryImportManager(
|
|||||||
try {
|
try {
|
||||||
for ((index, uri) in uris.withIndex()) {
|
for ((index, uri) in uris.withIndex()) {
|
||||||
currentCoroutineContext().ensureActive()
|
currentCoroutineContext().ensureActive()
|
||||||
val fileName = getFileName(uri) ?: continue
|
val fileName = withContext(Dispatchers.IO) { getFileName(uri) } ?: continue
|
||||||
if (SafeFileName.validate(fileName) == null) {
|
if (SafeFileName.validate(fileName) == null) {
|
||||||
deferredErrors += context.getString(R.string.import_invalid_file_name, fileName)
|
deferredErrors += context.getString(R.string.import_invalid_file_name, fileName)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in new issue
Block a user