mirror of
https://github.com/InvertGeek/MixFile.git
synced 2026-06-01 17:10:49 +08:00
优化线程同步
This commit is contained in:
@@ -14,8 +14,8 @@ android {
|
||||
applicationId = "com.donut.mixfile"
|
||||
minSdk = 24
|
||||
targetSdk = 34
|
||||
versionCode = 42
|
||||
versionName = "1.4.11"
|
||||
versionCode = 43
|
||||
versionName = "1.4.12"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
||||
@@ -16,7 +16,6 @@ import io.ktor.server.response.respondText
|
||||
import io.ktor.util.pipeline.PipelineContext
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.readBytes
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
|
||||
@@ -40,7 +40,6 @@ 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
|
||||
|
||||
@@ -130,7 +129,7 @@ val Favorites = MixNavPage(
|
||||
scope.launch(Dispatchers.IO) {
|
||||
val sorted = result.sortedBy { it.getNameNum() }
|
||||
withContext(Dispatchers.Main) {
|
||||
if (resultCache == result){
|
||||
if (resultCache == result) {
|
||||
result = sorted
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import io.ktor.server.application.ApplicationCall
|
||||
import io.ktor.server.response.respondText
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.Date
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class, ExperimentalLayoutApi::class)
|
||||
@@ -128,15 +129,14 @@ class UploadTask(
|
||||
}
|
||||
|
||||
|
||||
fun complete(shareInfo: MixShareInfo) {
|
||||
result = shareInfo.toString()
|
||||
appScope.launch {
|
||||
suspend fun complete(shareInfo: MixShareInfo) {
|
||||
withContext(Dispatchers.Main) {
|
||||
result = shareInfo.toString()
|
||||
uploadTasks -= this@UploadTask
|
||||
if (add) {
|
||||
addUploadLog(shareInfo)
|
||||
}
|
||||
}
|
||||
if (add) {
|
||||
addUploadLog(shareInfo)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun delete() {
|
||||
@@ -152,9 +152,7 @@ class UploadTask(
|
||||
}
|
||||
setPositiveButton("确定") {
|
||||
stop()
|
||||
appScope.launch {
|
||||
uploadTasks -= this@UploadTask
|
||||
}
|
||||
uploadTasks -= this@UploadTask
|
||||
closeDialog()
|
||||
}
|
||||
show()
|
||||
|
||||
Reference in New Issue
Block a user