Compare commits
3
Commits
c1d4263473
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d28c5692a | ||
|
|
6387d9a776 | ||
|
|
0540879551 |
@@ -33,6 +33,8 @@ import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
||||
import com.shuwei.dish.match.utils.ext.appendText
|
||||
import com.shuwei.dish.match.utils.ext.buildSpannableString
|
||||
import com.shuwei.dish.match.utils.ext.dp
|
||||
import com.shuwei.dish.match.utils.ext.roundedDecimalPlace
|
||||
import com.shuwei.dish.match.utils.ext.roundedOneDecimalPlace
|
||||
import com.shuwei.dish.match.utils.ext.toJsonString
|
||||
import com.shuwei.dish.match.utils.ext.toObject
|
||||
import com.shuwei.dish.match.utils.ext.toast
|
||||
@@ -229,7 +231,7 @@ class BottomDialog2(
|
||||
var topWeight = "$weight"
|
||||
var bottomUnit = "克"
|
||||
if (weight >= 1000) {
|
||||
topWeight = "$weight"
|
||||
topWeight = "${(weight/1000).roundedDecimalPlace(3)}"
|
||||
bottomUnit = "千克"
|
||||
}
|
||||
return buildSpannableString {
|
||||
|
||||
@@ -272,7 +272,10 @@ class DishSamplingActivity : BaseActivity() {
|
||||
toast("不允许重复添加同一食材")
|
||||
return@show
|
||||
}
|
||||
binding.etInputDishType.setText(item.goodsName)
|
||||
binding.etInputDishType.run {
|
||||
setText(item.goodsName)
|
||||
setSelection(length())
|
||||
}
|
||||
tempDishEntity = CookFoodGoodsEntity().apply {
|
||||
goodsId = item.goodsId
|
||||
goodsName = item.goodsName
|
||||
|
||||
@@ -182,6 +182,10 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
val firstWeight = firstGoodsArray.get(address, null)
|
||||
if (firstWeight == null) {
|
||||
//未设置数据
|
||||
if (state != WeightUtil.STATE_STABLE) {
|
||||
//首次记录数据需要稳定数据
|
||||
return@addWeightListener
|
||||
}
|
||||
firstGoodsArray.put(address, weight)
|
||||
return@addWeightListener
|
||||
}
|
||||
@@ -420,7 +424,11 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
initConfigData()
|
||||
// setGridData(list)
|
||||
list.forEach { entity ->
|
||||
updateGridData(entity.also { it.useWeight = 0.0 })
|
||||
//烹饪中重量数据从本地获取,否则显示0
|
||||
if (isCooking.not()) {
|
||||
entity.useWeight = 0.0
|
||||
}
|
||||
updateGridData(entity)
|
||||
}
|
||||
seasoningCookingItems = seasoningItems.map { it.copy() }.toList()
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.shuwei.dish.match.utils
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.shuwei.dish.match.ui.HomeActivity
|
||||
import com.shuwei.dish.match.ui.InitActivity
|
||||
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
|
||||
// 启动服务或Activity
|
||||
val launchIntent = Intent(context, HomeActivity::class.java)
|
||||
val launchIntent = Intent(context, InitActivity::class.java)
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(launchIntent)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ typealias WeightCallback = (address: Int, state: Int, weight: Double) -> Unit
|
||||
|
||||
object WeightUtil {
|
||||
private const val TAG = "WeightUtil"
|
||||
const val STATE_STABLE = SensorScale.STATE_STABLE
|
||||
const val STATE_UNSTABLE = SensorScale.STATE_UNSTABLE
|
||||
const val STATE_OVER_WEIGHT = SensorScale.STATE_OVER_WEIGHT
|
||||
|
||||
var isConnected = false
|
||||
var weightFuncMap: MutableMap<String, WeightCallback?>? =
|
||||
@@ -28,9 +31,9 @@ object WeightUtil {
|
||||
override fun onGetWeight(address: Int, state: Int, weight: Double) {
|
||||
super.onGetWeight(address, state, weight)
|
||||
val stateStr = when (state) {
|
||||
SensorScale.STATE_STABLE -> "稳定"
|
||||
SensorScale.STATE_UNSTABLE -> "不稳定"
|
||||
SensorScale.STATE_OVER_WEIGHT -> "量程溢出"
|
||||
STATE_STABLE -> "稳定"
|
||||
STATE_UNSTABLE -> "不稳定"
|
||||
STATE_OVER_WEIGHT -> "量程溢出"
|
||||
else -> "$state"
|
||||
}
|
||||
val useWeight = (weight*1000).roundedOneDecimalPlace()
|
||||
@@ -44,7 +47,11 @@ object WeightUtil {
|
||||
}
|
||||
|
||||
fun getWeight() {
|
||||
Weigher2.getWeight()
|
||||
try {
|
||||
Weigher2.getWeight()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun startContinuousRead() {
|
||||
@@ -61,7 +68,11 @@ object WeightUtil {
|
||||
}
|
||||
|
||||
fun tareTwo(address: Int) {
|
||||
Weigher2.tareTwo(address)
|
||||
try {
|
||||
Weigher2.tareTwo(address)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun runOnUiThread(action: () -> Unit) {
|
||||
|
||||
@@ -175,7 +175,9 @@ fun View.clickWithDebounce(delay: Long = 300, action: () -> Unit) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Double.roundedDecimalPlace(num: Int): Double {
|
||||
return BigDecimal(this).setScale(num, RoundingMode.HALF_UP).toDouble()
|
||||
}
|
||||
fun Double.roundedOneDecimalPlace(): Double {
|
||||
return BigDecimal(this).setScale(1, RoundingMode.HALF_UP).toDouble()
|
||||
return this.roundedDecimalPlace(1)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
android:layout_height="100dp"
|
||||
android:textColor="@color/black666"
|
||||
android:textSize="30sp"
|
||||
android:paddingHorizontal="5dp"
|
||||
android:gravity="center"
|
||||
android:layout_margin="15dp"
|
||||
tools:text="椒盐"
|
||||
|
||||
Reference in New Issue
Block a user