优化
This commit is contained in:
@@ -51,6 +51,8 @@ import com.sw.inbound.utils.ext.visible
|
||||
import com.sw.inbound.viewmodel.ReceiptViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.objectbox.Box
|
||||
import io.objectbox.exception.DbException
|
||||
import io.objectbox.exception.FileCorruptException
|
||||
import io.objectbox.kotlin.boxFor
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
@@ -255,7 +257,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun clearData() {
|
||||
val count = collectList.count { it.imageFile !=null }
|
||||
val count = collectList.count { it.imageFile != null }
|
||||
if (count == 0) return
|
||||
clearCoilCache(this)
|
||||
collectList.forEach {
|
||||
@@ -308,7 +310,17 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
toast("操作失败")
|
||||
return@let
|
||||
}
|
||||
val foodList = FoodModule.queryFoodNameScore(imageVector)
|
||||
val foodList = try {
|
||||
FoodModule.queryFoodNameScore(imageVector)
|
||||
} catch (e: DbException) {
|
||||
try {
|
||||
ObjectBox.init(this)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
toast("数据库异常,请稍后重试")
|
||||
return@let
|
||||
}
|
||||
val filterList =
|
||||
foodList.filter { it.score < FoodModule.BAG_RATE && it.name.contains("黑袋子") }
|
||||
if (filterList.isNotEmpty()) {
|
||||
@@ -342,7 +354,20 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
hideWaitingDialog()
|
||||
toast("程序异常${e.message}")
|
||||
val errMsg = e.message ?: ""
|
||||
if (errMsg.contains("Could not get from cursor") ||
|
||||
e is FileCorruptException ||
|
||||
e is DbException
|
||||
) {
|
||||
try {
|
||||
ObjectBox.init(this)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
toast("请重试")
|
||||
} else {
|
||||
toast("程序异常$errMsg")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +379,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
// .filter { it.imageVector != null }
|
||||
.forEachIndexed { index, it ->
|
||||
//image2VectorTask(it.bitmap!!, index)
|
||||
it.imageVector?.let{ imageVector ->
|
||||
it.imageVector?.let { imageVector ->
|
||||
image2VectorTask(imageVector = imageVector, position = index)
|
||||
}
|
||||
}
|
||||
@@ -559,7 +584,8 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
runOnUiThread {
|
||||
hideWaitingDialog()
|
||||
val view = View.inflate(this, R.layout.dialog_waiting, null)
|
||||
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).text = tip
|
||||
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).text =
|
||||
tip
|
||||
mDialogWaiting = CustomDialog(this, view, R.style.MyDialog)
|
||||
mDialogWaiting!!.show()
|
||||
mDialogWaiting!!.setCancelable(true)
|
||||
|
||||
@@ -3,7 +3,11 @@ package com.sw.inbound.activity
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.TextUtils
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.viewModels
|
||||
@@ -19,6 +23,7 @@ import com.sw.inbound.databinding.ActivityGoodsListBinding
|
||||
import com.sw.inbound.databinding.LayoutCameraPreviewBinding
|
||||
import com.sw.inbound.databinding.ListItemReceiptGoodsBinding
|
||||
import com.sw.inbound.databinding.ListItemSelfProcurementBinding
|
||||
import com.sw.inbound.dialog.CustomDialog
|
||||
import com.sw.inbound.dialog.DialogManager
|
||||
import com.sw.inbound.dialog.DropdownPopup
|
||||
import com.sw.inbound.dialog.GoodsRecognizeDialog
|
||||
@@ -566,10 +571,14 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
)
|
||||
Timber.tag("SelfProcurementActivity")
|
||||
.d("receiptSubmit确认收货提交数据:${uploadInfo.toJsonString()}")
|
||||
showWaitingDialog2("加载中")
|
||||
receiptViewModel.confirmReceipt(uploadInfo) { success ->
|
||||
hideWaitingDialog()
|
||||
if (success) {
|
||||
toast("确认收货成功")
|
||||
finish()
|
||||
binding.root.postDelayed({
|
||||
finish()
|
||||
}, 200)
|
||||
} else {
|
||||
toast("确认收货失败")
|
||||
}
|
||||
@@ -601,10 +610,14 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
}
|
||||
Timber.tag("SelfProcurementActivity")
|
||||
.d("selfProcurementSubmit自采入库提交数据:${submitData.toJsonString()}")
|
||||
showWaitingDialog2("加载中")
|
||||
receiptViewModel.addToWarehouse(submitData) { success ->
|
||||
hideWaitingDialog()
|
||||
if (success) {
|
||||
toast("提交入库成功")
|
||||
finish()
|
||||
binding.root.postDelayed({
|
||||
finish()
|
||||
}, 200)
|
||||
} else {
|
||||
toast("提交入库失败")
|
||||
}
|
||||
@@ -659,4 +672,45 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private var mDialogWaiting: CustomDialog? = null
|
||||
|
||||
/**
|
||||
* 显示等待提示框
|
||||
*/
|
||||
fun showWaitingDialog(tip: String?) {
|
||||
runOnUiThread {
|
||||
hideWaitingDialog()
|
||||
val view = View.inflate(this, R.layout.dialog_waiting, null)
|
||||
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).text =
|
||||
tip
|
||||
mDialogWaiting = CustomDialog(this, view, R.style.MyDialog)
|
||||
mDialogWaiting!!.show()
|
||||
mDialogWaiting!!.setCancelable(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏等待提示框
|
||||
*/
|
||||
fun hideWaitingDialog() {
|
||||
runOnUiThread {
|
||||
mDialogWaiting?.dismiss()
|
||||
mDialogWaiting = null
|
||||
}
|
||||
}
|
||||
|
||||
fun showWaitingDialog2(tip: String?) {
|
||||
runOnUiThread {
|
||||
if (mDialogWaiting == null) {
|
||||
hideWaitingDialog()
|
||||
val view = View.inflate(this, R.layout.dialog_waiting, null)
|
||||
mDialogWaiting = CustomDialog(this, view, R.style.MyDialog)
|
||||
mDialogWaiting!!.show()
|
||||
mDialogWaiting!!.setCancelable(true)
|
||||
}
|
||||
val contentView = mDialogWaiting?.findViewById<ViewGroup>(android.R.id.content)
|
||||
val tvTip = contentView?.findViewById<TextView>(R.id.tvTip)
|
||||
tvTip?.text = tip
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import io.objectbox.Box
|
||||
import io.objectbox.kotlin.boxFor
|
||||
import io.objectbox.query.IdWithScore
|
||||
import io.objectbox.query.Query
|
||||
import okhttp3.internal.closeQuietly
|
||||
import org.pytorch.IValue
|
||||
import org.pytorch.Module
|
||||
import org.pytorch.torchvision.TensorImageUtils
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
android:paddingBottom="10dp">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:indeterminateTint="@color/teal_200"
|
||||
android:indeterminateTintMode="src_atop" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user