4 Commits
Author SHA1 Message Date
lvmeng 7a75e943db fix(ui): 优化菜品制作界面布局和称重功能
- 调整 activity_prepare_cook.xml 中的边距和布局参数
- 更新称重显示文本为“称重:0g”并调整样式
- 在 BaseActivity 中将 loading 显示和隐藏操作移到主线程执行
- 为称重按钮添加防抖点击监听器和清零功能
- 在食物识别过程中添加加载提示和调试日志
- 修复食物识别流程中的加载框显示和隐藏逻辑
- 添加识别结果页面加载功能和取消判断
2026-04-27 14:32:03 +08:00
lvmeng 634f23a76a style(ui): 优化食物识别界面布局和对话框标题
- 将食物照片区域包装在 CardView 中并调整样式
- 为食材列表容器添加滚动指示条功能
- 替换 RecyclerView 的滚动条为自定义指示条
- 更新多个对话框的标题文本以提高一致性
- 在准备烹饪界面添加重量显示文本
- 优化适配器数据更新和列表滚动逻辑
- 防止 StateFlow 重放导致的重复数据加载
- 添加新的滚动条绘制资源文件
2026-04-27 13:50:56 +08:00
lvmeng b110cc97a0 refactor(collect): 重构食材采集功能界面和适配器
- 将按钮组件替换为TextView以支持更好的交互效果
- 添加selectableItemBackground实现点击反馈效果
- 重命名食材采样为食材采集保持术语一致性
- 替换FoodCollectionAdapter为VectorCollectionAdapter适配器
- 更新列表项布局从list_item_food_collection到list_item_vector_collection
- 添加FoodSearchAdapter适配器用于食材搜索功能
- 重构CollectFragment中的数据绑定和UI逻辑
- 修改相机容器布局位置优化界面结构
- 更新资源文件名和颜色定义提升代码可读性
- 调整保存按钮样式增强视觉效果
- 修改提示对话框内容精确表达功能意图
2026-04-27 10:21:37 +08:00
lvmeng fda88fff33 feat(ui): 添加地址显示功能到调味品网格适配器
- 在 Seasoning22GridAdapter 中启用地址显示
- 在 Seasoning18GridAdapter 中启用地址显示
- 更新点击事件以显示地址对话框
- 为网格项目添加地址显示支持
2026-04-27 08:57:30 +08:00
26 changed files with 389 additions and 157 deletions
@@ -0,0 +1,43 @@
package com.shuwei.dish.match.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.shuwei.dish.match.R
import com.shuwei.dish.match.databinding.ListItemSearchFoodBinding
import com.shuwei.dish.match.databinding.ListItemSearchGoodsInfoBinding
import com.shuwei.dish.match.entity.CookFoodGoodsEntity
import com.shuwei.dish.match.utils.ext.gone
import com.shuwei.dish.match.utils.ext.roundedDecimalPlace
import com.shuwei.dish.match.utils.ext.visible
class FoodSearchAdapter(private var list: MutableList<CookFoodGoodsEntity>) :
BaseQuickAdapter<CookFoodGoodsEntity, FoodSearchAdapter.VH>(list) {
override fun onBindViewHolder(
holder: VH,
position: Int,
item: CookFoodGoodsEntity?
) {
item ?: return
holder.binding.tvFoodName.run {
text = item.goodsName
isChecked = item.isClicked
}
}
override fun onCreateViewHolder(
context: Context,
parent: ViewGroup,
viewType: Int
): VH {
val binding = ListItemSearchFoodBinding.inflate(LayoutInflater.from(context), parent, false)
return VH(binding)
}
inner class VH(var binding: ListItemSearchFoodBinding) : QuickViewHolder(binding.root)
}
@@ -8,18 +8,18 @@ import android.widget.ImageView
import com.chad.library.adapter4.BaseQuickAdapter import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.shuwei.dish.match.R import com.shuwei.dish.match.R
import com.shuwei.dish.match.databinding.ListItemFoodCollectionBinding import com.shuwei.dish.match.databinding.ListItemVectorCollectionBinding
import com.shuwei.dish.match.objbox.FoodCollectionBean import com.shuwei.dish.match.objbox.FoodCollectionBean
import com.shuwei.dish.match.utils.ext.load import com.shuwei.dish.match.utils.ext.load
class FoodCollectionAdapter (var list: MutableList<FoodCollectionBean>) : class VectorCollectionAdapter (var list: MutableList<FoodCollectionBean>) :
BaseQuickAdapter<FoodCollectionBean, FoodCollectionAdapter.VH>(list) { BaseQuickAdapter<FoodCollectionBean, VectorCollectionAdapter.VH>(list) {
inner class VH(var binding: ListItemFoodCollectionBinding) : QuickViewHolder(binding.root) inner class VH(var binding: ListItemVectorCollectionBinding) : QuickViewHolder(binding.root)
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH { override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
val inflater = LayoutInflater.from(context) val inflater = LayoutInflater.from(context)
val binding = ListItemFoodCollectionBinding.inflate(inflater, parent, false) val binding = ListItemVectorCollectionBinding.inflate(inflater, parent, false)
return VH(binding) return VH(binding)
} }
@@ -162,18 +162,22 @@ open class BaseActivity : AppCompatActivity() {
} }
fun showLoading(msg: String = "加载中……") { fun showLoading(msg: String = "加载中……") {
handler.post {
Loading.show( Loading.show(
context = this, context = this,
message = msg message = msg
) )
} }
}
fun dismissLoading() { fun dismissLoading() {
handler.post {
Loading.dismiss() Loading.dismiss()
} }
}
fun delayDismissLoading() { fun delayDismissLoading() {
window.decorView.postDelayed({ handler.postDelayed({
Loading.dismiss() Loading.dismiss()
}, 500) }, 500)
} }
@@ -65,7 +65,7 @@ class CollectedFoodActivity : BaseActivity() {
appendText(" 删除后无法恢复,${separator}确认要删除吗?") appendText(" 删除后无法恢复,${separator}确认要删除吗?")
} }
CommonDialog(this) CommonDialog(this)
.setTitle("温馨提示") .setTitle("删除提示")
.setContent(content) .setContent(content)
.setNegativeButton("取消") .setNegativeButton("取消")
.setPositiveButton("确认") { .setPositiveButton("确认") {
@@ -117,8 +117,8 @@ class DishSamplingActivity : BaseActivity() {
private fun saveDataRemindDialog() { private fun saveDataRemindDialog() {
CommonDialog(this) CommonDialog(this)
.setTitle("温馨提示") .setTitle("返回提示")
.setContent("您好,当前页面存在未保存的数据,确认返回吗?") .setContent("您好,当前页面存在未保存的数据,\n确认返回吗?")
.setNegativeButton("取消") .setNegativeButton("取消")
.setPositiveButton("确认") { .setPositiveButton("确认") {
if (pageFrom == HOME) { if (pageFrom == HOME) {
@@ -6,6 +6,7 @@ import android.os.Bundle
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.content.IntentCompat import androidx.core.content.IntentCompat
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.shuwei.dish.match.adapter.GoodsInfoSearchAdapter import com.shuwei.dish.match.adapter.GoodsInfoSearchAdapter
import com.shuwei.dish.match.base.BaseActivity import com.shuwei.dish.match.base.BaseActivity
import com.shuwei.dish.match.databinding.ActivityFoodRecognizeBinding import com.shuwei.dish.match.databinding.ActivityFoodRecognizeBinding
@@ -93,6 +94,15 @@ class FoodRecognizeActivity : BaseActivity() {
/** 当前待延迟更新的目标重量,避免相同重量重复重置计时器 */ /** 当前待延迟更新的目标重量,避免相同重量重复重置计时器 */
private var pendingWeight = 0.0 private var pendingWeight = 0.0
/** 右侧自定义滚动指示条最小高度 */
private val scrollIndicatorMinHeightPx by lazy { (24 * resources.displayMetrics.density).toInt() }
private val scrollListener = object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
updateScrollIndicator()
}
}
private val adapter = GoodsInfoSearchAdapter(list).apply { private val adapter = GoodsInfoSearchAdapter(list).apply {
setOnItemClickListener { _, _, position -> setOnItemClickListener { _, _, position ->
list.forEachIndexed { i, item -> item.isClicked = (i == position) } list.forEachIndexed { i, item -> item.isClicked = (i == position) }
@@ -166,9 +176,13 @@ class FoodRecognizeActivity : BaseActivity() {
* 初始化 RecyclerView * 初始化 RecyclerView
*/ */
private fun initRecyclerView() { private fun initRecyclerView() {
binding.recyclerView.run { binding.recyclerView.let {
layoutManager = GridLayoutManager(this@FoodRecognizeActivity, 2) it.layoutManager = GridLayoutManager(this@FoodRecognizeActivity, 2)
adapter = this@FoodRecognizeActivity.adapter it.adapter = adapter
it.isVerticalScrollBarEnabled = false
it.removeOnScrollListener(scrollListener)
it.addOnScrollListener(scrollListener)
it.post { updateScrollIndicator() }
} }
updateListVisibility() updateListVisibility()
} }
@@ -178,12 +192,57 @@ class FoodRecognizeActivity : BaseActivity() {
*/ */
private fun updateListVisibility() { private fun updateListVisibility() {
if (list.isEmpty()) { if (list.isEmpty()) {
binding.recyclerView.gone() binding.flListContainer.gone()
} else { } else {
binding.recyclerView.visible() binding.flListContainer.visible()
binding.recyclerView.post { updateScrollIndicator() }
} }
} }
/**
* 根据 RecyclerView 滚动状态刷新右侧自定义指示条
*/
private fun updateScrollIndicator() {
val recyclerView = binding.recyclerView
val track = binding.vScrollIndicatorTrack
val thumb = binding.vScrollIndicatorThumb
if (!recyclerView.canScrollVertically(1) && !recyclerView.canScrollVertically(-1)) {
track.gone()
thumb.gone()
return
}
val range = recyclerView.computeVerticalScrollRange()
val extent = recyclerView.computeVerticalScrollExtent()
val offset = recyclerView.computeVerticalScrollOffset()
if (range <= 0 || extent <= 0 || range <= extent) {
track.gone()
thumb.gone()
return
}
val trackHeight = track.height.takeIf { it > 0 } ?: recyclerView.height
if (trackHeight <= 0) return
val thumbHeight = ((extent.toFloat() / range) * trackHeight)
.toInt()
.coerceAtLeast(scrollIndicatorMinHeightPx)
.coerceAtMost(trackHeight)
val maxTop = (trackHeight - thumbHeight).coerceAtLeast(0)
val scrollable = (range - extent).coerceAtLeast(1)
val thumbTop = ((offset.toFloat() / scrollable) * maxTop).toInt().coerceIn(0, maxTop)
if (thumb.layoutParams.height != thumbHeight) {
thumb.layoutParams = thumb.layoutParams.apply { height = thumbHeight }
}
thumb.translationY = thumbTop.toFloat()
track.visible()
thumb.visible()
}
/** /**
* 初始化按钮点击事件 * 初始化按钮点击事件
*/ */
@@ -219,6 +278,7 @@ class FoodRecognizeActivity : BaseActivity() {
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
binding.tvSelectedFood.text = item.goodsName ?: "-" binding.tvSelectedFood.text = item.goodsName ?: "-"
updateListVisibility() updateListVisibility()
binding.recyclerView.post { updateScrollIndicator() }
} }
/** /**
@@ -122,11 +122,22 @@ class PrepareCookActivity : BaseActivity() {
} }
private fun addViewClickListener() { private fun addViewClickListener() {
binding.tvShowWeight.setOnClickListener {
showLoading("正在清零……")
WeightUtil.tareTwo(AddressUtil.ONE)
delayDismissLoading()
}
WeightUtil.addWeightListener( WeightUtil.addWeightListener(
weightKey = TAG, weightKey = TAG,
getWeight = { address, state, weight -> getWeight = { address, state, weight ->
if (address == AddressUtil.ONE && state == WeightUtil.STATE_STABLE) { if (address == AddressUtil.ONE && state == WeightUtil.STATE_STABLE) {
runOnUiThread { runOnUiThread {
binding.tvShowWeight.run {
if (tag != weight) {
text = "称重:${weight}g"
tag = weight
}
}
recognizeFood(weight) recognizeFood(weight)
} }
} }
@@ -201,8 +212,10 @@ class PrepareCookActivity : BaseActivity() {
return 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, "recognizeFood, lastWeight:$lastWeight, weight:$weight, pageVisible:$pageVisible, manualCancelFlag:$manualCancelFlag, isTakingPhoto:${isTakingPhoto.get()}")
return return
} }
showLoading("识别中……")
isTakingPhoto.set(true) isTakingPhoto.set(true)
cameraUtils.takePhoto( cameraUtils.takePhoto(
succCallback = cameraSuccessCallback, succCallback = cameraSuccessCallback,
@@ -222,13 +235,12 @@ class PrepareCookActivity : BaseActivity() {
existing.isSetFinished = true existing.isSetFinished = true
dishPartAdapter.notifyItemChanged(list.indexOf(existing)) dishPartAdapter.notifyItemChanged(list.indexOf(existing))
} else { } else {
list.add(entity.also { dishPartAdapter.add(entity.also {
it.isNewDishType = true it.isNewDishType = true
it.isSetFinished = true it.isSetFinished = true
}) })
val position = list.size - 1
dishPartAdapter.notifyItemInserted(position) binding.rvDishPartList.smoothScrollToPosition(list.size - 1)
binding.rvDishPartList.smoothScrollToPosition(position)
} }
} }
@@ -265,8 +277,8 @@ class PrepareCookActivity : BaseActivity() {
private fun showRemindDialog() { private fun showRemindDialog() {
CommonDialog(this) CommonDialog(this)
.setTitle("制作提示") .setTitle(getString(R.string.food_remind_01))
.setContent(getString(R.string.food_remind_01)) .setContent(getString(R.string.food_remind_02))
.setNegativeButton("返回调整") .setNegativeButton("返回调整")
.setPositiveButton("确认无误") { openSubmitPage() } .setPositiveButton("确认无误") { openSubmitPage() }
.setOnDismissCallback { hideStatusBar() } .setOnDismissCallback { hideStatusBar() }
@@ -280,11 +292,14 @@ class PrepareCookActivity : BaseActivity() {
netViewModel.foodDetailState.collect { state -> netViewModel.foodDetailState.collect { state ->
when (state) { when (state) {
is UiState.Success -> { is UiState.Success -> {
// 防止 StateFlow 重放导致 list 被重复清空
if (isDetailLoaded) return@collect
val detail = state.data val detail = state.data
if (detail == null) { if (detail == null) {
toast("查询菜品信息为空") toast("查询菜品信息为空")
return@collect return@collect
} }
isDetailLoaded = true
loadDishDetail(detail) loadDishDetail(detail)
} }
@@ -336,6 +351,7 @@ class PrepareCookActivity : BaseActivity() {
} }
private var firstReqSize = 0 private var firstReqSize = 0
private var isDetailLoaded = false
private val list = mutableListOf<CookFoodGoodsEntity>() private val list = mutableListOf<CookFoodGoodsEntity>()
private val dishPartAdapter by lazy { private val dishPartAdapter by lazy {
DishPartAdapter(list = list).apply { DishPartAdapter(list = list).apply {
@@ -438,8 +454,8 @@ class PrepareCookActivity : BaseActivity() {
*/ */
private fun saveDataRemindDialog() { private fun saveDataRemindDialog() {
CommonDialog(this) CommonDialog(this)
.setTitle("温馨提示") .setTitle("返回提示")
.setContent("您好,当前页面存在未保存的数据,确认返回吗?") .setContent("您好,当前页面存在未保存的数据,\n确认返回吗?")
.setNegativeButton("取消") .setNegativeButton("取消")
.setPositiveButton("确认") { .setPositiveButton("确认") {
if (SpTool.cookMode == 1 && pageFrom == HOME) { if (SpTool.cookMode == 1 && pageFrom == HOME) {
@@ -461,12 +477,14 @@ class PrepareCookActivity : BaseActivity() {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
val bitmap = ImageUtil.uriToBitmap(this@PrepareCookActivity, uri) val bitmap = ImageUtil.uriToBitmap(this@PrepareCookActivity, uri)
if (bitmap == null) { if (bitmap == null) {
dismissLoading()
Log.d(TAG, "takePhoto bitmap is null") Log.d(TAG, "takePhoto bitmap is null")
isTakingPhoto.set(false) isTakingPhoto.set(false)
return@withContext return@withContext
} }
val foodScoreList = FoodModule.getFoodScoreList(bitmap) val foodScoreList = FoodModule.getFoodScoreList(bitmap)
if (foodScoreList.isEmpty()) { if (foodScoreList.isEmpty()) {
dismissLoading()
Log.d(TAG, "takePhoto foodScoreList is empty") Log.d(TAG, "takePhoto foodScoreList is empty")
isTakingPhoto.set(false) isTakingPhoto.set(false)
return@withContext return@withContext
@@ -485,6 +503,7 @@ class PrepareCookActivity : BaseActivity() {
Log.d(TAG, "takePhoto failure") Log.d(TAG, "takePhoto failure")
isTakingPhoto.set(false) isTakingPhoto.set(false)
toast(errMsg) toast(errMsg)
dismissLoading()
} }
/** /**
@@ -492,10 +511,11 @@ class PrepareCookActivity : BaseActivity() {
* @param list 食材列表 * @param list 食材列表
*/ */
private fun queryFood(list: List<FoodModule.IdNameScore>) { private fun queryFood(list: List<FoodModule.IdNameScore>) {
Log.d(TAG, "takePhoto queryFood, list=${list.toString()}") Log.d(TAG, "takePhoto queryFood, list=$list")
//调用接口成功,返回食材列表设置isTakingPhoto.set(false),暂时写死数据 //调用接口成功,返回食材列表设置isTakingPhoto.set(false),暂时写死数据
val foodList = mutableListOf<CookFoodGoodsEntity>() val foodList = mutableListOf<CookFoodGoodsEntity>()
list.forEachIndexed { index, food -> list.forEachIndexed { index, food ->
Log.d(TAG, "takePhoto queryFood, index=${index},food=$food")
var foodName = "" var foodName = ""
var foodId = "" var foodId = ""
food.name.split("WP").let { food.name.split("WP").let {
@@ -517,6 +537,23 @@ class PrepareCookActivity : BaseActivity() {
} }
) )
} }
Log.d(TAG, "takePhoto queryFood, 数据添加完成")
handler.postDelayed({
dismissLoading()
loadRecognizeResultPage(foodList)
}, 1000)
}
/**
* 加载识别结果页面
*/
private fun loadRecognizeResultPage(foodList: List<CookFoodGoodsEntity>) {
if (currentWeight < WEIGHT_RECOGNIZE_VALUE) {
Log.d(TAG, "takePhoto queryFood, 已取消")
toast("已取消")
isTakingPhoto.set(false)
return
}
lastWeight = currentWeight lastWeight = currentWeight
FoodRecognizeActivity.start( FoodRecognizeActivity.start(
activity = this, activity = this,
@@ -369,7 +369,7 @@ class SamplingListActivity : BaseActivity() {
private fun showDeviceConfigDialog() { private fun showDeviceConfigDialog() {
CommonDialog(this) CommonDialog(this)
.setTitle("温馨提示") .setTitle("配置提示")
.setContent("请先在设备配置页面进行调料设置") .setContent("请先在设备配置页面进行调料设置")
.setNegativeButton("取消") .setNegativeButton("取消")
.setPositiveButton("去设置") { startActivity<SettingActivity>() } .setPositiveButton("去设置") { startActivity<SettingActivity>() }
@@ -84,7 +84,7 @@ class SelectDishActivity : BaseActivity() {
private fun showDeviceConfigDialog() { private fun showDeviceConfigDialog() {
CommonDialog(this) CommonDialog(this)
.setTitle("温馨提示") .setTitle("配置提示")
.setContent("请先在设备配置页面进行调料设置") .setContent("请先在设备配置页面进行调料设置")
.setNegativeButton("取消") .setNegativeButton("取消")
.setPositiveButton("去设置") { startActivity<SettingActivity>() } .setPositiveButton("去设置") { startActivity<SettingActivity>() }
@@ -115,8 +115,8 @@ class SettingActivity : BaseActivity() {
private fun showNotGrantedCameraPermissionDialog() { private fun showNotGrantedCameraPermissionDialog() {
CommonDialog(this) CommonDialog(this)
.setTitle("温馨提示") .setTitle("权限提示")
.setContent("暂无相机权限,无法使用菜品采集功能,请确认是否同意开始权限?") .setContent("暂无相机权限,无法使用食材采集功能,请确认是否同意开始权限?")
.setNegativeButton("不同意") .setNegativeButton("不同意")
.setPositiveButton("同意") { .setPositiveButton("同意") {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
@@ -94,7 +94,7 @@ class SingleFragmentActivity : BaseActivity() {
* 根据页面类型返回对应标题文本 * 根据页面类型返回对应标题文本
*/ */
private fun getTitleForPage(pageType: PageType): String = when (pageType) { private fun getTitleForPage(pageType: PageType): String = when (pageType) {
PageType.FOOD_COLLECT -> "食材采" PageType.FOOD_COLLECT -> "食材采"
PageType.COOK_MODE -> "餐品模式" PageType.COOK_MODE -> "餐品模式"
PageType.SEASONING_CONFIG -> "调料区设置" PageType.SEASONING_CONFIG -> "调料区设置"
} }
@@ -103,7 +103,8 @@ class SlaveActivity : BaseActivity() {
scale22Adapter = Seasoning22GridAdapter( scale22Adapter = Seasoning22GridAdapter(
size.largeSize, size.largeSize,
size.smallSize, size.smallSize,
showNameOnly = false showNameOnly = false,
showAddress = true
).also { ).also {
it.onItemClick = { scale, _ -> showTareDialog(scale.address) } it.onItemClick = { scale, _ -> showTareDialog(scale.address) }
} }
@@ -116,7 +117,7 @@ class SlaveActivity : BaseActivity() {
override fun getSpanSize(position: Int) = 1 override fun getSpanSize(position: Int) = 1
} }
} }
scale18Adapter = Seasoning18GridAdapter(showNameOnly = false).also { scale18Adapter = Seasoning18GridAdapter(showNameOnly = false, showAddress = true).also {
it.onItemClick = { scale, _ -> showTareDialog(scale.address) } it.onItemClick = { scale, _ -> showTareDialog(scale.address) }
} }
binding.rvScaleList.adapter = scale18Adapter binding.rvScaleList.adapter = scale18Adapter
@@ -423,8 +423,8 @@ class SubmitFoodActivity : BaseActivity() {
*/ */
private fun remindSaveDataDialog() { private fun remindSaveDataDialog() {
CommonDialog(this) CommonDialog(this)
.setTitle("温馨提示") .setTitle("保存提示")
.setContent("请确认是否存在未保存的数据?") .setContent("可能存在未保存的数据,请确认")
.setNegativeButton("取消,留在页面") .setNegativeButton("取消,留在页面")
.setNeutralButton("返回上页,不保存") { finish() } .setNeutralButton("返回上页,不保存") { finish() }
.setPositiveButton("保存为烹饪中菜品") { cook() } .setPositiveButton("保存为烹饪中菜品") { cook() }
@@ -436,7 +436,7 @@ class SubmitFoodActivity : BaseActivity() {
*/ */
private fun showRemindDialog(content: CharSequence, action: () -> Unit) { private fun showRemindDialog(content: CharSequence, action: () -> Unit) {
CommonDialog(this) CommonDialog(this)
.setTitle("温馨提示") .setTitle(food?.foodName ?: "温馨提示")
.setContent(content) .setContent(content)
.setNegativeButton("取消") .setNegativeButton("取消")
.setPositiveButton("确认") { action() } .setPositiveButton("确认") { action() }
@@ -16,11 +16,13 @@ import androidx.core.view.doOnLayout
import androidx.core.view.updateLayoutParams import androidx.core.view.updateLayoutParams
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import com.shuwei.dish.match.R import com.shuwei.dish.match.R
import com.shuwei.dish.match.adapter.FoodCollectionAdapter import com.shuwei.dish.match.adapter.VectorCollectionAdapter
import com.shuwei.dish.match.adapter.FoodSearchAdapter
import com.shuwei.dish.match.base.BaseFragment import com.shuwei.dish.match.base.BaseFragment
import com.shuwei.dish.match.databinding.FragmentCollectBinding import com.shuwei.dish.match.databinding.FragmentCollectBinding
import com.shuwei.dish.match.databinding.LayoutCameraPreviewBinding import com.shuwei.dish.match.databinding.LayoutCameraPreviewBinding
import com.shuwei.dish.match.dialog.Loading import com.shuwei.dish.match.dialog.Loading
import com.shuwei.dish.match.entity.CookFoodGoodsEntity
import com.shuwei.dish.match.objbox.FoodCollectionBean import com.shuwei.dish.match.objbox.FoodCollectionBean
import com.shuwei.dish.match.objbox.FoodModule import com.shuwei.dish.match.objbox.FoodModule
import com.shuwei.dish.match.ui.CollectedFoodActivity import com.shuwei.dish.match.ui.CollectedFoodActivity
@@ -35,7 +37,7 @@ import com.shuwei.dish.match.utils.ext.dp
import com.shuwei.dish.match.utils.ext.toast import com.shuwei.dish.match.utils.ext.toast
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
class CollectFragment : BaseFragment<FragmentCollectBinding>(){ class CollectFragment : BaseFragment<FragmentCollectBinding>() {
companion object { companion object {
private const val TAG = "CollectFragment" private const val TAG = "CollectFragment"
@@ -45,34 +47,47 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
private var selectedFoodId: String? = "" private var selectedFoodId: String? = ""
private var selectedFoodName: String? = "" private var selectedFoodName: String? = ""
private val foodCollectionList = mutableListOf<FoodCollectionBean>().apply { private val vectorList = mutableListOf<FoodCollectionBean>().apply {
repeat(MAX_COUNT) { repeat(MAX_COUNT) {
add(FoodCollectionBean(isShowCamera = true)) add(FoodCollectionBean(isShowCamera = true))
} }
} }
// private val searchFoodList = mutableListOf<FoodInfo>() private val searchList = mutableListOf<CookFoodGoodsEntity>().apply {
// private var settingActivity: SettingActivity? = null add(CookFoodGoodsEntity(goodsId = "200001", goodsName = "土豆丝"))
// private var checkedItem: FoodInfo? = null add(CookFoodGoodsEntity(goodsId = "200002", goodsName = "土豆片"))
// private val searchFoodAdapter by lazy { add(CookFoodGoodsEntity(goodsId = "200003", goodsName = "土豆丁"))
// CollectFoodListAdapter(searchFoodList).apply { add(CookFoodGoodsEntity(goodsId = "200004", goodsName = "胡萝卜丝"))
// setOnItemClickListener { adapter, view, position -> add(CookFoodGoodsEntity(goodsId = "200005", goodsName = "胡萝卜片"))
// searchFoodList.forEachIndexed { index, item -> item.isChecked = index == position } add(CookFoodGoodsEntity(goodsId = "200006", goodsName = "胡萝卜丁"))
// checkedItem = searchFoodList[position] add(CookFoodGoodsEntity(goodsId = "200007", goodsName = "黄瓜丝"))
// notifyDataSetChanged() add(CookFoodGoodsEntity(goodsId = "200008", goodsName = "黄瓜片"))
// selectedFoodId = checkedItem!!.foodId add(CookFoodGoodsEntity(goodsId = "200009", goodsName = "黄瓜丁"))
// selectedFoodName = checkedItem!!.foodName add(CookFoodGoodsEntity(goodsId = "200010", goodsName = "洋葱丝"))
// } add(CookFoodGoodsEntity(goodsId = "200011", goodsName = "洋葱丁"))
// } }
// } private var checkedItem: CookFoodGoodsEntity? = null
private val searchAdapter by lazy {
FoodSearchAdapter(searchList).apply {
setOnItemClickListener { adapter, view, position ->
searchList.forEachIndexed { index, item -> item.isClicked = index == position }
checkedItem = searchList[position]
notifyDataSetChanged()
checkedItem?.let {
selectedFoodId = it.foodId
selectedFoodName = it.goodsName
}
}
}
}
private val debouncer = Debouncer(2000) private val debouncer = Debouncer(2000)
// private lateinit var settingActivity: SettingActivity
private lateinit var currentActivity: SingleFragmentActivity private lateinit var currentActivity: SingleFragmentActivity
private val collectionAdapter: FoodCollectionAdapter by lazy { private val vectorAdapter: VectorCollectionAdapter by lazy {
FoodCollectionAdapter(foodCollectionList).apply { VectorCollectionAdapter(vectorList).apply {
addOnItemChildClickListener(R.id.ivDelete) { _, _, position -> addOnItemChildClickListener(R.id.ivDelete) { _, _, position ->
foodCollectionList[position].let { vectorList[position].let {
it.bitmap = null it.bitmap = null
it.imageVector = null it.imageVector = null
it.imageFile = null it.imageFile = null
@@ -96,23 +111,23 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
//typealias CameraCallback = (Uri) -> Unit //typealias CameraCallback = (Uri) -> Unit
private val cameraCallback: (Uri) -> Unit = { uri -> private val cameraCallback: (Uri) -> Unit = cameraCallback@{ uri ->
try { try {
val index = foodCollectionList.indexOfFirst { it.imageFile == null } val index = vectorList.indexOfFirst { it.imageFile == null }
if (index == -1) { if (index == -1) {
toast("每次只允许保存${MAX_COUNT}条数据") toast("每次只允许保存${MAX_COUNT}条数据")
hideWaitingDialog() hideWaitingDialog()
rerurn@ cameraCallback return@cameraCallback
} }
activity?.runOnUiThread { activity?.runOnUiThread {
foodCollectionList[index].let { vectorList[index].let {
it.imageVector = null it.imageVector = null
it.bitmap = null it.bitmap = null
it.isShowCamera = false it.isShowCamera = false
it.imageFile = null it.imageFile = null
it.imageUri = uri it.imageUri = uri
} }
collectionAdapter.notifyItemChanged(index) vectorAdapter.notifyItemChanged(index)
} }
// hideWaitingDialog() // hideWaitingDialog()
Thread { Thread {
@@ -149,13 +164,13 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
log("${this.javaClass.simpleName}-cameraCallback-裁剪bitmap保存文件路径:${file?.absolutePath}") log("${this.javaClass.simpleName}-cameraCallback-裁剪bitmap保存文件路径:${file?.absolutePath}")
activity?.runOnUiThread { activity?.runOnUiThread {
foodCollectionList[index].let { vectorList[index].let {
it.imageVector = imageVector it.imageVector = imageVector
it.bitmap = null it.bitmap = null
it.isShowCamera = false it.isShowCamera = false
it.imageFile = file it.imageFile = file
} }
collectionAdapter.notifyItemChanged(index) vectorAdapter.notifyItemChanged(index)
} }
if (bitmap.isRecycled.not()) { if (bitmap.isRecycled.not()) {
bitmap.recycle() bitmap.recycle()
@@ -165,12 +180,12 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
private fun takePhoto() { private fun takePhoto() {
val count = foodCollectionList.count { it.bitmap != null } val count = vectorList.count { it.bitmap != null }
if (count >= MAX_COUNT) { if (count >= MAX_COUNT) {
toast("每次只允许保存${MAX_COUNT}条数据") toast("每次只允许保存${MAX_COUNT}条数据")
return return
} }
val index = foodCollectionList.indexOfFirst { it.imageFile == null } val index = vectorList.indexOfFirst { it.imageFile == null }
if (index == -1) { if (index == -1) {
toast("每次只允许保存${MAX_COUNT}条数据") toast("每次只允许保存${MAX_COUNT}条数据")
hideWaitingDialog() hideWaitingDialog()
@@ -212,7 +227,7 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
binding.rvFoodList.let { binding.rvFoodList.let {
it.layoutManager = it.layoutManager =
GridLayoutManager(requireActivity(), 3, GridLayoutManager.VERTICAL, false) GridLayoutManager(requireActivity(), 3, GridLayoutManager.VERTICAL, false)
it.adapter = collectionAdapter it.adapter = vectorAdapter
} }
binding.btnFoodSearch.setOnClickListener { binding.btnFoodSearch.setOnClickListener {
@@ -248,7 +263,7 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
startActivity(Intent(requireActivity(), CollectedFoodActivity::class.java)) startActivity(Intent(requireActivity(), CollectedFoodActivity::class.java))
} }
binding.btnTakePhoto.clickWithDebounce { binding.btnTakePhoto.clickWithDebounce {
val count = foodCollectionList.count { it.bitmap != null } val count = vectorList.count { it.bitmap != null }
if (count >= MAX_COUNT) { if (count >= MAX_COUNT) {
toast("每次只允许保存${MAX_COUNT}条数据") toast("每次只允许保存${MAX_COUNT}条数据")
return@clickWithDebounce return@clickWithDebounce
@@ -256,10 +271,10 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
takePhoto() takePhoto()
} }
binding.btnClearData.setOnClickListener { clearData() } binding.btnClearData.setOnClickListener { clearData() }
// binding.rvSearchFood.let { binding.rvSearchFood.let {
// it.layoutManager = GridLayoutManager(context, 2) it.layoutManager = GridLayoutManager(context, 2)
// it.adapter = searchFoodAdapter it.adapter = searchAdapter
// } }
searchFood() searchFood()
} }
@@ -342,7 +357,7 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
fun clearData() { fun clearData() {
foodCollectionList.forEach { vectorList.forEach {
it.bitmap = null it.bitmap = null
it.imageVector = null it.imageVector = null
it.imageFile = null it.imageFile = null
@@ -351,7 +366,7 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>(){
it.isFinish = false it.isFinish = false
it.uploadSuccess = false it.uploadSuccess = false
} }
collectionAdapter.notifyDataSetChanged() vectorAdapter.notifyDataSetChanged()
clickIndex = -1 clickIndex = -1
binding.editFoodName.setText("") binding.editFoodName.setText("")
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/dish_green" android:state_checked="true" />
<item android:color="#5E7585" android:state_checked="false" />
</selector>
@@ -4,14 +4,14 @@
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<corners android:radius="50dp"/> <corners android:radius="50dp"/>
<solid android:color="@color/white"/> <solid android:color="@color/white"/>
<!-- <stroke android:color="#FFC4CFDA" android:width="2dp"/>-->
</shape> </shape>
</item> </item>
<item android:state_checked="true"> <item android:state_checked="true">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<corners android:radius="50dp"/> <corners android:radius="50dp"/>
<solid android:color="#FFFFF0F0"/> <!-- <solid android:color="#FFFFF0F0"/>-->
<stroke android:color="#FFFF3232" android:width="2dp"/> <solid android:color="#F0FFF0"/>
<stroke android:color="@color/dish_green" android:width="2dp"/>
</shape> </shape>
</item> </item>
</selector> </selector>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="6dp" />
<!-- <solid android:color="#66C4C4C4" />-->
<solid android:color="@color/dish_green" />
<corners android:radius="3dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="10dp" />
<solid android:color="#33000000" />
<corners android:radius="5dp" />
</shape>
@@ -271,7 +271,7 @@
</LinearLayout> </LinearLayout>
<androidx.appcompat.widget.AppCompatButton <TextView
android:id="@+id/btnCook" android:id="@+id/btnCook"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="90dp" android:layout_height="90dp"
@@ -282,6 +282,7 @@
android:textSize="32sp" android:textSize="32sp"
android:textStyle="bold" android:textStyle="bold"
android:background="@drawable/shape_green_bg" android:background="@drawable/shape_green_bg"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true" /> android:clickable="true" />
<!-- android:background="@drawable/ripple_effect_green"--> <!-- android:background="@drawable/ripple_effect_green"-->
@@ -9,31 +9,63 @@
tools:background="@color/white"> tools:background="@color/white">
<!-- 食材照片,权重占满剩余空间 --> <!-- 食材照片,权重占满剩余空间 -->
<ImageView <androidx.cardview.widget.CardView
android:id="@+id/ivFoodPhoto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
app:cardBackgroundColor="@color/white"
app:cardElevation="0dp"
app:cardCornerRadius="8dp">
<ImageView
android:id="@+id/ivFoodPhoto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" android:scaleType="centerCrop"
tools:ignore="ContentDescription" tools:ignore="ContentDescription"
tools:src="@color/bg_color" /> tools:src="@mipmap/ic_launcher" />
</androidx.cardview.widget.CardView>
<!-- 识别到的食材列表,无数据时隐藏 --> <!-- 识别到的食材列表,无数据时隐藏 -->
<FrameLayout
android:id="@+id/flListContainer"
android:layout_width="match_parent"
android:layout_height="260dp"
android:layout_marginTop="12dp">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:maxHeight="200dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" android:overScrollMode="never"
android:visibility="gone" android:paddingEnd="6dp"
android:paddingStart="0dp"
android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="2" app:spanCount="2"
tools:itemCount="4" tools:itemCount="4"
tools:listitem="@layout/list_item_search_goods_info" tools:listitem="@layout/list_item_search_goods_info"
tools:visibility="visible" /> tools:visibility="visible" />
<View
android:id="@+id/vScrollIndicatorTrack"
android:layout_width="4dp"
android:layout_height="match_parent"
android:layout_gravity="end|top"
android:layout_marginEnd="2dp"
android:background="@drawable/scrollbar_track_food_recognize"
android:visibility="gone" />
<View
android:id="@+id/vScrollIndicatorThumb"
android:layout_width="6dp"
android:layout_height="24dp"
android:layout_gravity="end|top"
android:layout_marginEnd="1dp"
android:background="@drawable/scrollbar_thumb_food_recognize"
android:visibility="gone" />
</FrameLayout>
<!-- 选中的食材名称 --> <!-- 选中的食材名称 -->
<TextView <TextView
android:id="@+id/tvSelectedFood" android:id="@+id/tvSelectedFood"
@@ -63,8 +95,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="90dp" android:layout_height="90dp"
android:layout_marginTop="30dp" android:layout_marginTop="30dp"
android:gravity="center"
android:background="@drawable/shape_green_bg" android:background="@drawable/shape_green_bg"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center"
android:text="更换食材" android:text="更换食材"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="32sp" android:textSize="32sp"
@@ -77,8 +110,9 @@
android:layout_height="90dp" android:layout_height="90dp"
android:layout_marginTop="30dp" android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" android:layout_marginBottom="30dp"
android:gravity="center"
android:background="@drawable/shape_white_12_corners" android:background="@drawable/shape_white_12_corners"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center"
android:text="取消" android:text="取消"
android:textColor="@color/black333" android:textColor="@color/black333"
android:textSize="32sp" android:textSize="32sp"
@@ -60,21 +60,36 @@
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="30dp"
android:gravity="center_vertical"> android:gravity="center_vertical">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start" android:layout_gravity="start"
android:layout_marginVertical="30dp"
android:layout_marginStart="20dp"
android:padding="10dp" android:padding="10dp"
android:text="@string/dish_composition" android:text="@string/dish_composition"
android:textColor="@color/black666" android:textColor="@color/black666"
android:textSize="28sp" /> android:textSize="28sp" />
<TextView
android:id="@+id/tvShowWeight"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_gravity="end|center_vertical"
android:paddingHorizontal="30dp"
android:gravity="center_vertical"
android:maxLines="1"
tools:text="称重:0g"
android:textColor="@color/black666"
android:textSize="28sp" />
<FrameLayout
android:id="@+id/flCameraContainer"
android:layout_width="1dp"
android:layout_height="1dp" />
</FrameLayout> </FrameLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
@@ -89,17 +104,13 @@
</LinearLayout> </LinearLayout>
<FrameLayout <TextView
android:id="@+id/flCameraContainer"
android:layout_width="1dp"
android:layout_height="1dp" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnCook" android:id="@+id/btnCook"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="90dp" android:layout_height="90dp"
android:layout_margin="30dp" android:layout_margin="30dp"
android:background="@drawable/shape_green_bg" android:background="@drawable/shape_green_bg"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center" android:gravity="center"
android:text="@string/goCooking" android:text="@string/goCooking"
android:textColor="@color/white" android:textColor="@color/white"
+1 -1
View File
@@ -94,7 +94,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="食材采" android:text="食材采"
android:textSize="32sp" android:textSize="32sp"
android:textStyle="bold" android:textStyle="bold"
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
@@ -112,7 +112,7 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatButton <TextView
android:id="@+id/btnCook" android:id="@+id/btnCook"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="90dp" android:layout_height="90dp"
@@ -121,6 +121,7 @@
android:layout_marginBottom="30dp" android:layout_marginBottom="30dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/shape_green_stroke" android:background="@drawable/shape_green_stroke"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center" android:gravity="center"
android:text="制作" android:text="制作"
android:textColor="@color/dish_green" android:textColor="@color/dish_green"
@@ -128,7 +129,7 @@
android:textStyle="bold" /> android:textStyle="bold" />
<!-- android:background="@drawable/ripple_effect_light"--> <!-- android:background="@drawable/ripple_effect_light"-->
<androidx.appcompat.widget.AppCompatButton <TextView
android:id="@+id/btnSubmit" android:id="@+id/btnSubmit"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="90dp" android:layout_height="90dp"
@@ -138,6 +139,7 @@
android:layout_marginBottom="30dp" android:layout_marginBottom="30dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/shape_green_bg" android:background="@drawable/shape_green_bg"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center" android:gravity="center"
android:text="提交" android:text="提交"
android:textColor="@color/white" android:textColor="@color/white"
+9 -5
View File
@@ -139,7 +139,7 @@
app:spanCount="3" app:spanCount="3"
tools:itemCount="12" tools:itemCount="12"
android:overScrollMode="never" android:overScrollMode="never"
tools:listitem="@layout/list_item_food_collection" /> tools:listitem="@layout/list_item_vector_collection" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
@@ -157,9 +157,9 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/setting_border_gray3" android:background="@drawable/setting_border_gray3"
android:gravity="center_vertical" android:gravity="center_vertical"
android:hint="输入菜品名称" android:hint="输入食材名称"
android:inputType="text"
android:imeOptions="actionSearch" android:imeOptions="actionSearch"
android:inputType="text"
android:maxLines="1" android:maxLines="1"
android:paddingStart="47dp" android:paddingStart="47dp"
android:paddingEnd="80dp" android:paddingEnd="80dp"
@@ -191,7 +191,7 @@
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/list_item_search_food"/> tools:listitem="@layout/list_item_search_food"/>
<androidx.appcompat.widget.AppCompatButton <TextView
android:id="@+id/btnSave" android:id="@+id/btnSave"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="100dp"
@@ -199,8 +199,12 @@
android:layout_marginBottom="32dp" android:layout_marginBottom="32dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:text="保存" android:text="保存"
android:gravity="center"
android:textStyle="bold"
android:foreground="?android:attr/selectableItemBackground"
android:background="@drawable/bg_btn_save" android:background="@drawable/bg_btn_save"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="40sp" /> android:textSize="40sp"
android:clipToOutline="true"/>
</LinearLayout> </LinearLayout>
@@ -4,7 +4,7 @@
android:id="@+id/tvFoodName" android:id="@+id/tvFoodName"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="100dp"
tools:background="@drawable/bg_text_main" android:background="@drawable/bg_item_search"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
@@ -12,7 +12,7 @@
android:layout_marginVertical="14dp" android:layout_marginVertical="14dp"
android:paddingHorizontal="15dp" android:paddingHorizontal="15dp"
android:textAlignment="center" android:textAlignment="center"
tools:textColor="@color/black" android:textColor="@color/color_item_search"
android:textSize="30sp" android:textSize="30sp"
android:textStyle="bold" android:textStyle="bold"
tools:text="肉沫干拌面" /> tools:text="土豆丝" />