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