修复了柱状图显示问题,修复了菜品图片显示问题,处理了人脸采集框变形问题
This commit is contained in:
@@ -93,14 +93,13 @@ class SecondaryScreenPresentation(
|
|||||||
window?.setBackgroundDrawableResource(android.R.color.transparent)
|
window?.setBackgroundDrawableResource(android.R.color.transparent)
|
||||||
initView()
|
initView()
|
||||||
setupArcCamera()
|
setupArcCamera()
|
||||||
// binding.includeUserHeat.ivHeat.showText("1070千卡")
|
|
||||||
registerDataChange()
|
registerDataChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerDataChange() {
|
private fun registerDataChange() {
|
||||||
activity.lifecycleScope.launch {
|
activity.lifecycleScope.launch {
|
||||||
viewModel.loadFaceResult.collect { needUpdate ->
|
viewModel.loadFaceResult.collect { needUpdate ->
|
||||||
if (needUpdate){
|
if (needUpdate) {
|
||||||
recognizeViewModel.refreshFaceList()
|
recognizeViewModel.refreshFaceList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,7 +285,9 @@ class SecondaryScreenPresentation(
|
|||||||
mealPickupMode = mode
|
mealPickupMode = mode
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateNutrition(weight: Double) {
|
private fun calculateNutrition(weight1: Double) {
|
||||||
|
var weight = weight1
|
||||||
|
if (weight < 0) weight = 0.0
|
||||||
debouncer.debounce {
|
debouncer.debounce {
|
||||||
Timber.d("calculateNutrition weight = $weight, recognitionWeight = $recognitionWeight")
|
Timber.d("calculateNutrition weight = $weight, recognitionWeight = $recognitionWeight")
|
||||||
val dinnerType = dinnerTypeInfo!!.dinnerType!!.dinnerType!!
|
val dinnerType = dinnerTypeInfo!!.dinnerType!!.dinnerType!!
|
||||||
@@ -312,43 +313,76 @@ class SecondaryScreenPresentation(
|
|||||||
)
|
)
|
||||||
var maxKcal = totalKcal.max
|
var maxKcal = totalKcal.max
|
||||||
Timber.d("maxKcal = $maxKcal")
|
Timber.d("maxKcal = $maxKcal")
|
||||||
|
// 避免0作为被除数
|
||||||
if (maxKcal <= 0.0) {
|
if (maxKcal <= 0.0) {
|
||||||
maxKcal = 100.0
|
maxKcal = 1.0
|
||||||
}
|
}
|
||||||
Timber.d("maxKcal 1 = $maxKcal")
|
Timber.d("maxKcal 1 = $maxKcal")
|
||||||
itemUserNutritionBinding.totalKcalTv.text = totalKcal.current.format2String()
|
itemUserNutritionBinding.totalKcalTv.text = totalKcal.current.format2String()
|
||||||
|
var totalKcalHeight = (totalKcal.current / maxKcal).toFloat()
|
||||||
|
if (totalKcalHeight == 0F) {
|
||||||
|
itemUserNutritionBinding.divKcalView.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
itemUserNutritionBinding.divKcalView.visibility = View.GONE
|
||||||
|
totalKcalHeight += 0.1F
|
||||||
|
}
|
||||||
itemUserNutritionBinding.customKcalColumn.setCustomHeightPercent(
|
itemUserNutritionBinding.customKcalColumn.setCustomHeightPercent(
|
||||||
(totalKcal.current / maxKcal).toFloat(),
|
totalKcalHeight,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
// 设置主食
|
// 设置主食
|
||||||
itemUserNutritionBinding.customFoodColumn.setImageDrawable(
|
itemUserNutritionBinding.customFoodColumn.setImageDrawable(
|
||||||
false,
|
false,
|
||||||
grain.max < grain.current
|
grain.max < grain.current
|
||||||
)
|
)
|
||||||
itemUserNutritionBinding.totalFoodTv.text = grain.current.format2String()
|
itemUserNutritionBinding.totalFoodTv.text = grain.current.format2String()
|
||||||
|
var grainHeight = (grain.current / columnMax).toFloat()
|
||||||
|
if (grainHeight == 0F) {
|
||||||
|
itemUserNutritionBinding.divTotalFoodView.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
itemUserNutritionBinding.divTotalFoodView.visibility = View.GONE
|
||||||
|
grainHeight += 0.1F
|
||||||
|
}
|
||||||
itemUserNutritionBinding.customFoodColumn.setCustomHeightPercent(
|
itemUserNutritionBinding.customFoodColumn.setCustomHeightPercent(
|
||||||
(grain.current / columnMax).toFloat(),
|
grainHeight,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
// 设置果蔬
|
// 设置果蔬
|
||||||
itemUserNutritionBinding.customVegetableColumn.setImageDrawable(
|
itemUserNutritionBinding.customVegetableColumn.setImageDrawable(
|
||||||
false,
|
false,
|
||||||
fruits.max < fruits.current
|
fruits.max < fruits.current
|
||||||
)
|
)
|
||||||
itemUserNutritionBinding.totalVegetableTv.text = fruits.current.format2String()
|
itemUserNutritionBinding.totalVegetableTv.text = fruits.current.format2String()
|
||||||
|
var fruitsHeight = (fruits.current / columnMax).toFloat()
|
||||||
|
|
||||||
|
if (fruitsHeight == 0F) {
|
||||||
|
itemUserNutritionBinding.divVegetableView.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
itemUserNutritionBinding.divVegetableView.visibility = View.GONE
|
||||||
|
fruitsHeight += 0.1F
|
||||||
|
}
|
||||||
itemUserNutritionBinding.customVegetableColumn.setCustomHeightPercent(
|
itemUserNutritionBinding.customVegetableColumn.setCustomHeightPercent(
|
||||||
(fruits.current / columnMax).toFloat(),
|
fruitsHeight,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
// 设置肉蛋
|
// 设置肉蛋
|
||||||
itemUserNutritionBinding.customMeatColumn.setImageDrawable(
|
itemUserNutritionBinding.customMeatColumn.setImageDrawable(
|
||||||
false,
|
false,
|
||||||
meat.max < meat.current
|
meat.max < meat.current
|
||||||
)
|
)
|
||||||
itemUserNutritionBinding.totalMeatTv.text = meat.current.format2String()
|
itemUserNutritionBinding.totalMeatTv.text = meat.current.format2String()
|
||||||
|
var meatHeight = (meat.current / columnMax).toFloat()
|
||||||
|
if (meatHeight == 0F) {
|
||||||
|
itemUserNutritionBinding.divMeatView.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
itemUserNutritionBinding.divMeatView.visibility = View.GONE
|
||||||
|
meatHeight += 0.1F
|
||||||
|
}
|
||||||
itemUserNutritionBinding.customMeatColumn.setCustomHeightPercent(
|
itemUserNutritionBinding.customMeatColumn.setCustomHeightPercent(
|
||||||
(meat.current / columnMax).toFloat(),
|
meatHeight,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -542,7 +576,7 @@ class SecondaryScreenPresentation(
|
|||||||
val layoutParams = adjustPreviewViewSize(
|
val layoutParams = adjustPreviewViewSize(
|
||||||
binding.dualCameraTexturePreviewRgb,
|
binding.dualCameraTexturePreviewRgb,
|
||||||
binding.dualCameraTexturePreviewRgb, binding.dualCameraFaceRectView,
|
binding.dualCameraTexturePreviewRgb, binding.dualCameraFaceRectView,
|
||||||
previewSizeRgb, displayOrientation, 1f
|
previewSizeRgb, displayOrientation, 0.6F
|
||||||
)
|
)
|
||||||
Timber.d("initRgbCamera previewSizeRgb = ${previewSizeRgb.width}-${previewSizeRgb.height}")
|
Timber.d("initRgbCamera previewSizeRgb = ${previewSizeRgb.width}-${previewSizeRgb.height}")
|
||||||
Timber.d("initRgbCamera layoutParams = ${layoutParams.width}-${layoutParams.height}")
|
Timber.d("initRgbCamera layoutParams = ${layoutParams.width}-${layoutParams.height}")
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.graphics.Paint;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.AlphaAnimation;
|
import android.view.animation.AlphaAnimation;
|
||||||
|
|
||||||
@@ -107,9 +108,8 @@ public class CustomImageView extends androidx.appcompat.widget.AppCompatImageVie
|
|||||||
// 用于设置自定义高度的方法
|
// 用于设置自定义高度的方法
|
||||||
public void setCustomHeight(int height, boolean isAnimation) {
|
public void setCustomHeight(int height, boolean isAnimation) {
|
||||||
Timber.d("setCustomHeight height = %s", height);
|
Timber.d("setCustomHeight height = %s", height);
|
||||||
if (height > 0) {
|
|
||||||
height += 30;
|
setVisibility(height == 0 ? View.GONE : VISIBLE);
|
||||||
}
|
|
||||||
if (height > MAX_HEIGHT){
|
if (height > MAX_HEIGHT){
|
||||||
height = MAX_HEIGHT;
|
height = MAX_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 292 KiB |
@@ -60,6 +60,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:contentDescription="食物图预览"
|
android:contentDescription="食物图预览"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<View
|
<View
|
||||||
android:id="@+id/divKcalView"
|
android:id="@+id/divKcalView"
|
||||||
android:layout_width="1dp"
|
android:layout_width="1dp"
|
||||||
android:layout_height="@dimen/dp16"
|
android:layout_height="@dimen/dp30"
|
||||||
app:layout_constraintBottom_toTopOf="@id/customKcalColumn"
|
app:layout_constraintBottom_toTopOf="@id/customKcalColumn"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent" />
|
app:layout_constraintRight_toRightOf="parent" />
|
||||||
@@ -128,7 +128,7 @@
|
|||||||
<View
|
<View
|
||||||
android:id="@+id/divTotalFoodView"
|
android:id="@+id/divTotalFoodView"
|
||||||
android:layout_width="1dp"
|
android:layout_width="1dp"
|
||||||
android:layout_height="@dimen/dp16"
|
android:layout_height="@dimen/dp30"
|
||||||
app:layout_constraintBottom_toTopOf="@id/customFoodColumn"
|
app:layout_constraintBottom_toTopOf="@id/customFoodColumn"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent" />
|
app:layout_constraintRight_toRightOf="parent" />
|
||||||
@@ -181,7 +181,7 @@
|
|||||||
<View
|
<View
|
||||||
android:id="@+id/divVegetableView"
|
android:id="@+id/divVegetableView"
|
||||||
android:layout_width="1dp"
|
android:layout_width="1dp"
|
||||||
android:layout_height="@dimen/dp16"
|
android:layout_height="@dimen/dp30"
|
||||||
app:layout_constraintBottom_toTopOf="@id/customVegetableColumn"
|
app:layout_constraintBottom_toTopOf="@id/customVegetableColumn"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent" />
|
app:layout_constraintRight_toRightOf="parent" />
|
||||||
@@ -234,7 +234,7 @@
|
|||||||
<View
|
<View
|
||||||
android:id="@+id/divMeatView"
|
android:id="@+id/divMeatView"
|
||||||
android:layout_width="1dp"
|
android:layout_width="1dp"
|
||||||
android:layout_height="@dimen/dp16"
|
android:layout_height="@dimen/dp30"
|
||||||
app:layout_constraintBottom_toTopOf="@id/customMeatColumn"
|
app:layout_constraintBottom_toTopOf="@id/customMeatColumn"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent" />
|
app:layout_constraintRight_toRightOf="parent" />
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@mipmap/bg"
|
android:background="@mipmap/bg"
|
||||||
android:gravity="center_horizontal"
|
android:visibility="visible"
|
||||||
android:orientation="vertical"
|
|
||||||
tools:context=".activity.MainActivity">
|
tools:context=".activity.MainActivity">
|
||||||
|
|
||||||
<!--人脸识别-->
|
<!--人脸识别-->
|
||||||
@@ -47,18 +46,18 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_face_bg"
|
android:id="@+id/iv_face_bg"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="1406dp"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/bg_face"
|
android:background="@drawable/bg_face"
|
||||||
android:contentDescription="相机遮盖层"
|
android:contentDescription="相机遮盖层"
|
||||||
android:visibility="gone" />
|
android:visibility="visible" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="80dp">
|
android:padding="80dp">
|
||||||
|
|
||||||
@@ -107,6 +106,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:contentDescription="img"
|
android:contentDescription="img"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="486dp"
|
android:layout_height="486dp"
|
||||||
android:layout_marginTop="633dp"
|
android:layout_gravity="bottom"
|
||||||
android:background="@drawable/rounded_border_transparent"
|
android:background="@drawable/rounded_border_transparent"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<dimen name="bottom_sheet_height">1000dp</dimen>
|
<dimen name="bottom_sheet_height">1000dp</dimen>
|
||||||
<dimen name="sp11">11sp</dimen>
|
<dimen name="sp11">11sp</dimen>
|
||||||
<dimen name="sp20">20sp</dimen>
|
<dimen name="sp20">20sp</dimen>
|
||||||
<dimen name="dp16">16dp</dimen>
|
<dimen name="dp30">30dp</dimen>
|
||||||
<dimen name="dp80">80dp</dimen>
|
<dimen name="dp80">80dp</dimen>
|
||||||
<dimen name="dp87">87dp</dimen>
|
<dimen name="dp87">87dp</dimen>
|
||||||
<dimen name="dp107">107dp</dimen>
|
<dimen name="dp107">107dp</dimen>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
<item name="android:layout_centerHorizontal">true</item>
|
<item name="android:layout_centerHorizontal">true</item>
|
||||||
<item name="android:gravity">bottom</item>
|
<item name="android:gravity">bottom</item>
|
||||||
<!-- <item name="android:layout_marginBottom">20dp</item>-->
|
<item name="android:layout_marginBottom">20dp</item>
|
||||||
<item name="android:orientation">horizontal</item>
|
<item name="android:orientation">horizontal</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user