支付完成倒计时3秒返回首页;秤默认置零取消,打开直接识别物品;人脸识别图片显示拉伸优化;设置页面切换是否收费模式首页逻辑处理;
This commit is contained in:
Generated
+2
-2
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-12-10T08:38:49.440422600Z">
|
<DropdownSelection timestamp="2025-12-17T09:12:02.352767500Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="Default" identifier="serial=192.168.1.177:5555;connection=45709318" />
|
<DeviceId pluginId="Default" identifier="serial=192.168.1.118:5555;connection=50c01ec0" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation(libs.androidx.recyclerview)
|
implementation(libs.androidx.recyclerview)
|
||||||
|
|
||||||
|
implementation("org.greenrobot:eventbus:3.2.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(plugin = "io.objectbox")
|
apply(plugin = "io.objectbox")
|
||||||
@@ -17,9 +17,13 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.sw.dualscreen.R
|
import com.sw.dualscreen.R
|
||||||
import com.sw.dualscreen.model.IActivityResult
|
import com.sw.dualscreen.model.IActivityResult
|
||||||
|
import com.sw.dualscreen.model.response.PostEvent
|
||||||
import com.sw.dualscreen.view.CustomDialog
|
import com.sw.dualscreen.view.CustomDialog
|
||||||
import com.sw.dualscreen.viewmodel.BaseViewModel
|
import com.sw.dualscreen.viewmodel.BaseViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
import org.greenrobot.eventbus.Subscribe
|
||||||
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
|
|
||||||
@@ -37,6 +41,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
EventBus.getDefault().register(this)
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
context = this
|
context = this
|
||||||
|
|
||||||
@@ -50,6 +55,11 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
registerDataChange()
|
registerDataChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
EventBus.getDefault().unregister(this)
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
abstract fun getViewModel(): BaseViewModel
|
abstract fun getViewModel(): BaseViewModel
|
||||||
|
|
||||||
protected abstract fun inflateViewBinding(): VB
|
protected abstract fun inflateViewBinding(): VB
|
||||||
@@ -122,4 +132,9 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
) { result: Boolean ->
|
) { result: Boolean ->
|
||||||
launchPermissionCallback?.callback(result)
|
launchPermissionCallback?.callback(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
fun onPostEvent(event: PostEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import android.net.Uri
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
|
import android.view.Display
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewOutlineProvider
|
import android.view.ViewOutlineProvider
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
@@ -30,8 +31,10 @@ import com.sw.dualscreen.ext.dp
|
|||||||
import com.sw.dualscreen.ext.gone
|
import com.sw.dualscreen.ext.gone
|
||||||
import com.sw.dualscreen.ext.load
|
import com.sw.dualscreen.ext.load
|
||||||
import com.sw.dualscreen.ext.visible
|
import com.sw.dualscreen.ext.visible
|
||||||
|
import com.sw.dualscreen.model.response.ChargeModeEvent
|
||||||
import com.sw.dualscreen.model.response.FoodInfo
|
import com.sw.dualscreen.model.response.FoodInfo
|
||||||
import com.sw.dualscreen.model.response.FoodOrder
|
import com.sw.dualscreen.model.response.FoodOrder
|
||||||
|
import com.sw.dualscreen.model.response.PaySuccessEvent
|
||||||
import com.sw.dualscreen.objbox.FoodModule
|
import com.sw.dualscreen.objbox.FoodModule
|
||||||
import com.sw.dualscreen.objbox.FoodModule.IdNameScore
|
import com.sw.dualscreen.objbox.FoodModule.IdNameScore
|
||||||
import com.sw.dualscreen.presentation.MainScreenPresentation
|
import com.sw.dualscreen.presentation.MainScreenPresentation
|
||||||
@@ -47,6 +50,8 @@ import com.sw.dualscreen.viewmodel.UserViewModel
|
|||||||
import com.sw.plate.utils.LightManager
|
import com.sw.plate.utils.LightManager
|
||||||
import com.sw.plate.utils.ToastUtils
|
import com.sw.plate.utils.ToastUtils
|
||||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||||
|
import org.greenrobot.eventbus.Subscribe
|
||||||
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
@@ -55,6 +60,7 @@ import java.time.format.DateTimeFormatter
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
import kotlin.text.compareTo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务员显示界面
|
* 服务员显示界面
|
||||||
@@ -106,6 +112,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
private var lastPhotoUri: Uri? = null // 最后拍照的图片
|
private var lastPhotoUri: Uri? = null // 最后拍照的图片
|
||||||
private var debouncer = Debouncer(2000)
|
private var debouncer = Debouncer(2000)
|
||||||
private var isRecognitionFood = true
|
private var isRecognitionFood = true
|
||||||
|
private var isFirstOpen = true
|
||||||
|
|
||||||
override fun getViewModel(): BaseViewModel {
|
override fun getViewModel(): BaseViewModel {
|
||||||
return viewModel
|
return viewModel
|
||||||
@@ -120,18 +127,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
addBackEventListener()
|
addBackEventListener()
|
||||||
FoodModule.init(this)
|
FoodModule.init(this)
|
||||||
initView()
|
initView()
|
||||||
setupSecondaryDisplay()
|
viewModel.getUserFaceCache(pageNo = 1)
|
||||||
|
//setupSecondaryDisplay()
|
||||||
setupCamera()
|
setupCamera()
|
||||||
|
//presentation?.step1FoodRecognizing()
|
||||||
initData()
|
initData()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initData() {
|
private fun initData() {
|
||||||
// viewModel.getEquipmentToken()
|
// viewModel.getEquipmentToken()
|
||||||
viewModel.getUserFaceCache(pageNo = 1)
|
|
||||||
//viewModel.getUserFaceCache2()
|
//viewModel.getUserFaceCache2()
|
||||||
|
|
||||||
// presentation?.step1()
|
|
||||||
presentation?.step1FoodRecognizing()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
@@ -146,7 +151,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
updateDateTime()
|
updateDateTime()
|
||||||
binding.ivSetting.setOnClickListener {
|
binding.ivSetting.setOnClickListener {
|
||||||
startActivity(Intent(this, SettingActivity::class.java))
|
startActivity(Intent(this, SettingActivity::class.java))
|
||||||
finish()
|
//finish()
|
||||||
}
|
}
|
||||||
//binding.foodDisplayLayout.setOnClickListener {
|
//binding.foodDisplayLayout.setOnClickListener {
|
||||||
// val intent = Intent(this, FoodCollectionActivity::class.java)
|
// val intent = Intent(this, FoodCollectionActivity::class.java)
|
||||||
@@ -218,59 +223,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
// binding.tvRescan.setOnClickListener {
|
// binding.tvRescan.setOnClickListener {
|
||||||
// debouncer.debounce { recognizeFood() }
|
// debouncer.debounce { recognizeFood() }
|
||||||
// }
|
// }
|
||||||
binding.btnPay.let {
|
binding.btnPay.setOnClickListener {
|
||||||
it.run {
|
clickPayButton()
|
||||||
val mode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
|
||||||
if (mode == 0) visible() else gone()
|
|
||||||
}
|
|
||||||
it.setOnClickListener { v ->
|
|
||||||
if (checkedItem == null) {
|
|
||||||
ToastUtils.showToast("暂无识别数据,请搜索选择")
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
//val realWeight = (lastWeight * 1000).roundToInt()
|
|
||||||
val mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
|
||||||
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0) ?: 0
|
|
||||||
var foodWeight = 0.0
|
|
||||||
var eatWeight = 0.0
|
|
||||||
if (chargeMode == 0) {
|
|
||||||
//计费
|
|
||||||
if (mealPickupMode == 0) {
|
|
||||||
//即放即取
|
|
||||||
eatWeight = lastWeight * 1000
|
|
||||||
foodWeight = lastWeight * 1000
|
|
||||||
} else {
|
|
||||||
//余量计量
|
|
||||||
eatWeight = (recognizeWeight - lastWeight) * 1000
|
|
||||||
foodWeight = recognizeWeight * 1000
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//不计费
|
|
||||||
foodWeight = recognizeWeight * 1000
|
|
||||||
eatWeight = if (mealPickupMode == 0) {
|
|
||||||
//即放即取
|
|
||||||
recognizeWeight * 1000
|
|
||||||
} else {
|
|
||||||
//余量计量
|
|
||||||
(recognizeWeight - lastWeight) * 1000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val eatNum = getEatNum(eatWeight, checkedItem!!.specWeight)
|
|
||||||
createOrder(
|
|
||||||
foodInfo = checkedItem!!,
|
|
||||||
foodWeight = foodWeight.roundToInt(),
|
|
||||||
eatWeight = eatWeight.roundToInt(),
|
|
||||||
eatNum = eatNum
|
|
||||||
) {
|
|
||||||
presentation?.dismiss()
|
|
||||||
startActivity(Intent(this, PayActivity::class.java).apply {
|
|
||||||
putExtra(PayActivity.FOOD_INFO, checkedItem!!)
|
|
||||||
putExtra(PayActivity.FOOD_EAT_NUM, eatNum)
|
|
||||||
putExtra(PayActivity.FOOD_ORDER_ID, foodOrderId)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,19 +242,22 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
recognizeWeight = lastWeight
|
recognizeWeight = lastWeight
|
||||||
presentation?.updateFood(foodInfo)
|
presentation?.updateFood(foodInfo)
|
||||||
binding.tvFoodName.text = foodInfo.foodName
|
binding.tvFoodName.text = foodInfo.foodName
|
||||||
binding.previewView.visibility = View.GONE
|
binding.previewView.gone()
|
||||||
binding.ivImg.visibility = View.VISIBLE
|
binding.ivImg.visible()
|
||||||
if (foodInfo.foodImg.isNullOrBlank()) {
|
if (foodInfo.foodImg.isNullOrBlank()) {
|
||||||
takePhoto { imgUri ->
|
takePhoto { imgUri ->
|
||||||
binding.ivImg.load(imgUri)
|
binding.ivImg.load(imgUri)
|
||||||
presentation?.updateFood(foodInfo.copy(foodImg = imgUri.toString()))
|
presentation?.updateFood(foodInfo.copy(foodImg = imgUri.toString()))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
binding.ivImg.load(foodInfo.photoUri ?: foodInfo.foodImg)
|
|
||||||
}
|
}
|
||||||
|
binding.ivImg.load(foodInfo.foodImg ?: foodInfo.photoUri)
|
||||||
//pauseAnalysis()
|
//pauseAnalysis()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateImage(imgUrl: Any?) {
|
||||||
|
binding.ivImg.load(imgUrl)
|
||||||
|
}
|
||||||
|
|
||||||
override fun registerDataChange() {
|
override fun registerDataChange() {
|
||||||
super.registerDataChange()
|
super.registerDataChange()
|
||||||
//// lifecycleScope.launch {
|
//// lifecycleScope.launch {
|
||||||
@@ -326,23 +283,30 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
SensorScaleUtils.addWeightListener { weight ->
|
SensorScaleUtils.addWeightListener { weight ->
|
||||||
Timber.d("registerDataChange weight = $weight")
|
Timber.d("registerDataChange weight = $weight")
|
||||||
|
val isWeightChange = weight - lastWeight > 0.05
|
||||||
|
recognizeByWeight(weight, isWeightChange)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun recognizeByWeight(weight: Double, isWeightChange: Boolean, block: () -> Unit = {}) {
|
||||||
presentation?.updateWeight(weight)
|
presentation?.updateWeight(weight)
|
||||||
|
|
||||||
if (weight <= 0.005) {//余量取餐,检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
if (weight <= 0.005) {//余量取餐,检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
||||||
isRecognitionFood = true
|
isRecognitionFood = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (weight - lastWeight > 0.05 && isRecognitionFood) { // 大于50g
|
if (isWeightChange && isRecognitionFood) { // 大于50g
|
||||||
if (presentation?.mealPickupMode == 1) {
|
if (presentation?.mealPickupMode == 1) {
|
||||||
isRecognitionFood = false
|
isRecognitionFood = false
|
||||||
}
|
}
|
||||||
debouncer.debounce {
|
debouncer.debounce {
|
||||||
recognizeFood()
|
recognizeFood()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
block()
|
||||||
}
|
}
|
||||||
lastWeight = weight
|
lastWeight = weight
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun recognizeFood() {
|
fun recognizeFood() {
|
||||||
LightManager.openRedLight()
|
LightManager.openRedLight()
|
||||||
@@ -590,9 +554,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
override fun onError(exception: ImageCaptureException) {
|
override fun onError(exception: ImageCaptureException) {
|
||||||
Timber.e("拍照失败: ${exception.message}")
|
Timber.e("拍照失败: ${exception.message}")
|
||||||
runOnUiThread {
|
//runOnUiThread {
|
||||||
ToastUtils.showToast("拍照失败: ${exception.message}")
|
// ToastUtils.showToast("拍照失败: ${exception.message}")
|
||||||
}
|
//}
|
||||||
// 恢复图像分析
|
// 恢复图像分析
|
||||||
isAnalyzing = true
|
isAnalyzing = true
|
||||||
}
|
}
|
||||||
@@ -600,13 +564,21 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSecondaryDisplay() {
|
private fun getSecondaryDisplay(): Display? {
|
||||||
val displayManager = getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
val displayManager = getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||||
val displays = displayManager.displays
|
val displays = displayManager.displays
|
||||||
|
|
||||||
// 查找副屏(通常索引为1)
|
// 查找副屏(通常索引为1)
|
||||||
if (displays.size > 1) {
|
if (displays.size > 1) return displays[1]
|
||||||
val secondaryDisplay = displays[1]
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupSecondaryDisplay() {
|
||||||
|
val secondaryDisplay = getSecondaryDisplay()
|
||||||
|
if (secondaryDisplay == null) {
|
||||||
|
ToastUtils.showToast("获取副屏失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
// 创建副屏的Presentation
|
// 创建副屏的Presentation
|
||||||
presentation = MainScreenPresentation(
|
presentation = MainScreenPresentation(
|
||||||
activity = this,
|
activity = this,
|
||||||
@@ -621,6 +593,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
bottomSheetDialog?.dismiss()
|
bottomSheetDialog?.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
show()
|
||||||
}
|
}
|
||||||
//SecondaryScreenPresentation(
|
//SecondaryScreenPresentation(
|
||||||
// activity = this,
|
// activity = this,
|
||||||
@@ -636,10 +609,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
// bottomSheetDialog?.dismiss()
|
// bottomSheetDialog?.dismiss()
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
presentation!!.show()
|
|
||||||
} else {
|
|
||||||
ToastUtils.showToast("获取副屏失败")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
@@ -651,7 +620,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
//SensorScaleUtils.closeScale()
|
//SensorScaleUtils.closeScale()
|
||||||
presentation?.dismiss()
|
presentation?.cancel()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
shutdownCamera()
|
shutdownCamera()
|
||||||
}
|
}
|
||||||
@@ -664,16 +633,45 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
Timber.tag("onResume").d("=================onResume================")
|
||||||
// 启动定时器
|
// 启动定时器
|
||||||
handler.postDelayed(timeoutRunnable, TIME_OUT)
|
handler.postDelayed(timeoutRunnable, TIME_OUT)
|
||||||
|
|
||||||
if (presentation?.isShowing == false) {
|
if (isFirstOpen) {
|
||||||
|
//首次
|
||||||
setupSecondaryDisplay()
|
setupSecondaryDisplay()
|
||||||
|
presentation?.step1FoodRecognizing()
|
||||||
|
isFirstOpen = false
|
||||||
|
} else {
|
||||||
|
//副屏未显示重新加载
|
||||||
|
isRecognitionFood = true
|
||||||
|
if (presentation == null || !presentation!!.isShowing) {
|
||||||
|
lastWeight = 0.0
|
||||||
|
setupSecondaryDisplay()
|
||||||
|
presentation?.step1FoodRecognizing()
|
||||||
|
} else {
|
||||||
|
//已显示副屏,则进行更新
|
||||||
|
val weight = lastWeight
|
||||||
|
lastWeight = 0.0
|
||||||
|
presentation?.hideRecImage()
|
||||||
|
recognizeByWeight(weight, true)
|
||||||
}
|
}
|
||||||
val mode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0)
|
|
||||||
presentation?.updateMealPickupMode(mode ?: 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//根据付费模式确认是否显示按钮
|
||||||
|
binding.btnPay.run {
|
||||||
|
val mode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
||||||
|
if (mode == 0) visible() else gone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fun retry() {
|
||||||
|
// val weight = lastWeight
|
||||||
|
// lastWeight = 0.0
|
||||||
|
// presentation?.hideRecImage()
|
||||||
|
// recognizeByWeight(weight, true)
|
||||||
|
// }
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
// 取消定时器
|
// 取消定时器
|
||||||
@@ -712,12 +710,14 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
block: () -> Unit
|
block: () -> Unit
|
||||||
) {
|
) {
|
||||||
Timber.tag(TAG).d("foodWeight=$foodWeight,eatWeight=$eatWeight")
|
Timber.tag(TAG).d("foodWeight=$foodWeight,eatWeight=$eatWeight")
|
||||||
|
val pickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||||
|
if (pickupMode == 0) {
|
||||||
if (foodWeight <= 5 || eatWeight <= 5) {
|
if (foodWeight <= 5 || eatWeight <= 5) {
|
||||||
ToastUtils.showToast("请取走餐品")
|
ToastUtils.showToast("请取走餐品")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
||||||
val pickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
|
||||||
val order = FoodOrder(
|
val order = FoodOrder(
|
||||||
deviceId = GlobalData.deviceId,
|
deviceId = GlobalData.deviceId,
|
||||||
foodId = foodInfo.foodId,
|
foodId = foodInfo.foodId,
|
||||||
@@ -768,4 +768,67 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
fun onPaySuccessEvent(event: PaySuccessEvent) {
|
||||||
|
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)?:0
|
||||||
|
presentation?.hideNutritionView(chargeMode)
|
||||||
|
presentation?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
fun onChargeModeEvent(event: ChargeModeEvent) {
|
||||||
|
presentation?.hideNutritionView(event.chargeMode)
|
||||||
|
// presentation?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clickPayButton() {
|
||||||
|
if (checkedItem == null) {
|
||||||
|
ToastUtils.showToast("暂无识别数据,请搜索选择")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//val realWeight = (lastWeight * 1000).roundToInt()
|
||||||
|
val mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||||
|
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0) ?: 0
|
||||||
|
var foodWeight = 0.0
|
||||||
|
var eatWeight = 0.0
|
||||||
|
if (chargeMode == 0) {
|
||||||
|
//计费
|
||||||
|
if (mealPickupMode == 0) {
|
||||||
|
//即放即取
|
||||||
|
eatWeight = lastWeight * 1000
|
||||||
|
foodWeight = lastWeight * 1000
|
||||||
|
} else {
|
||||||
|
//余量计量
|
||||||
|
eatWeight = (recognizeWeight - lastWeight) * 1000
|
||||||
|
foodWeight = recognizeWeight * 1000
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//不计费
|
||||||
|
foodWeight = recognizeWeight * 1000
|
||||||
|
eatWeight = if (mealPickupMode == 0) {
|
||||||
|
//即放即取
|
||||||
|
recognizeWeight * 1000
|
||||||
|
} else {
|
||||||
|
//余量计量
|
||||||
|
(recognizeWeight - lastWeight) * 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val eatNum = getEatNum(eatWeight, checkedItem!!.specWeight)
|
||||||
|
createOrder(
|
||||||
|
foodInfo = checkedItem!!,
|
||||||
|
foodWeight = foodWeight.roundToInt(),
|
||||||
|
eatWeight = eatWeight.roundToInt(),
|
||||||
|
eatNum = eatNum
|
||||||
|
) {
|
||||||
|
// TODO: 暂不关闭首页副屏
|
||||||
|
//presentation?.dismiss()
|
||||||
|
startActivity(Intent(this, PayActivity::class.java).apply {
|
||||||
|
putExtra(PayActivity.FOOD_INFO, checkedItem!!)
|
||||||
|
putExtra(PayActivity.FOOD_EAT_NUM, eatNum)
|
||||||
|
putExtra(PayActivity.FOOD_ORDER_ID, foodOrderId)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,12 +13,14 @@ import com.sw.dualscreen.databinding.ActivityPayBinding
|
|||||||
import com.sw.dualscreen.ext.gone
|
import com.sw.dualscreen.ext.gone
|
||||||
import com.sw.dualscreen.model.response.FoodInfo
|
import com.sw.dualscreen.model.response.FoodInfo
|
||||||
import com.sw.dualscreen.model.response.MemberInfo
|
import com.sw.dualscreen.model.response.MemberInfo
|
||||||
|
import com.sw.dualscreen.model.response.PaySuccessEvent
|
||||||
import com.sw.dualscreen.presentation.pay.ScanQrCodePayPresentation
|
import com.sw.dualscreen.presentation.pay.ScanQrCodePayPresentation
|
||||||
import com.sw.dualscreen.utils.SPUtil
|
import com.sw.dualscreen.utils.SPUtil
|
||||||
import com.sw.dualscreen.viewmodel.BaseViewModel
|
import com.sw.dualscreen.viewmodel.BaseViewModel
|
||||||
import com.sw.dualscreen.viewmodel.UserViewModel
|
import com.sw.dualscreen.viewmodel.UserViewModel
|
||||||
import com.sw.plate.utils.ToastUtils
|
import com.sw.plate.utils.ToastUtils
|
||||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
|
||||||
class PayActivity : BaseActivity<ActivityPayBinding>() {
|
class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||||
|
|
||||||
@@ -170,6 +172,7 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun showPaySuccess(isVip: Boolean) {
|
fun showPaySuccess(isVip: Boolean) {
|
||||||
|
EventBus.getDefault().post(PaySuccessEvent())
|
||||||
showPayInfo(type = 2, isVip = isVip, memberInfo = memberInfo)
|
showPayInfo(type = 2, isVip = isVip, memberInfo = memberInfo)
|
||||||
hidePayTab()
|
hidePayTab()
|
||||||
}
|
}
|
||||||
@@ -256,6 +259,7 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fun bindOrder(userId: String, block: () -> Unit) {
|
// fun bindOrder(userId: String, block: () -> Unit) {
|
||||||
// val pickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0)
|
// val pickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0)
|
||||||
// val mode = if (pickupMode == 1) 1 else 2
|
// val mode = if (pickupMode == 1) 1 else 2
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.sw.dualscreen.activity
|
package com.sw.dualscreen.activity
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.sw.dualscreen.R
|
import com.sw.dualscreen.R
|
||||||
@@ -10,8 +9,6 @@ import com.sw.dualscreen.databinding.ActivitySettingBinding
|
|||||||
import com.sw.dualscreen.model.response.FoodInfo
|
import com.sw.dualscreen.model.response.FoodInfo
|
||||||
import com.sw.dualscreen.viewmodel.BaseViewModel
|
import com.sw.dualscreen.viewmodel.BaseViewModel
|
||||||
import com.sw.dualscreen.viewmodel.UserViewModel
|
import com.sw.dualscreen.viewmodel.UserViewModel
|
||||||
import kotlin.collections.get
|
|
||||||
import kotlin.text.replace
|
|
||||||
|
|
||||||
class SettingActivity : BaseActivity<ActivitySettingBinding>() {
|
class SettingActivity : BaseActivity<ActivitySettingBinding>() {
|
||||||
|
|
||||||
@@ -33,8 +30,8 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
|
|||||||
super.initialize()
|
super.initialize()
|
||||||
binding.include.let {
|
binding.include.let {
|
||||||
it.ivPageBack.setOnClickListener {
|
it.ivPageBack.setOnClickListener {
|
||||||
val intent = Intent(this, MainActivity::class.java)
|
// val intent = Intent(this, MainActivity::class.java)
|
||||||
startActivity(intent)
|
// startActivity(intent)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
it.tvPageTitle.text = "设置"
|
it.tvPageTitle.text = "设置"
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import com.sw.dualscreen.model.response.PostEvent
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
import org.greenrobot.eventbus.Subscribe
|
||||||
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
|
|
||||||
abstract class BaseFragment<VB : ViewBinding>: Fragment() {
|
abstract class BaseFragment<VB : ViewBinding>: Fragment() {
|
||||||
|
|
||||||
@@ -36,4 +40,21 @@ abstract class BaseFragment<VB : ViewBinding>: Fragment() {
|
|||||||
initialize()
|
initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
fun onPostEvent(event: PostEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
EventBus.getDefault().register(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
EventBus.getDefault().unregister(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,11 @@ import android.view.LayoutInflater
|
|||||||
import com.sw.dualscreen.GlobalKey
|
import com.sw.dualscreen.GlobalKey
|
||||||
import com.sw.dualscreen.R
|
import com.sw.dualscreen.R
|
||||||
import com.sw.dualscreen.databinding.FragmentBusinessBinding
|
import com.sw.dualscreen.databinding.FragmentBusinessBinding
|
||||||
|
import com.sw.dualscreen.model.response.ChargeModeEvent
|
||||||
import com.sw.dualscreen.sdk.SensorScaleUtils
|
import com.sw.dualscreen.sdk.SensorScaleUtils
|
||||||
import com.sw.dualscreen.utils.SPUtil
|
import com.sw.dualscreen.utils.SPUtil
|
||||||
import com.sw.plate.utils.ToastUtils
|
import com.sw.plate.utils.ToastUtils
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class BusinessFragment: BaseFragment<FragmentBusinessBinding>() {
|
class BusinessFragment: BaseFragment<FragmentBusinessBinding>() {
|
||||||
@@ -44,13 +46,21 @@ class BusinessFragment: BaseFragment<FragmentBusinessBinding>() {
|
|||||||
ToastUtils.showToast("请设置取餐模式")
|
ToastUtils.showToast("请设置取餐模式")
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
var mode = if (binding.rgCharge.checkedRadioButtonId == R.id.rbChargeYes) 0 else 1
|
|
||||||
SPUtil.getInstance().put(GlobalKey.KEY_CHARGE_MODE, mode)
|
|
||||||
|
|
||||||
mode = if (binding.rgTakeFood.checkedRadioButtonId == R.id.rbPickAndPlace) 0 else 1
|
val chargeMode = if (binding.rgCharge.checkedRadioButtonId == R.id.rbChargeYes) 0 else 1
|
||||||
SPUtil.getInstance().put(GlobalKey.KEY_PICKUP_MODE, mode)
|
//原来的支付模式
|
||||||
|
val oldChargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
||||||
|
if (chargeMode != oldChargeMode) {
|
||||||
|
//支付模式有变化通知首页页面刷新
|
||||||
|
EventBus.getDefault().post(ChargeModeEvent(chargeMode))
|
||||||
|
}
|
||||||
|
SPUtil.getInstance().put(GlobalKey.KEY_CHARGE_MODE, chargeMode)
|
||||||
|
|
||||||
|
val pickupMode = if (binding.rgTakeFood.checkedRadioButtonId == R.id.rbPickAndPlace) 0 else 1
|
||||||
|
SPUtil.getInstance().put(GlobalKey.KEY_PICKUP_MODE, pickupMode)
|
||||||
|
|
||||||
ToastUtils.showToast("设置已保存")
|
ToastUtils.showToast("设置已保存")
|
||||||
|
activity?.finish()
|
||||||
}
|
}
|
||||||
SensorScaleUtils.addWeightListener { value ->
|
SensorScaleUtils.addWeightListener { value ->
|
||||||
val realWeight = (value * 1000).roundToInt()
|
val realWeight = (value * 1000).roundToInt()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.sw.dualscreen.activity.fragment.pay
|
package com.sw.dualscreen.activity.fragment.pay
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.sw.dualscreen.R
|
import com.sw.dualscreen.R
|
||||||
import com.sw.dualscreen.activity.PayActivity
|
import com.sw.dualscreen.activity.PayActivity
|
||||||
import com.sw.dualscreen.activity.fragment.BaseFragment
|
import com.sw.dualscreen.activity.fragment.BaseFragment
|
||||||
@@ -11,10 +12,13 @@ import com.sw.dualscreen.ext.invisible
|
|||||||
import com.sw.dualscreen.ext.load
|
import com.sw.dualscreen.ext.load
|
||||||
import com.sw.dualscreen.ext.visible
|
import com.sw.dualscreen.ext.visible
|
||||||
import com.sw.dualscreen.model.response.MemberInfo
|
import com.sw.dualscreen.model.response.MemberInfo
|
||||||
|
import com.sw.dualscreen.model.response.PaySuccessEvent
|
||||||
import com.sw.dualscreen.model.response.TextBean
|
import com.sw.dualscreen.model.response.TextBean
|
||||||
import com.sw.dualscreen.utils.IntervalExecutor
|
import com.sw.dualscreen.utils.IntervalExecutor
|
||||||
import com.sw.dualscreen.utils.SpannedUtils
|
import com.sw.dualscreen.utils.SpannedUtils
|
||||||
|
import com.sw.dualscreen.utils.countDownByFlow
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
|
||||||
class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
|
class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
|
||||||
|
|
||||||
@@ -42,6 +46,23 @@ class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
|
|||||||
return FragmentPayResultBinding.inflate(layoutInflater)
|
return FragmentPayResultBinding.inflate(layoutInflater)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var countDownJob: Job? = null
|
||||||
|
private fun closePageCountDown() {
|
||||||
|
countDownJob = countDownByFlow(
|
||||||
|
total = 3,
|
||||||
|
scope = lifecycleScope,
|
||||||
|
onStart = {
|
||||||
|
binding.btnBack.text = "返回(3s)..."
|
||||||
|
},
|
||||||
|
onTick = { seconds ->
|
||||||
|
binding.btnBack.text = "返回(${seconds}s)..."
|
||||||
|
},
|
||||||
|
onFinish = {
|
||||||
|
payActivity.finish()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private lateinit var payActivity: PayActivity
|
private lateinit var payActivity: PayActivity
|
||||||
override fun initialize() {
|
override fun initialize() {
|
||||||
payActivity = activity as PayActivity
|
payActivity = activity as PayActivity
|
||||||
@@ -153,11 +174,14 @@ class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
|
|||||||
binding.tvPayAmount.text = "收款金额 $showTotalPrice 元"
|
binding.tvPayAmount.text = "收款金额 $showTotalPrice 元"
|
||||||
|
|
||||||
val showExpensesBalance = expensesBalance.format2String(2)
|
val showExpensesBalance = expensesBalance.format2String(2)
|
||||||
binding.tvPayInfo.text = "应收 $showTotalPrice 元,余额扣除 $showExpensesBalance 元"
|
binding.tvPayInfo.text =
|
||||||
|
"应收 $showTotalPrice 元,余额扣除 $showExpensesBalance 元"
|
||||||
} else {
|
} else {
|
||||||
binding.tvPayAmount.text = "收款金额 ${totalPrice.format2String(2)} 元"
|
binding.tvPayAmount.text = "收款金额 ${totalPrice.format2String(2)} 元"
|
||||||
binding.tvPayInfo.text = "应收 ${totalPrice.format2String(2)} 元"
|
binding.tvPayInfo.text = "应收 ${totalPrice.format2String(2)} 元"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closePageCountDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
@@ -220,7 +244,10 @@ class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadUserInfo(item: MemberInfo) {
|
private fun loadUserInfo(item: MemberInfo) {
|
||||||
binding.ivHeadPic.load(item.faceUrl?.ifBlank { R.drawable.ic_avatar_default })
|
binding.ivHeadPic.load(
|
||||||
|
if(item.faceUrl.isNullOrBlank()) R.drawable.ic_avatar_default
|
||||||
|
else item.faceUrl
|
||||||
|
)
|
||||||
binding.tvUserName.text = item.name
|
binding.tvUserName.text = item.name
|
||||||
|
|
||||||
val phone = item.phone ?: ""
|
val phone = item.phone ?: ""
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ data class UserNutrition(
|
|||||||
//肉蛋超量
|
//肉蛋超量
|
||||||
val meatEggsExcess: String? = null,
|
val meatEggsExcess: String? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
//{"code":"00000","data":"{\"orderType\":0,\"orderPayFrom\":2,\"payType\":\"1\",\"paySuc\":0,\"totalFee\":0.01,\"orderCode\":\"1998193614899372032\",\"message\":\"支付成功\",\"payCode\":\"1998193614899372032508227\"}","msg":"成功","total":0}
|
//{"code":"00000","data":"{\"orderType\":0,\"orderPayFrom\":2,\"payType\":\"1\",\"paySuc\":0,\"totalFee\":0.01,\"orderCode\":\"1998193614899372032\",\"message\":\"支付成功\",\"payCode\":\"1998193614899372032508227\"}","msg":"成功","total":0}
|
||||||
data class PayResult(
|
data class PayResult(
|
||||||
val paySuc: String? = null
|
val paySuc: String? = null
|
||||||
@@ -116,3 +117,13 @@ data class RespCodeMsg(
|
|||||||
val code: String?,
|
val code: String?,
|
||||||
val msg: String?
|
val msg: String?
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
data class PostEvent(var name:String="")
|
||||||
|
data class PaySuccessEvent(
|
||||||
|
var name: String = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
data class ChargeModeEvent(
|
||||||
|
var chargeMode:Int = 0
|
||||||
|
)
|
||||||
@@ -9,11 +9,14 @@ import android.graphics.Point
|
|||||||
import android.hardware.Camera
|
import android.hardware.Camera
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.util.DisplayMetrics
|
||||||
import android.view.Display
|
import android.view.Display
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewOutlineProvider
|
import android.view.ViewOutlineProvider
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
|
import android.widget.FrameLayout
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
@@ -102,6 +105,10 @@ class MainScreenPresentation(
|
|||||||
private var lastFaceTrackId: Int = -1 // 上一次的人脸信息
|
private var lastFaceTrackId: Int = -1 // 上一次的人脸信息
|
||||||
var mealPickupMode: Int = 0 // 取餐模式 0 即放即取 1 余量取餐
|
var mealPickupMode: Int = 0 // 取餐模式 0 即放即取 1 余量取餐
|
||||||
|
|
||||||
|
var isKeepFaceState = true
|
||||||
|
|
||||||
|
var currentUserId: String? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = PresentationMainScreenBinding.inflate(layoutInflater)
|
binding = PresentationMainScreenBinding.inflate(layoutInflater)
|
||||||
@@ -161,10 +168,10 @@ class MainScreenPresentation(
|
|||||||
Timber.tag(TAG).e("updateWeight userNutritionData is null")
|
Timber.tag(TAG).e("updateWeight userNutritionData is null")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (dinnerTypeInfo == null) {
|
// if (dinnerTypeInfo == null) {
|
||||||
Timber.tag(TAG).e("updateWeight dinnerType is null")
|
// Timber.tag(TAG).e("updateWeight dinnerType is null")
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if (chargeMode == 1) {
|
if (chargeMode == 1) {
|
||||||
//不计费
|
//不计费
|
||||||
if (mealPickupMode == 0) {
|
if (mealPickupMode == 0) {
|
||||||
@@ -270,14 +277,15 @@ class MainScreenPresentation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
binding.ivRecImage.let {
|
// binding.ivRecImage.let {
|
||||||
it.outlineProvider = object : ViewOutlineProvider() {
|
// it.outlineProvider = object : ViewOutlineProvider() {
|
||||||
override fun getOutline(view: View, outline: Outline) {
|
// override fun getOutline(view: View, outline: Outline) {
|
||||||
outline.setRoundRect(0, 0, view.width, view.height, 12f.dp)
|
// outline.setRoundRect(0, 0, view.width, view.height, 12f.dp)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
it.clipToOutline = true
|
// it.clipToOutline = true
|
||||||
}
|
// }
|
||||||
|
binding.ivPreviewImage.visible()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisplayRemoved() {
|
override fun onDisplayRemoved() {
|
||||||
@@ -418,6 +426,7 @@ class MainScreenPresentation(
|
|||||||
binding.flCameraView.visible()
|
binding.flCameraView.visible()
|
||||||
binding.ivRecImage.gone()
|
binding.ivRecImage.gone()
|
||||||
binding.ivPreviewImage.visible()
|
binding.ivPreviewImage.visible()
|
||||||
|
binding.ivFrame.visible()
|
||||||
binding.ivFaceRecMask.gone()
|
binding.ivFaceRecMask.gone()
|
||||||
binding.tvFaceTip.gone()
|
binding.tvFaceTip.gone()
|
||||||
binding.llPriceInfo.gone()
|
binding.llPriceInfo.gone()
|
||||||
@@ -467,7 +476,7 @@ class MainScreenPresentation(
|
|||||||
|
|
||||||
binding.ivRecImage.gone()
|
binding.ivRecImage.gone()
|
||||||
binding.ivPreviewImage.gone()
|
binding.ivPreviewImage.gone()
|
||||||
|
binding.ivFrame.gone()
|
||||||
dinnerTypeInfo = null
|
dinnerTypeInfo = null
|
||||||
// userNutritionData = null
|
// userNutritionData = null
|
||||||
userNutrition = null
|
userNutrition = null
|
||||||
@@ -476,11 +485,15 @@ class MainScreenPresentation(
|
|||||||
stepChangeCallback(currentStep)
|
stepChangeCallback(currentStep)
|
||||||
currentFood = foodInfo
|
currentFood = foodInfo
|
||||||
|
|
||||||
userViewModel.getDinnerType()
|
// userViewModel.getDinnerType()
|
||||||
|
|
||||||
resumeCamera()
|
resumeCamera()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hideRecImage() {
|
||||||
|
binding.ivRecImage.gone()
|
||||||
|
}
|
||||||
|
|
||||||
// 当前食物信息
|
// 当前食物信息
|
||||||
private var currentFood: FoodInfo? = null
|
private var currentFood: FoodInfo? = null
|
||||||
fun updateFood(foodInfo: FoodInfo?) {
|
fun updateFood(foodInfo: FoodInfo?) {
|
||||||
@@ -491,12 +504,16 @@ class MainScreenPresentation(
|
|||||||
}
|
}
|
||||||
binding.tvFoodName.text = foodInfo.foodName
|
binding.tvFoodName.text = foodInfo.foodName
|
||||||
binding.ivPreviewImage.gone()
|
binding.ivPreviewImage.gone()
|
||||||
|
binding.ivFrame.gone()
|
||||||
|
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
||||||
|
if (chargeMode == 0) {
|
||||||
binding.ivRecImage.let {
|
binding.ivRecImage.let {
|
||||||
it.visible()
|
it.visible()
|
||||||
val imageUrl =
|
val imageUrl =
|
||||||
if (foodInfo.foodImg.isNullOrBlank()) foodInfo.photoUri else foodInfo.foodImg
|
if (foodInfo.foodImg.isNullOrBlank()) foodInfo.photoUri else foodInfo.foodImg
|
||||||
it.load(imageUrl)
|
it.load(imageUrl)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
val mode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
val mode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
//计费,查询营养信息、价格信息------------------------
|
//计费,查询营养信息、价格信息------------------------
|
||||||
@@ -537,12 +554,15 @@ class MainScreenPresentation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateNutrition(weight1: Double) {
|
private fun calculateNutrition(weight1: Double) {
|
||||||
|
if (currentFood == null || userNutrition == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var weight = weight1
|
var weight = weight1
|
||||||
if (weight < 0) weight = 0.0
|
if (weight < 0) weight = 0.0
|
||||||
debouncer.debounce {
|
debouncer.debounce {
|
||||||
Timber.tag(TAG)
|
Timber.tag(TAG)
|
||||||
.d("calculateNutrition weight = $weight, recognitionWeight = $recognitionWeight")
|
.d("calculateNutrition weight = $weight, recognitionWeight = $recognitionWeight")
|
||||||
val dinnerType = dinnerTypeInfo!!.dinnerType!!
|
val dinnerType = dinnerTypeInfo?.dinnerType
|
||||||
// Timber.tag(TAG)
|
// Timber.tag(TAG)
|
||||||
// .d("calculateNutrition foodName = ${currentFood!!.foodName}, dinnerType = $dinnerType, userId = ${userNutritionData!!.userId}")
|
// .d("calculateNutrition foodName = ${currentFood!!.foodName}, dinnerType = $dinnerType, userId = ${userNutritionData!!.userId}")
|
||||||
val energy: UserEnergy = UserNutritionUtils.calculateNutrition2(
|
val energy: UserEnergy = UserNutritionUtils.calculateNutrition2(
|
||||||
@@ -550,7 +570,7 @@ class MainScreenPresentation(
|
|||||||
// userNutritionData!!,
|
// userNutritionData!!,
|
||||||
userNutrition!!,
|
userNutrition!!,
|
||||||
weight,
|
weight,
|
||||||
dinnerType = dinnerType
|
dinnerType = dinnerType ?: ""
|
||||||
)
|
)
|
||||||
// Timber.tag(TAG).d("calculateNutrition calcResultInfo = $calcResultInfo")
|
// Timber.tag(TAG).d("calculateNutrition calcResultInfo = $calcResultInfo")
|
||||||
// val columnMax = UserNutritionUtils.getMaxInt(calcResultInfo)
|
// val columnMax = UserNutritionUtils.getMaxInt(calcResultInfo)
|
||||||
@@ -570,7 +590,8 @@ class MainScreenPresentation(
|
|||||||
0.0,
|
0.0,
|
||||||
userNutrition?.minCalorie ?: 0.0,
|
userNutrition?.minCalorie ?: 0.0,
|
||||||
userNutrition?.recommendCalorie ?: 0.0,
|
userNutrition?.recommendCalorie ?: 0.0,
|
||||||
((userNutrition?.recommendCalorie?:0.0) + (userNutrition?.maxCalorie?:0.0))/2,
|
((userNutrition?.recommendCalorie ?: 0.0) + (userNutrition?.maxCalorie
|
||||||
|
?: 0.0)) / 2,
|
||||||
userNutrition?.maxCalorie ?: 0.0,
|
userNutrition?.maxCalorie ?: 0.0,
|
||||||
)
|
)
|
||||||
val calorieIndex = UserNutritionUtils.findCalorieIndex(energy.grain, calorieArray)
|
val calorieIndex = UserNutritionUtils.findCalorieIndex(energy.grain, calorieArray)
|
||||||
@@ -585,9 +606,9 @@ class MainScreenPresentation(
|
|||||||
include.totalKcalTv.text = totalKcal.format2String(2)
|
include.totalKcalTv.text = totalKcal.format2String(2)
|
||||||
var totalKcalHeight = (totalKcal / maxKcal).toFloat()
|
var totalKcalHeight = (totalKcal / maxKcal).toFloat()
|
||||||
if (totalKcalHeight == 0F) {
|
if (totalKcalHeight == 0F) {
|
||||||
include.divKcalView.visibility = View.VISIBLE
|
include.divKcalView.visible()
|
||||||
} else {
|
} else {
|
||||||
include.divKcalView.visibility = View.GONE
|
include.divKcalView.gone()
|
||||||
totalKcalHeight += 0.1F
|
totalKcalHeight += 0.1F
|
||||||
}
|
}
|
||||||
include.customKcalColumn.setCustomHeightPercent(totalKcalHeight, true)
|
include.customKcalColumn.setCustomHeightPercent(totalKcalHeight, true)
|
||||||
@@ -603,9 +624,9 @@ class MainScreenPresentation(
|
|||||||
include.totalFoodTv.text = grain.format2String(2)
|
include.totalFoodTv.text = grain.format2String(2)
|
||||||
var grainHeight = (grain / columnMax).toFloat()
|
var grainHeight = (grain / columnMax).toFloat()
|
||||||
if (grainHeight == 0F) {
|
if (grainHeight == 0F) {
|
||||||
include.divTotalFoodView.visibility = View.VISIBLE
|
include.divTotalFoodView.visible()
|
||||||
} else {
|
} else {
|
||||||
include.divTotalFoodView.visibility = View.GONE
|
include.divTotalFoodView.gone()
|
||||||
grainHeight += 0.1F
|
grainHeight += 0.1F
|
||||||
}
|
}
|
||||||
include.customFoodColumn.setCustomHeightPercent(grainHeight, true)
|
include.customFoodColumn.setCustomHeightPercent(grainHeight, true)
|
||||||
@@ -616,15 +637,16 @@ class MainScreenPresentation(
|
|||||||
mid = userNutrition?.fruitsVegetablesNearExcess,
|
mid = userNutrition?.fruitsVegetablesNearExcess,
|
||||||
right = userNutrition?.fruitsVegetablesExcess
|
right = userNutrition?.fruitsVegetablesExcess
|
||||||
)
|
)
|
||||||
val fruitsIndex = UserNutritionUtils.findCalorieIndex(energy.fruitsVegetables, fruitsArray)
|
val fruitsIndex =
|
||||||
|
UserNutritionUtils.findCalorieIndex(energy.fruitsVegetables, fruitsArray)
|
||||||
include.customVegetableColumn.setImageDrawable(false, fruitsIndex)
|
include.customVegetableColumn.setImageDrawable(false, fruitsIndex)
|
||||||
include.totalVegetableTv.text = fruitsVegetables.format2String(2)
|
include.totalVegetableTv.text = fruitsVegetables.format2String(2)
|
||||||
var fruitsHeight = (fruitsVegetables / columnMax).toFloat()
|
var fruitsHeight = (fruitsVegetables / columnMax).toFloat()
|
||||||
|
|
||||||
if (fruitsHeight == 0F) {
|
if (fruitsHeight == 0F) {
|
||||||
include.divVegetableView.visibility = View.VISIBLE
|
include.divVegetableView.visible()
|
||||||
} else {
|
} else {
|
||||||
include.divVegetableView.visibility = View.GONE
|
include.divVegetableView.gone()
|
||||||
fruitsHeight += 0.1F
|
fruitsHeight += 0.1F
|
||||||
}
|
}
|
||||||
include.customVegetableColumn.setCustomHeightPercent(fruitsHeight, true)
|
include.customVegetableColumn.setCustomHeightPercent(fruitsHeight, true)
|
||||||
@@ -635,14 +657,15 @@ class MainScreenPresentation(
|
|||||||
mid = userNutrition?.meatEggsNearExcess,
|
mid = userNutrition?.meatEggsNearExcess,
|
||||||
right = userNutrition?.meatEggsExcess
|
right = userNutrition?.meatEggsExcess
|
||||||
)
|
)
|
||||||
val meatEggsIndex = UserNutritionUtils.findCalorieIndex(energy.meatEggs, meatEggsArray)
|
val meatEggsIndex =
|
||||||
|
UserNutritionUtils.findCalorieIndex(energy.meatEggs, meatEggsArray)
|
||||||
include.customMeatColumn.setImageDrawable(false, meatEggsIndex)
|
include.customMeatColumn.setImageDrawable(false, meatEggsIndex)
|
||||||
include.totalMeatTv.text = meatEggs.format2String(2)
|
include.totalMeatTv.text = meatEggs.format2String(2)
|
||||||
var meatHeight = (meatEggs / columnMax).toFloat()
|
var meatHeight = (meatEggs / columnMax).toFloat()
|
||||||
if (meatHeight == 0F) {
|
if (meatHeight == 0F) {
|
||||||
include.divMeatView.visibility = View.VISIBLE
|
include.divMeatView.visible()
|
||||||
} else {
|
} else {
|
||||||
include.divMeatView.visibility = View.GONE
|
include.divMeatView.gone()
|
||||||
meatHeight += 0.1F
|
meatHeight += 0.1F
|
||||||
}
|
}
|
||||||
include.customMeatColumn.setCustomHeightPercent(meatHeight, true)
|
include.customMeatColumn.setCustomHeightPercent(meatHeight, true)
|
||||||
@@ -738,6 +761,9 @@ class MainScreenPresentation(
|
|||||||
recognizeViewModel.recognizeUserId.observe(
|
recognizeViewModel.recognizeUserId.observe(
|
||||||
activity,
|
activity,
|
||||||
Observer { compareResult: CompareResult ->
|
Observer { compareResult: CompareResult ->
|
||||||
|
activity.runOnUiThread {
|
||||||
|
activity.showWaitingDialog("加载中,请稍后……")
|
||||||
|
}
|
||||||
Timber.tag(TAG)
|
Timber.tag(TAG)
|
||||||
.i("recognizeUserId observe compareResult = ${compareResult.trackId}, userId = ${compareResult.faceEntity.userName}")
|
.i("recognizeUserId observe compareResult = ${compareResult.trackId}, userId = ${compareResult.faceEntity.userName}")
|
||||||
recognitionTime = System.currentTimeMillis()
|
recognitionTime = System.currentTimeMillis()
|
||||||
@@ -745,6 +771,16 @@ class MainScreenPresentation(
|
|||||||
lastFaceTrackId = compareResult.trackId
|
lastFaceTrackId = compareResult.trackId
|
||||||
val faceEntity = compareResult.faceEntity
|
val faceEntity = compareResult.faceEntity
|
||||||
val userId = faceEntity.userName
|
val userId = faceEntity.userName
|
||||||
|
currentUserId = userId
|
||||||
|
// if (TextUtils.equals(userId, "2")) {
|
||||||
|
// //解决识别出现recognizeStatus = 2待重试的问题
|
||||||
|
// activity.runOnUiThread {
|
||||||
|
// ToastUtils.showToast("一开始就在屏幕内发现无法识别,从屏幕外进入就可以识别")
|
||||||
|
// activity.hideWaitingDialog()
|
||||||
|
// }
|
||||||
|
// //userViewModel.getUserFaceCache()
|
||||||
|
// return@Observer
|
||||||
|
// }
|
||||||
if (userId == null) return@Observer
|
if (userId == null) return@Observer
|
||||||
//ToastUtils.showToast("人脸识别成功,userId = $userId")
|
//ToastUtils.showToast("人脸识别成功,userId = $userId")
|
||||||
if (currentFood == null) {
|
if (currentFood == null) {
|
||||||
@@ -752,6 +788,7 @@ class MainScreenPresentation(
|
|||||||
}
|
}
|
||||||
if (currentFood == null) {
|
if (currentFood == null) {
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
|
activity.hideWaitingDialog()
|
||||||
ToastUtils.showToast("请选择菜品")
|
ToastUtils.showToast("请选择菜品")
|
||||||
return@runOnUiThread
|
return@runOnUiThread
|
||||||
}
|
}
|
||||||
@@ -761,12 +798,21 @@ class MainScreenPresentation(
|
|||||||
userViewModel.getUserNutritionData(userId = userId) { nutrition ->
|
userViewModel.getUserNutritionData(userId = userId) { nutrition ->
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
if (nutrition == null) {
|
if (nutrition == null) {
|
||||||
|
activity.hideWaitingDialog()
|
||||||
ToastUtils.showToast("未查询到营养数据")
|
ToastUtils.showToast("未查询到营养数据")
|
||||||
return@runOnUiThread
|
return@runOnUiThread
|
||||||
}
|
}
|
||||||
this@MainScreenPresentation.userNutrition = nutrition
|
this@MainScreenPresentation.userNutrition = nutrition
|
||||||
loadUnbilledMode()
|
loadUnbilledMode()
|
||||||
// -------------------------------
|
|
||||||
|
val imageUrl =
|
||||||
|
if (currentFood!!.foodImg.isNullOrBlank()) currentFood!!.photoUri else currentFood!!.foodImg
|
||||||
|
binding.ivRecImage.let {
|
||||||
|
it.visible()
|
||||||
|
it.load(imageUrl)
|
||||||
|
}
|
||||||
|
activity.updateImage(imageUrl)
|
||||||
|
activity.hideWaitingDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -816,7 +862,7 @@ class MainScreenPresentation(
|
|||||||
// layoutParams.width = (measuredHeight * ratio).toInt()
|
// layoutParams.width = (measuredHeight * ratio).toInt()
|
||||||
// }
|
// }
|
||||||
// if (scale < 1f) {
|
// if (scale < 1f) {
|
||||||
// val rgbParam = rgbPreview.getLayoutParams()
|
// val rgbParam = rgbPreview.layoutParams
|
||||||
// layoutParams.width = (rgbParam.width * scale).toInt()
|
// layoutParams.width = (rgbParam.width * scale).toInt()
|
||||||
// layoutParams.height = (rgbParam.height * scale).toInt()
|
// layoutParams.height = (rgbParam.height * scale).toInt()
|
||||||
// } else {
|
// } else {
|
||||||
@@ -838,16 +884,23 @@ class MainScreenPresentation(
|
|||||||
// layoutParams.height = (layoutParams.height / viewRatio).toInt()
|
// layoutParams.height = (layoutParams.height / viewRatio).toInt()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// Timber.tag(TAG).d("initRgbCamera:metrics(${metrics.widthPixels},${metrics.heightPixels})")
|
||||||
|
|
||||||
val layoutParams = previewView.layoutParams
|
|
||||||
// layoutParams.width = (608.dp * 1.5).roundToInt()
|
//val layoutParams = previewView.layoutParams
|
||||||
// layoutParams.height = (456.dp * 1.5).roundToInt()
|
//layoutParams.width = 1024
|
||||||
// layoutParams.width = (600.dp * 1.5).roundToInt()
|
//layoutParams.height = 768
|
||||||
// layoutParams.height = (450.dp * 1.5).roundToInt()
|
// val w = 600.dp //(912.dp * scale).toInt()
|
||||||
layoutParams.width = 1024
|
// val h = 900.dp //684.dp
|
||||||
layoutParams.height = 768
|
val w = 500.dp
|
||||||
|
val h = 850.dp
|
||||||
|
//(1024*scale).toInt()
|
||||||
|
val layoutParams = FrameLayout.LayoutParams(w, h);
|
||||||
|
// val layoutParams = FrameLayout.LayoutParams(480, 320);
|
||||||
|
// val layoutParams = FrameLayout.LayoutParams(912.dp, 684.dp);
|
||||||
previewView.setLayoutParams(layoutParams)
|
previewView.setLayoutParams(layoutParams)
|
||||||
faceRectView.setLayoutParams(layoutParams)
|
faceRectView.setLayoutParams(layoutParams)
|
||||||
|
|
||||||
return layoutParams
|
return layoutParams
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -865,8 +918,11 @@ class MainScreenPresentation(
|
|||||||
val previewSizeRgb = camera.getParameters().getPreviewSize()
|
val previewSizeRgb = camera.getParameters().getPreviewSize()
|
||||||
val layoutParams = adjustPreviewViewSize(
|
val layoutParams = adjustPreviewViewSize(
|
||||||
binding.dualCameraTexturePreviewRgb,
|
binding.dualCameraTexturePreviewRgb,
|
||||||
binding.dualCameraTexturePreviewRgb, binding.dualCameraFaceRectView,
|
binding.dualCameraTexturePreviewRgb,
|
||||||
previewSizeRgb, displayOrientation, 0.6F
|
binding.dualCameraFaceRectView,
|
||||||
|
previewSizeRgb, displayOrientation,
|
||||||
|
0.5F
|
||||||
|
//0.6F
|
||||||
)
|
)
|
||||||
|
|
||||||
Timber.tag(TAG)
|
Timber.tag(TAG)
|
||||||
@@ -886,10 +942,8 @@ class MainScreenPresentation(
|
|||||||
)
|
)
|
||||||
// 调整识别窗口位置
|
// 调整识别窗口位置
|
||||||
rgbFaceRectTransformer = FaceRectTransformer(
|
rgbFaceRectTransformer = FaceRectTransformer(
|
||||||
// previewSizeRgb.width,
|
previewSizeRgb.width,
|
||||||
// previewSizeRgb.height,
|
previewSizeRgb.height,
|
||||||
layoutParams.width,
|
|
||||||
layoutParams.height,
|
|
||||||
layoutParams.width,
|
layoutParams.width,
|
||||||
layoutParams.height,
|
layoutParams.height,
|
||||||
90,
|
90,
|
||||||
@@ -945,9 +999,12 @@ class MainScreenPresentation(
|
|||||||
val previewConfig: PreviewConfig = recognizeViewModel.previewConfig
|
val previewConfig: PreviewConfig = recognizeViewModel.previewConfig
|
||||||
rgbCameraHelper = DualCameraHelper.Builder()
|
rgbCameraHelper = DualCameraHelper.Builder()
|
||||||
.previewViewSize(Point(measuredWidth, measuredHeight))
|
.previewViewSize(Point(measuredWidth, measuredHeight))
|
||||||
|
// .previewViewSize(Point(608.dp, 456.dp))
|
||||||
|
// .previewViewSize(Point(1024, 768))
|
||||||
.rotation(activity.windowManager.defaultDisplay.rotation)
|
.rotation(activity.windowManager.defaultDisplay.rotation)
|
||||||
.additionalRotation(previewConfig.rgbAdditionalDisplayOrientation) // 角度
|
.additionalRotation(previewConfig.rgbAdditionalDisplayOrientation) // 角度
|
||||||
.previewSize(recognizeViewModel.loadPreviewSize())
|
.previewSize(recognizeViewModel.loadPreviewSize())
|
||||||
|
// .previewSize(Point(1080, 720))
|
||||||
.specificCameraId(previewConfig.rgbCameraId)
|
.specificCameraId(previewConfig.rgbCameraId)
|
||||||
.isMirror(true)
|
.isMirror(true)
|
||||||
.previewOn(binding.dualCameraTexturePreviewRgb)
|
.previewOn(binding.dualCameraTexturePreviewRgb)
|
||||||
@@ -982,9 +1039,10 @@ class MainScreenPresentation(
|
|||||||
)
|
)
|
||||||
|
|
||||||
irFaceRectTransformer = FaceRectTransformer(
|
irFaceRectTransformer = FaceRectTransformer(
|
||||||
// previewSizeIr.width, previewSizeIr.height,
|
previewSizeIr.width, previewSizeIr.height,
|
||||||
|
// layoutParams.width, layoutParams.height,
|
||||||
layoutParams.width, layoutParams.height,
|
layoutParams.width, layoutParams.height,
|
||||||
layoutParams.width, layoutParams.height, displayOrientation, cameraId, isMirror,
|
displayOrientation, cameraId, isMirror,
|
||||||
ConfigUtil.isDrawIrRectHorizontalMirror(context),
|
ConfigUtil.isDrawIrRectHorizontalMirror(context),
|
||||||
ConfigUtil.isDrawIrRectVerticalMirror(context)
|
ConfigUtil.isDrawIrRectVerticalMirror(context)
|
||||||
)
|
)
|
||||||
@@ -1027,6 +1085,7 @@ class MainScreenPresentation(
|
|||||||
binding.dualCameraTexturePreviewIr.measuredHeight
|
binding.dualCameraTexturePreviewIr.measuredHeight
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
// .previewViewSize(Point(133,100))
|
||||||
.rotation(activity.windowManager.defaultDisplay.rotation)
|
.rotation(activity.windowManager.defaultDisplay.rotation)
|
||||||
.specificCameraId(previewConfig.irCameraId)
|
.specificCameraId(previewConfig.irCameraId)
|
||||||
.previewOn(binding.dualCameraTexturePreviewIr)
|
.previewOn(binding.dualCameraTexturePreviewIr)
|
||||||
@@ -1064,16 +1123,17 @@ class MainScreenPresentation(
|
|||||||
Timber.tag(TAG)
|
Timber.tag(TAG)
|
||||||
.d("listIsEmpty=$listIsEmpty,lastFaceTrackId=$lastFaceTrackId,listFirstTrackId=$listFirstTrackId")
|
.d("listIsEmpty=$listIsEmpty,lastFaceTrackId=$lastFaceTrackId,listFirstTrackId=$listFirstTrackId")
|
||||||
if (listIsEmpty || (lastFaceTrackId != listFirstTrackId)) {
|
if (listIsEmpty || (lastFaceTrackId != listFirstTrackId)) {
|
||||||
if (lastFaceTrackId != -1) {
|
if (lastFaceTrackId != -1 && currentUserId!=null) {
|
||||||
mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||||
Timber.tag(TAG).i("$lastFaceTrackId 用户离开")
|
Timber.tag(TAG).i("$lastFaceTrackId 用户离开")
|
||||||
lastFaceTrackId = -1
|
lastFaceTrackId = -1
|
||||||
postUserData()
|
postUserData()
|
||||||
if (mealPickupMode == 0) {
|
if (mealPickupMode == 1 || isKeepFaceState) {
|
||||||
|
step2FaceRecognizing(currentFood!!)
|
||||||
|
isKeepFaceState = false
|
||||||
|
} else {
|
||||||
activity.isAnalyzing = false
|
activity.isAnalyzing = false
|
||||||
step1FoodRecognizing()
|
step1FoodRecognizing()
|
||||||
} else {
|
|
||||||
step2FaceRecognizing(currentFood!!)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1115,7 +1175,40 @@ class MainScreenPresentation(
|
|||||||
if (MyApp.DEBUG) {
|
if (MyApp.DEBUG) {
|
||||||
ToastUtils.showToast("订单已生成")
|
ToastUtils.showToast("订单已生成")
|
||||||
}
|
}
|
||||||
|
currentUserId = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hideNutritionView(chargeMode: Int) {
|
||||||
|
binding.nutritionInclude.root.gone()
|
||||||
|
binding.calorieInclude.root.gone()
|
||||||
|
binding.tvFoodRecPrompt.visible()
|
||||||
|
|
||||||
|
binding.ivRecImage.gone()
|
||||||
|
binding.llPriceInfo.gone()
|
||||||
|
binding.ivPreviewImage.visible()
|
||||||
|
binding.ivFrame.visible()
|
||||||
|
|
||||||
|
// if (chargeMode == 1) {
|
||||||
|
// //不计费
|
||||||
|
//// binding.flFace.visible()
|
||||||
|
// binding.ivRecImage.gone()
|
||||||
|
// binding.llPriceInfo.gone()
|
||||||
|
// binding.ivPreviewImage.gone()
|
||||||
|
// binding.ivFrame.gone()
|
||||||
|
// } else {
|
||||||
|
// //计费
|
||||||
|
// binding.flFace.gone()
|
||||||
|
// binding.llPriceInfo.gone()
|
||||||
|
//// val imageUrl = if (currentFood!!.foodImg.isNullOrBlank()) currentFood!!.photoUri else currentFood!!.foodImg
|
||||||
|
//// binding.ivRecImage.let {
|
||||||
|
//// it.visible()
|
||||||
|
//// it.load(imageUrl)
|
||||||
|
//// }
|
||||||
|
// binding.ivRecImage.gone()
|
||||||
|
// binding.ivPreviewImage.visible()
|
||||||
|
// binding.ivFrame.visible()
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,10 +28,10 @@ object UserNutritionUtils {
|
|||||||
var (calorie, grain, fruitsVegetables, meatEggs) = List(4) { 0.0 }
|
var (calorie, grain, fruitsVegetables, meatEggs) = List(4) { 0.0 }
|
||||||
|
|
||||||
// 处理食物信息
|
// 处理食物信息
|
||||||
calorie = calculateValue(foodInfo.calorie, weight)
|
calorie = foodInfo.calorie ?: 0.0 //calculateValue(foodInfo.calorie, weight)
|
||||||
grain = calculateValue(foodInfo.stapleFood, weight)
|
grain = foodInfo.stapleFood ?: 0.0 //calculateValue(foodInfo.stapleFood, weight)
|
||||||
fruitsVegetables = calculateValue(foodInfo.fruitsVegetables, weight)
|
fruitsVegetables = foodInfo.fruitsVegetables ?: 0.0 //calculateValue(foodInfo.fruitsVegetables, weight)
|
||||||
meatEggs = calculateValue(foodInfo.meatEggs, weight)
|
meatEggs = foodInfo.meatEggs ?: 0.0 //calculateValue(foodInfo.meatEggs, weight)
|
||||||
|
|
||||||
// 合并用户数据
|
// 合并用户数据
|
||||||
//val maxKcal = (nutrition.calorie?:0.0) * calculateDinnerTypeRatio(dinnerType) / 10.0
|
//val maxKcal = (nutrition.calorie?:0.0) * calculateDinnerTypeRatio(dinnerType) / 10.0
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import android.view.Display
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
|
import android.widget.FrameLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@@ -23,6 +24,7 @@ import com.sw.dualscreen.GlobalKey
|
|||||||
import com.sw.dualscreen.R
|
import com.sw.dualscreen.R
|
||||||
import com.sw.dualscreen.activity.PayActivity
|
import com.sw.dualscreen.activity.PayActivity
|
||||||
import com.sw.dualscreen.databinding.PresentationFacePayBinding
|
import com.sw.dualscreen.databinding.PresentationFacePayBinding
|
||||||
|
import com.sw.dualscreen.ext.dp
|
||||||
import com.sw.dualscreen.model.response.MemberInfo
|
import com.sw.dualscreen.model.response.MemberInfo
|
||||||
import com.sw.dualscreen.model.response.TextBean
|
import com.sw.dualscreen.model.response.TextBean
|
||||||
import com.sw.dualscreen.utils.SPUtil
|
import com.sw.dualscreen.utils.SPUtil
|
||||||
@@ -316,13 +318,17 @@ class FacePayPresentation(
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
val layoutParams = previewView.layoutParams
|
// val layoutParams = previewView.layoutParams
|
||||||
// layoutParams.width = (608.dp * 1.5).roundToInt()
|
// layoutParams.width = (608.dp * 1.5).roundToInt()
|
||||||
// layoutParams.height = (456.dp * 1.5).roundToInt()
|
// layoutParams.height = (456.dp * 1.5).roundToInt()
|
||||||
// layoutParams.width = (608.dp * 1.5).roundToInt()
|
// layoutParams.width = (608.dp * 1.5).roundToInt()
|
||||||
// layoutParams.height = (456.dp * 1.5).roundToInt()
|
// layoutParams.height = (456.dp * 1.5).roundToInt()
|
||||||
layoutParams.width = 1024
|
// layoutParams.width = 1024
|
||||||
layoutParams.height = 768
|
// layoutParams.height = 768
|
||||||
|
val w = 500.dp
|
||||||
|
val h = 850.dp
|
||||||
|
val layoutParams = FrameLayout.LayoutParams(w, h);
|
||||||
|
|
||||||
previewView.setLayoutParams(layoutParams)
|
previewView.setLayoutParams(layoutParams)
|
||||||
faceRectView.setLayoutParams(layoutParams)
|
faceRectView.setLayoutParams(layoutParams)
|
||||||
return layoutParams
|
return layoutParams
|
||||||
@@ -363,10 +369,10 @@ class FacePayPresentation(
|
|||||||
)
|
)
|
||||||
// 调整识别窗口位置
|
// 调整识别窗口位置
|
||||||
rgbFaceRectTransformer = FaceRectTransformer(
|
rgbFaceRectTransformer = FaceRectTransformer(
|
||||||
// previewSizeRgb.width,
|
previewSizeRgb.width,
|
||||||
// previewSizeRgb.height,
|
previewSizeRgb.height,
|
||||||
layoutParams.width,
|
// layoutParams.width,
|
||||||
layoutParams.height,
|
// layoutParams.height,
|
||||||
layoutParams.width,
|
layoutParams.width,
|
||||||
layoutParams.height,
|
layoutParams.height,
|
||||||
90,
|
90,
|
||||||
|
|||||||
@@ -140,7 +140,10 @@ class ScanQrCodePayPresentation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadUserInfo(item: MemberInfo) {
|
private fun loadUserInfo(item: MemberInfo) {
|
||||||
binding.ivHeadPic.load(item.faceUrl?.ifBlank { R.drawable.ic_avatar_default })
|
binding.ivHeadPic.load(
|
||||||
|
if(item.faceUrl.isNullOrBlank()) R.drawable.ic_avatar_default
|
||||||
|
else item.faceUrl
|
||||||
|
)
|
||||||
binding.tvUserName.text = item.name
|
binding.tvUserName.text = item.name
|
||||||
|
|
||||||
val phone = item.phone ?: ""
|
val phone = item.phone ?: ""
|
||||||
|
|||||||
@@ -85,7 +85,9 @@ object SensorScaleUtils {
|
|||||||
// 打开后需要等待后才能调用,否则会 1001 SDK未初始化
|
// 打开后需要等待后才能调用,否则会 1001 SDK未初始化
|
||||||
mSensorScale?.startContinuousRead()
|
mSensorScale?.startContinuousRead()
|
||||||
// Thread.sleep(1000)
|
// Thread.sleep(1000)
|
||||||
zero()
|
|
||||||
|
// TODO: 暂时不标定---------
|
||||||
|
//zero()
|
||||||
|
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,30 +122,30 @@ class UserViewModel : BaseViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUserFaceCache2(index: Int = 0) {
|
// fun getUserFaceCache2(index: Int = 0) {
|
||||||
Timber.d("getUserFaceCache index = $index")
|
// Timber.d("getUserFaceCache index = $index")
|
||||||
launch {
|
// launch {
|
||||||
_loadFaceResult.value = false
|
// _loadFaceResult.value = false
|
||||||
val response = repository.getUserFaceCache2(index)
|
// val response = repository.getUserFaceCache2(index)
|
||||||
if (parseResponse(response)) {
|
// if (parseResponse(response)) {
|
||||||
// 获取成功一次后缓存状态
|
// // 获取成功一次后缓存状态
|
||||||
SPUtil.getInstance().put(GlobalKey.KEY_FIRST_RUN, true)
|
// SPUtil.getInstance().put(GlobalKey.KEY_FIRST_RUN, true)
|
||||||
withContext(Dispatchers.Default) {
|
// withContext(Dispatchers.Default) {
|
||||||
val list: List<UserFaceModel2> = response.result?.records ?: emptyList()
|
// val list: List<UserFaceModel2> = response.result?.records ?: emptyList()
|
||||||
val faceEntity = list.map {
|
// val faceEntity = list.map {
|
||||||
FaceEntity(it.userId, null, Base64.decode(it.face))
|
// FaceEntity(it.userId, null, Base64.decode(it.face))
|
||||||
}
|
// }
|
||||||
faceApi.updateFaceData2(index, faceEntity)
|
// faceApi.updateFaceData2(index, faceEntity)
|
||||||
}
|
// }
|
||||||
val nextPageIndex = response.result?.nextPageIndex ?: -1
|
// val nextPageIndex = response.result?.nextPageIndex ?: -1
|
||||||
if (nextPageIndex > 0) {
|
// if (nextPageIndex > 0) {
|
||||||
getUserFaceCache2(nextPageIndex)
|
// getUserFaceCache2(nextPageIndex)
|
||||||
} else {
|
// } else {
|
||||||
_loadFaceResult.value = true
|
// _loadFaceResult.value = true
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fun getCollectedFoodList(
|
fun getCollectedFoodList(
|
||||||
pageNo: Int = 1,
|
pageNo: Int = 1,
|
||||||
|
|||||||
@@ -204,7 +204,8 @@
|
|||||||
android:background="@drawable/bg_gray"
|
android:background="@drawable/bg_gray"
|
||||||
android:text="返回"
|
android:text="返回"
|
||||||
android:textSize="30sp"
|
android:textSize="30sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold"
|
||||||
|
android:textAllCaps="false" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
android:textColor="#FF5E7585"
|
android:textColor="#FF5E7585"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginTop="33dp"
|
android:layout_marginTop="28dp"
|
||||||
android:layout_marginStart="41dp"
|
android:layout_marginStart="41dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="33dp"
|
android:layout_marginTop="28dp"
|
||||||
android:layout_marginHorizontal="28dp"
|
android:layout_marginHorizontal="28dp"
|
||||||
android:background="#FF5E7585"
|
android:background="#FF5E7585"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_user_name" />
|
app:layout_constraintTop_toBottomOf="@id/tv_user_name" />
|
||||||
|
|||||||
@@ -64,10 +64,12 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:ignore="HardcodedText" />
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
|
<!-- android:layout_width="300dp"-->
|
||||||
|
<!-- android:layout_height="510dp"-->
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/flFace"
|
android:id="@+id/flFace"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="300dp"
|
||||||
android:layout_height="456dp"
|
android:layout_height="510dp"
|
||||||
android:layout_marginHorizontal="28dp"
|
android:layout_marginHorizontal="28dp"
|
||||||
android:layout_marginTop="56dp">
|
android:layout_marginTop="56dp">
|
||||||
|
|
||||||
|
|||||||
@@ -24,23 +24,29 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginVertical="50dp"
|
android:layout_marginVertical="30dp"
|
||||||
android:text="餐品识别中..."
|
android:text="餐品识别中..."
|
||||||
android:textColor="#ff0a1428"
|
android:textColor="#ff0a1428"
|
||||||
android:textSize="40sp"
|
android:textSize="40sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<!-- android:layout_width="300dp"-->
|
||||||
|
<!-- android:layout_height="450dp"-->
|
||||||
|
<!-- android:layout_width="330dp"-->
|
||||||
|
<!-- android:layout_height="495dp"-->
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/flCameraView"
|
android:id="@+id/flCameraView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="456dp"
|
android:layout_height="510dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginHorizontal="28dp"
|
android:layout_marginHorizontal="28dp"
|
||||||
android:visibility="visible">
|
android:visibility="visible">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/flFace"
|
android:id="@+id/flFace"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="300dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="510dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
<TextureView
|
<TextureView
|
||||||
android:id="@+id/dual_camera_texture_preview_rgb"
|
android:id="@+id/dual_camera_texture_preview_rgb"
|
||||||
@@ -73,26 +79,34 @@
|
|||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="28dp"
|
||||||
|
android:background="@drawable/ic_camera_rect" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!-- android:layout_height="456dp"-->
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
android:id="@+id/ivPreviewImage"
|
android:id="@+id/ivPreviewImage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="456dp"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:shapeAppearance="@style/round10dpCornerStyle"
|
app:shapeAppearance="@style/round10dpCornerStyle"
|
||||||
tools:background="@mipmap/ic_launcher"/>
|
tools:src="@mipmap/ic_launcher"/>
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
android:id="@+id/ivRecImage"
|
android:id="@+id/ivRecImage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="456dp"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
tools:background="@mipmap/ic_launcher_round"
|
tools:src="@mipmap/ic_launcher_round"
|
||||||
app:shapeAppearance="@style/round10dpCornerStyle"
|
app:shapeAppearance="@style/round10dpCornerStyle"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/ivFrame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="28dp"
|
android:layout_margin="28dp"
|
||||||
@@ -164,7 +178,6 @@
|
|||||||
android:textColor="#ffff3232"
|
android:textColor="#ffff3232"
|
||||||
android:textSize="80sp"
|
android:textSize="80sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginTop="42dp"
|
|
||||||
android:background="@drawable/setting_border" />
|
android:background="@drawable/setting_border" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Base.Theme.DualScreen" parent="Theme.Material3.DayNight.NoActionBar">
|
<!-- <style name="Base.Theme.DualScreen" parent="Theme.Material3.DayNight.NoActionBar">-->
|
||||||
|
<style name="Base.Theme.DualScreen" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
<!-- Customize your light theme here. -->
|
<!-- Customize your light theme here. -->
|
||||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -88,8 +88,10 @@ public class ConfigUtil {
|
|||||||
* 默认相机分辨率
|
* 默认相机分辨率
|
||||||
*/
|
*/
|
||||||
// private static final String DEFAULT_PREVIEW_SIZE = "1280x720";
|
// private static final String DEFAULT_PREVIEW_SIZE = "1280x720";
|
||||||
|
// private static final String DEFAULT_PREVIEW_SIZE = "1080x720";
|
||||||
|
private static final String DEFAULT_PREVIEW_SIZE = "720x1080";
|
||||||
// private static final String DEFAULT_PREVIEW_SIZE = "608x456";
|
// private static final String DEFAULT_PREVIEW_SIZE = "608x456";
|
||||||
private static final String DEFAULT_PREVIEW_SIZE = "1024x768";
|
// private static final String DEFAULT_PREVIEW_SIZE = "1024x768";
|
||||||
// private static final String DEFAULT_PREVIEW_SIZE = "800x600";
|
// private static final String DEFAULT_PREVIEW_SIZE = "800x600";
|
||||||
// private static final String DEFAULT_PREVIEW_SIZE = "640x480";
|
// private static final String DEFAULT_PREVIEW_SIZE = "640x480";
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ public class FaceApi {
|
|||||||
faceDao.deleteAll();
|
faceDao.deleteAll();
|
||||||
faceDao.resetId();
|
faceDao.resetId();
|
||||||
}
|
}
|
||||||
faceDao.insert(list);
|
List<Long> insertIdList = faceDao.insert(list);
|
||||||
|
Log.d(TAG, "updateFaceData: count = " + insertIdList.size());
|
||||||
|
List<FaceEntity> queryList = faceDao.getAllFaces();
|
||||||
|
Log.d(TAG, "updateFaceData: queryList.size = " + queryList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateFaceData2(int index, List<FaceEntity> list) {
|
public void updateFaceData2(int index, List<FaceEntity> list) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.sw.plate.utils.arcface;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
@@ -215,6 +216,7 @@ public class FaceRectView extends View {
|
|||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
paint.setStrokeWidth(faceRectThickness);
|
paint.setStrokeWidth(faceRectThickness);
|
||||||
paint.setColor(drawInfo.getColor());
|
paint.setColor(drawInfo.getColor());
|
||||||
|
// paint.setColor(Color.parseColor("#FF0000"));
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
|
||||||
Path mPath = new Path();
|
Path mPath = new Path();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public interface FaceDao {
|
|||||||
Long insert(FaceEntity faceEntity);
|
Long insert(FaceEntity faceEntity);
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
void insert(List<FaceEntity> items);
|
List<Long> insert(List<FaceEntity> items);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取已注册的人脸数
|
* 获取已注册的人脸数
|
||||||
|
|||||||
@@ -586,9 +586,14 @@ public class RecognizeViewModel extends ViewModel implements RecognizeCallback {
|
|||||||
if (recognizeStatus != null) {
|
if (recognizeStatus != null) {
|
||||||
if (recognizeStatus == RequestFeatureStatus.FAILED) {
|
if (recognizeStatus == RequestFeatureStatus.FAILED) {
|
||||||
color = RecognizeColor.COLOR_FAILED;
|
color = RecognizeColor.COLOR_FAILED;
|
||||||
}
|
}else if (recognizeStatus == RequestFeatureStatus.SUCCEED) {
|
||||||
if (recognizeStatus == RequestFeatureStatus.SUCCEED) {
|
|
||||||
color = RecognizeColor.COLOR_SUCCESS;
|
color = RecognizeColor.COLOR_SUCCESS;
|
||||||
|
} else if (recognizeStatus == RequestFeatureStatus.TO_RETRY) {
|
||||||
|
color = RecognizeColor.COLOR_UNKNOWN;
|
||||||
|
//需要重试
|
||||||
|
// FaceEntity faceEntity = new FaceEntity("2",null, null);
|
||||||
|
// CompareResult result = new CompareResult(faceEntity, 0.0f);
|
||||||
|
// recognizeUserId.postValue(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (liveness != null && liveness == LivenessInfo.NOT_ALIVE) {
|
if (liveness != null && liveness == LivenessInfo.NOT_ALIVE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user