优化调试
This commit is contained in:
@@ -88,7 +88,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
it.uploadSuccess = false
|
||||
}
|
||||
collectionAdapter.notifyItemChanged(position)
|
||||
val count = collectList.count { it.imageFile != null && it.uploadSuccess.not() }
|
||||
// val count = collectList.count { it.imageFile != null && it.uploadSuccess.not() }
|
||||
// binding.btnUploadImage.text = "待上传图片${count}张"
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
toast("请选择物品名称")
|
||||
return@setOnClickListener
|
||||
}
|
||||
val count = collectList.count { it.bitmap != null }
|
||||
val count = collectList.count { it.imageVector != null }
|
||||
if (count == 0) {
|
||||
toast("请拍摄物品照片")
|
||||
return@setOnClickListener
|
||||
@@ -195,7 +195,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
loadEmptyView()
|
||||
|
||||
binding.tvTitle.setOnClickListener {
|
||||
startActivity<LocalImagePreviewActivity> { }
|
||||
// startActivity<LocalImagePreviewActivity> { }
|
||||
|
||||
// val goodsImage = GoodsImage(goodsId = "1993493094888140802", goodsName = "多宝鱼", startTime = 1764120531856L, endTime = 1764121842825L)
|
||||
// uploadImage(goodsImage)
|
||||
@@ -241,7 +241,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun takePhoto() {
|
||||
val count = collectList.count { it.bitmap != null }
|
||||
val count = collectList.count { it.imageFile != null }
|
||||
if (count == MAX_COUNT) {
|
||||
toast("每次只允许保存${MAX_COUNT}条数据")
|
||||
return
|
||||
@@ -280,9 +280,10 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
private val cameraCallback: (Uri) -> Unit = { uri ->
|
||||
val index = collectList.indexOfFirst { it.imageFile == null }
|
||||
if (index == -1) {
|
||||
toast("每次只允许保存6条数据")
|
||||
toast("每次只允许保存${MAX_COUNT}条数据")
|
||||
rerurn@ cameraCallback
|
||||
}
|
||||
// toast("index=$index")
|
||||
try {
|
||||
ImageUtil.uriToBitmap(this, uri)?.let { bitmap ->
|
||||
val cropBitmap = BitmapCropper.cropCenter(
|
||||
@@ -314,9 +315,11 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
it.bitmap = null
|
||||
it.imageFile = file
|
||||
it.isShowCamera = false
|
||||
it.isFinish = false
|
||||
it.uploadSuccess = false
|
||||
}
|
||||
collectionAdapter.notifyItemChanged(index)
|
||||
val count = collectList.count { it.imageFile != null && it.uploadSuccess.not() }
|
||||
// val count = collectList.count { it.imageFile != null && it.uploadSuccess.not() }
|
||||
// binding.btnUploadImage.text = "待上传图片${count}张"
|
||||
if (cropBitmap.isRecycled.not()) {
|
||||
cropBitmap.recycle()
|
||||
@@ -336,10 +339,12 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
Thread {
|
||||
collectList
|
||||
//.filter { it.bitmap != null }
|
||||
.filter { it.imageVector != null }
|
||||
// .filter { it.imageVector != null }
|
||||
.forEachIndexed { index, it ->
|
||||
//image2VectorTask(it.bitmap!!, index)
|
||||
image2VectorTask(imageVector = it.imageVector!!, position = index)
|
||||
it.imageVector?.let{ imageVector ->
|
||||
image2VectorTask(imageVector = imageVector, position = index)
|
||||
}
|
||||
}
|
||||
runOnUiThread {
|
||||
window.decorView.postDelayed({
|
||||
@@ -486,11 +491,11 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
private fun upload() {
|
||||
lifecycleScope.launch {
|
||||
val totalFileCount = collectList.count { it.imageFile != null }
|
||||
showWaitingDialog2("图片上传中0/$totalFileCount")
|
||||
val goods = searchGoodsList[clickIndex]
|
||||
val params = HashMap<String, RequestBody>()
|
||||
//params["placeId"] = restId.toRequestBody()
|
||||
params["foodId"] = goods.id!!.toRequestBody()
|
||||
params["foodName"] = goods.goodsName!!.toRequestBody()
|
||||
params["goodsId"] = goods.id!!.toRequestBody()
|
||||
params["goodsName"] = goods.goodsName!!.toRequestBody()
|
||||
//params["foodVector"] = foodVector.toRequestBody()
|
||||
ImageUploader(
|
||||
totalList = collectList,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.sw.inbound.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.core.net.toUri
|
||||
import coil.load
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.chad.library.adapter4.viewholder.QuickViewHolder
|
||||
@@ -39,7 +41,7 @@ class FoodCollectionAdapter (var list: MutableList<FoodCollectionBean>) :
|
||||
//setImageURI(it.imageUri)
|
||||
//load(it.bitmap)
|
||||
// setImageBitmap(it.bitmap!!)
|
||||
load(it.imageFile)
|
||||
setImageURI(it.imageFile?.toUri())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user