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