接口调试、增加人脸识别后主副屏支付金额逻辑、其它优化
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.sw.dualscreen.utils
|
||||
|
||||
import com.sw.dualscreen.objbox.FoodCollectionBean
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
class ImageUploader(
|
||||
private val totalList: List<FoodCollectionBean>,
|
||||
private val uploadImage: suspend (List<FoodCollectionBean>)-> Boolean,
|
||||
private val onProgress: (Int, List<FoodCollectionBean>) -> Unit,
|
||||
private val onError:(List<FoodCollectionBean>) -> Unit,
|
||||
private val onComplete:() -> Unit
|
||||
) {
|
||||
companion object {
|
||||
private const val BATCH_SIZE = 5
|
||||
}
|
||||
private val uploadedCount = AtomicInteger(0)
|
||||
|
||||
suspend fun processUploads() {
|
||||
val batches = totalList.chunked(BATCH_SIZE)
|
||||
|
||||
for (batch in batches) {
|
||||
val success = uploadImage(batch)
|
||||
if (!success) {
|
||||
//println("上传失败,终止流程")
|
||||
onError(batch)
|
||||
return
|
||||
}
|
||||
val fileCount = batch.count { it.imageFile!=null }
|
||||
uploadedCount.addAndGet(fileCount)
|
||||
onProgress(uploadedCount.get(), batch)
|
||||
//println("已上传 ${uploadedCount.get()}/$totalImages")
|
||||
}
|
||||
|
||||
onComplete()
|
||||
//println("流程完成,总计上传 ${uploadedCount.get()} 张图片")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.sw.dualscreen.utils
|
||||
|
||||
import android.text.Spanned
|
||||
import android.text.SpannedString
|
||||
import android.text.style.AbsoluteSizeSpan
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import androidx.core.graphics.toColorInt
|
||||
import androidx.core.text.buildSpannedString
|
||||
import com.sw.dualscreen.model.response.TextBean
|
||||
|
||||
object SpannedUtils {
|
||||
|
||||
public fun getAmountText(list: List<TextBean>): SpannedString {
|
||||
return buildSpannedString {
|
||||
list.forEach {
|
||||
append(
|
||||
it.text,
|
||||
AbsoluteSizeSpan(it.textSize, true),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
if (it.textColor.isNullOrBlank().not()) {
|
||||
append(
|
||||
it.text,
|
||||
ForegroundColorSpan(it.textColor!!.toColorInt()),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user