优化收藏排序

This commit is contained in:
1
2024-09-25 15:39:58 +08:00
parent 724b3e6f67
commit 978046403b
2 changed files with 7 additions and 3 deletions

View File

@@ -14,8 +14,8 @@ android {
applicationId = "com.donut.mixfile"
minSdk = 24
targetSdk = 34
versionCode = 40
versionName = "1.4.9"
versionCode = 41
versionName = "1.4.10"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {

View File

@@ -40,6 +40,7 @@ import com.donut.mixfile.util.file.updateMark
import com.donut.mixfile.util.formatFileSize
import com.donut.mixfile.util.truncate
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -125,10 +126,13 @@ val Favorites = MixNavPage(
"最大" -> result = result.sortedByDescending { it.size }
"最小" -> result = result.sortedBy { it.size }
"名称" -> {
val resultCache = result
scope.launch(Dispatchers.IO) {
val sorted = result.sortedBy { it.getNameNum() }
withContext(Dispatchers.Main) {
result = sorted
if (resultCache == result){
result = sorted
}
}
}
}