diff --git a/app/src/main/java/com/sw/scalefusion/shelf/ShelfV3Activity.kt b/app/src/main/java/com/sw/scalefusion/shelf/ShelfV3Activity.kt index 7a56a25..5ff61a6 100644 --- a/app/src/main/java/com/sw/scalefusion/shelf/ShelfV3Activity.kt +++ b/app/src/main/java/com/sw/scalefusion/shelf/ShelfV3Activity.kt @@ -155,8 +155,10 @@ class ShelfV3Activity : BaseActivity() { binding.tvVegTypeName.text = model.vegTypeName val weightG = model.weight ?: 0.0 realWeight = (weightG * 1000.0).toInt() + // 负漂移抑制:-5克以内的负读数显示时归零(realWeight 保持真实值) + val displayWeight = if (realWeight in -5..0) 0 else realWeight binding.tvFoodWeight.text = if (weightG >= 1.0) "%.3f千克".format(weightG) - else "${realWeight}克" + else "${displayWeight}克" startTime = System.currentTimeMillis() } @@ -354,8 +356,10 @@ class ShelfV3Activity : BaseActivity() { val intervalTime = System.currentTimeMillis() - startTime val weight = event.weight log("格口${shelfModel?.slotNo}获取重量:${weight}克,间隔:${intervalTime}ms") - binding.tvFoodWeight.text = if (weight < 1000) "${weight}克" - else "%.3f千克".format(weight / 1000.0) + // 负漂移抑制:-5克以内的负读数显示时归零 + val displayWeight = if (weight in -5..0) 0 else weight + binding.tvFoodWeight.text = if (displayWeight < 1000) "${displayWeight}克" + else "%.3f千克".format(displayWeight / 1000.0) startTime = System.currentTimeMillis() window.decorView.postDelayed({ Loading.dismiss() }, 1000) } diff --git a/app/src/main/java/com/sw/scalefusion/shelf/adapter/ShelfV3Adapter.kt b/app/src/main/java/com/sw/scalefusion/shelf/adapter/ShelfV3Adapter.kt index 421c97a..2a036ab 100644 --- a/app/src/main/java/com/sw/scalefusion/shelf/adapter/ShelfV3Adapter.kt +++ b/app/src/main/java/com/sw/scalefusion/shelf/adapter/ShelfV3Adapter.kt @@ -43,10 +43,12 @@ class ShelfV3Adapter(list: MutableList) : binding.tvShelfName.text = item.slotNo.padStart(2, '0') val weightG = item.weight ?: 0.0 + // 负漂移抑制:空秤零点可能出现 -5克以内的负读数,显示时归零 + val displayG = if (weightG in -0.005..0.0) 0.0 else weightG binding.tvFoodWeight.run { setTextColor(getColor(R.color.food_weight_orange)) - text = if (abs(weightG) >= 1.0) "%.3f千克".format(weightG) - else "${(weightG * 1000.0).toInt()}克" + text = if (abs(displayG) >= 1.0) "%.3f千克".format(displayG) + else "${(displayG * 1000.0).toInt()}克" } val isBlank = item.materName.isNullOrBlank() diff --git a/local.properties b/local.properties index ad55396..3d6d7d6 100644 --- a/local.properties +++ b/local.properties @@ -4,5 +4,5 @@ # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. -#Fri Jun 26 09:17:18 CST 2026 -sdk.dir=D\:\\Android\\sdk +#Thu Jul 02 16:04:28 CST 2026 +sdk.dir=C\:\\Users\\MZF\\AppData\\Local\\Android\\Sdk