优化
This commit is contained in:
@@ -25,6 +25,7 @@ import com.sw.inbound.dialog.GoodsRecognizeDialog
|
||||
import com.sw.inbound.dialog.GoodsSearchDialog
|
||||
import com.sw.inbound.dialog.Loading
|
||||
import com.sw.inbound.dialog.WarnDialog
|
||||
import com.sw.inbound.ext.toSafeDouble
|
||||
import com.sw.inbound.model.request.GoodsAddParam
|
||||
import com.sw.inbound.model.request.PurchaseWarehouseParam
|
||||
import com.sw.inbound.model.request.UploadInfo
|
||||
@@ -160,6 +161,9 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
}, 1 * 1000)
|
||||
binding.btnClearZero.setOnClickListener {
|
||||
SensorScaleUtils.tare()
|
||||
}
|
||||
}
|
||||
|
||||
private var weightCallback: ((weight: Int) -> Unit)? = null
|
||||
@@ -175,6 +179,9 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
// //从秤上取物品中
|
||||
// return
|
||||
//}
|
||||
if (lastWeight != weight || weight == 0) {
|
||||
binding.tvTotalWeight.text = "重量:${weight}克"
|
||||
}
|
||||
if (weight < 200) {
|
||||
if (abs(weight) < 10) {
|
||||
// val clazzName = DialogManager.getDialogList()
|
||||
@@ -190,8 +197,8 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
}
|
||||
return
|
||||
}
|
||||
this.lastWeight = weight
|
||||
if (DialogManager.hasShowDialog()) {
|
||||
this.lastWeight = weight
|
||||
return
|
||||
}
|
||||
// val checkResult = isFirstRecognize.not()
|
||||
@@ -204,8 +211,12 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
// }
|
||||
Timber.tag(TAG)
|
||||
.d("recognizeWeight,recognizeFood:isShowRecognizeDialog=$isShowRecognizeDialog")
|
||||
//两次相差5克内视作重量未变,不进行重新识别
|
||||
if (abs(lastWeight - weight) > 5) {
|
||||
recognizeFood()
|
||||
}
|
||||
this.lastWeight = weight
|
||||
}
|
||||
|
||||
//var startTime = 0L
|
||||
var isFirstRecognize = true
|
||||
@@ -439,7 +450,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
}
|
||||
item.isSelected = true
|
||||
val finalWeight = item.goodsWeight?.toDouble().plus2(goods.goodsWeight?.toDouble())
|
||||
val finalNum = item.receivedNum.plus2(goods.receivedNum)
|
||||
val finalNum = item.receivedNum.plus2(goods.receivedNum).toSafeDouble(item.unitName)
|
||||
val finalAmount = item.recPriceInItem.plus2(goods.recPriceInItem)
|
||||
val finalPrice =
|
||||
if (finalAmount == 0.toDouble() || finalNum == 0.toDouble()) 0.toDouble() else finalAmount / finalNum
|
||||
|
||||
@@ -16,7 +16,8 @@ import com.sw.inbound.utils.ext.hideKeyboard
|
||||
abstract class BaseDialog(
|
||||
context: Context,
|
||||
var defWidth: Int = 1500.dp,
|
||||
var defHeight: Int = 900.dp
|
||||
// var defHeight: Int = 900.dp
|
||||
var defHeight: Int = 750.dp
|
||||
) : Dialog(context, R.style.DialogTheme) {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@@ -90,7 +90,7 @@ class GoodsRecognizeDialog(
|
||||
// }
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismiss()
|
||||
activity?.delayRecognizeFood()
|
||||
// activity?.delayRecognizeFood()
|
||||
//activity?.startTime = System.currentTimeMillis()
|
||||
}
|
||||
binding.btnManuallyFind.setOnClickListener {
|
||||
|
||||
@@ -37,6 +37,8 @@ import com.sw.inbound.utils.CameraUtils
|
||||
import com.sw.inbound.utils.ImageUtil
|
||||
import com.sw.inbound.utils.ext.dp
|
||||
import com.sw.inbound.utils.ext.gone
|
||||
import com.sw.inbound.utils.ext.hideKeyboard
|
||||
import com.sw.inbound.utils.ext.invisible
|
||||
import com.sw.inbound.utils.ext.roundedDecimalPlace
|
||||
import com.sw.inbound.utils.ext.toast
|
||||
import com.sw.inbound.utils.ext.visible
|
||||
@@ -103,6 +105,7 @@ class GoodsStoreDialog(
|
||||
// AddProcurementUnitDialog(context).show()
|
||||
// }
|
||||
binding.flUnitDropdown.setOnClickListener { v ->
|
||||
v.hideKeyboard()
|
||||
if (dropdownPopup == null) {
|
||||
dropdownPopup = DropdownPopup(
|
||||
context = context,
|
||||
@@ -111,6 +114,7 @@ class GoodsStoreDialog(
|
||||
popHeight = min(dropdownList.size, 4) * 71.dp
|
||||
) { dictType ->
|
||||
try {
|
||||
v.hideKeyboard()
|
||||
binding.tvProcurementUnit.run {
|
||||
text = dictType.value
|
||||
tag = dictType.id
|
||||
@@ -164,8 +168,8 @@ class GoodsStoreDialog(
|
||||
addPriceInputListener(binding.etProcurementAmount) {
|
||||
val countText = binding.etProcurementCount.text.trim().toString()
|
||||
val count = if (countText.isNotBlank()) countText.toDouble() else 0.toDouble()
|
||||
if (count == 0.toDouble()) {
|
||||
//context.toast("入库数量不能为0")
|
||||
if (count == 0.toDouble() || it == (-1).toDouble()) {
|
||||
binding.tvProcurementPrice.text = ""
|
||||
return@addPriceInputListener
|
||||
}
|
||||
val price = (it / count).roundedDecimalPlace(2)
|
||||
@@ -198,6 +202,11 @@ class GoodsStoreDialog(
|
||||
}
|
||||
})
|
||||
}
|
||||
binding.tvProcurementPrice.addTextChangedListener {
|
||||
binding.tvPriceUnit.run {
|
||||
if (it.isNullOrBlank()) invisible() else visible()
|
||||
}
|
||||
}
|
||||
addWeightListener()
|
||||
}
|
||||
|
||||
@@ -239,6 +248,7 @@ class GoodsStoreDialog(
|
||||
addTextChangedListener(onTextChanged = { it, _, _, _ ->
|
||||
try {
|
||||
if (it.isNullOrBlank()) {
|
||||
action((-1).toDouble())
|
||||
return@addTextChangedListener
|
||||
}
|
||||
val input = it.toString()
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
android:textColor="#141428"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="冯厨子" />
|
||||
tools:text="冯厨子"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivLogout"
|
||||
@@ -43,7 +44,31 @@
|
||||
android:layout_marginEnd="40dp"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:src="@mipmap/ic_logout"
|
||||
tools:ignore="ContentDescription" />
|
||||
tools:ignore="ContentDescription"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTotalWeight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingHorizontal="50dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#FF141428"
|
||||
android:textSize="24sp"
|
||||
tools:text="重量:6300克" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btnClearZero"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:background="@drawable/bg_white_alpha40_radius6"
|
||||
android:gravity="center"
|
||||
android:text="清零"
|
||||
android:textColor="#FF141428"
|
||||
android:textSize="24sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
<TextView
|
||||
android:id="@+id/tvDialogTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="180dp"
|
||||
android:text="物品识别结果"
|
||||
android:textColor="#ff141428"
|
||||
android:textSize="36sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toTopOf="@+id/flContent"
|
||||
android:gravity="center_vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
@@ -39,14 +39,13 @@
|
||||
android:layout_marginHorizontal="30dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="180dp">
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDialogTitle">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvRecognize"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
tools:itemCount="5"
|
||||
android:overScrollMode="never"
|
||||
tools:listitem="@layout/list_item_recognize" />
|
||||
@@ -57,7 +56,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center"
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
android:background="@color/white"
|
||||
android:visibility="gone"
|
||||
tools:ignore="HardcodedText,UseCompoundDrawables">
|
||||
@@ -118,16 +117,34 @@
|
||||
android:textSize="30sp"
|
||||
android:background="@drawable/bg_blue_ripple"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/flContent"
|
||||
app:layout_constraintBottom_toTopOf="@id/dividerLine">
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="2"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="若以上识别结果都不是该物品,请点击“重新识别”或“手动查找”"
|
||||
android:textColor="#ff999999"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/dividerLine"
|
||||
android:layout_marginBottom="60dp"/>
|
||||
android:textSize="30sp" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
|
||||
@@ -212,7 +212,8 @@
|
||||
android:layout_width="428dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_marginStart="57dp"
|
||||
android:background="@drawable/bg_white_radius10_stroke2">
|
||||
android:background="@drawable/bg_gray_radius10">
|
||||
<!-- bg_white_radius10_stroke2-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvProcurementPrice"
|
||||
@@ -232,6 +233,7 @@
|
||||
tools:ignore="Autofill,TextFields" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPriceUnit"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
@@ -239,7 +241,8 @@
|
||||
android:text="元"
|
||||
android:textColor="#ff96a0aa"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
android:textStyle="bold"
|
||||
android:visibility="invisible"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user