style(ui): 调整食物识别页面布局间距和移除测试代码
- 调整 activity_food_recognize.xml 中多个组件的 margin 间距 - 移除 FoodRecognizeActivity.kt 中的测试数据相关注释代码 - 为 list_item_food2.xml 添加可点击背景效果 - 清理 PrepareFoodActivity.kt 中的无用导入和调整常量值 - 优化 PrepareFoodActivity.kt 中的条件判断换行格式
This commit is contained in:
@@ -176,26 +176,26 @@ class FoodRecognizeActivity : BaseActivity() {
|
||||
}
|
||||
currentWeight = intent.getDoubleExtra(EXTRA_CURRENT_WEIGHT, 0.0)
|
||||
binding.tvWeight.text = "${currentWeight}g"
|
||||
val tempList = arrayListOf<GoodsItem>()
|
||||
// val tempList = arrayListOf<GoodsItem>()
|
||||
recognizeNameList?.apply {
|
||||
forEach {
|
||||
val goodsName = it.name.split("WP").first()
|
||||
goodsNameList.add(goodsName)
|
||||
nameScoreMap.put(goodsName, it)
|
||||
|
||||
// TODO: 测试数据,临时使用-------------------------
|
||||
val testData = buildTestData(it)
|
||||
tempList.add(testData)
|
||||
// TODO: 测试数据,临时使用-------------------------
|
||||
// // TODO: 测试数据,临时使用-------------------------
|
||||
// val testData = buildTestData(it)
|
||||
// tempList.add(testData)
|
||||
// // TODO: 测试数据,临时使用-------------------------
|
||||
}
|
||||
// TODO: 测试数据,临时使用-------------------------
|
||||
loadRecognizeList(tempList)
|
||||
// TODO: 测试数据,临时使用-------------------------
|
||||
// // TODO: 测试数据,临时使用-------------------------
|
||||
// loadRecognizeList(tempList)
|
||||
// // TODO: 测试数据,临时使用-------------------------
|
||||
recognizeNameList = null
|
||||
}
|
||||
|
||||
// TODO: 注释掉等接口正常再调用,临时使用测试数据
|
||||
//netViewModel.queryGoodsList(goodsType = "0", goodsNames = goodsNameList)
|
||||
//TODO: 注释掉等接口正常再调用,临时使用测试数据
|
||||
netViewModel.queryGoodsList(goodsType = "0", goodsNames = goodsNameList)
|
||||
}
|
||||
|
||||
private fun buildTestData(item: FoodModule.IdNameScore): GoodsItem {
|
||||
|
||||
@@ -7,13 +7,10 @@ import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.content.IntentCompat
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.shuwei.dish.match.R
|
||||
@@ -31,7 +28,6 @@ import com.shuwei.dish.match.objbox.FoodModule
|
||||
import com.shuwei.dish.match.utils.AddressUtil
|
||||
import com.shuwei.dish.match.utils.CameraUtils
|
||||
import com.shuwei.dish.match.utils.ImageUtil
|
||||
import com.shuwei.dish.match.utils.KeyboardUtil
|
||||
import com.shuwei.dish.match.utils.SpTool
|
||||
import com.shuwei.dish.match.utils.WeightUtil
|
||||
import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
||||
@@ -43,7 +39,6 @@ import com.shuwei.dish.match.utils.ext.toJsonString
|
||||
import com.shuwei.dish.match.utils.ext.toast
|
||||
import com.shuwei.dish.match.utils.ext.visible
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuItem
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -56,11 +51,11 @@ import kotlin.math.abs
|
||||
class PrepareFoodActivity : BaseActivity() {
|
||||
|
||||
companion object {
|
||||
const val TAG = "CookActivity"
|
||||
const val TAG = "PrepareFoodActivity"
|
||||
const val FOOD_ITEM = "foodItem"
|
||||
const val PAGE_FROM = "pageFrom"
|
||||
const val HOME = "home"
|
||||
const val WEIGHT_CHANGE_VALUE = 15
|
||||
const val WEIGHT_CHANGE_VALUE = 5
|
||||
const val WEIGHT_RECOGNIZE_VALUE = 10
|
||||
|
||||
/** 主材数量上限 */
|
||||
@@ -224,9 +219,9 @@ class PrepareFoodActivity : BaseActivity() {
|
||||
FoodRecognizeActivity.close()
|
||||
return
|
||||
}
|
||||
if (!pageVisible || manualCancelFlag || isTakingPhoto.get() || showRecognizePage || abs(
|
||||
lastWeight - weight
|
||||
) <= WEIGHT_CHANGE_VALUE
|
||||
if (
|
||||
!pageVisible || manualCancelFlag || isTakingPhoto.get() || showRecognizePage ||
|
||||
abs(lastWeight - weight) <= WEIGHT_CHANGE_VALUE
|
||||
) {
|
||||
Log.d(
|
||||
TAG,
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
android:id="@+id/flListContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="260dp"
|
||||
android:layout_marginTop="12dp">
|
||||
android:layout_marginTop="20dp">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvRecognizeList"
|
||||
@@ -85,7 +85,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@drawable/shape_white_12_corners"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
android:id="@+id/btnChangeFood"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginTop="40dp"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:background="@drawable/shape_green_bg"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
@@ -134,7 +134,7 @@
|
||||
android:id="@+id/btnCancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginVertical="30dp"
|
||||
android:layout_marginVertical="40dp"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:background="@drawable/shape_white_12_corners"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="center"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:background="@drawable/shape_white_f6_10_corners"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="32sp"
|
||||
|
||||
Reference in New Issue
Block a user