Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1569faa85 | ||
|
|
a958262dff | ||
|
|
fb691c508d | ||
|
|
8113c1d830 | ||
|
|
db839fd596 | ||
|
|
c2fd14cb6f | ||
|
|
95895e6390 |
@@ -12,11 +12,22 @@ import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
|||||||
import com.shuwei.dish.match.utils.ext.gone
|
import com.shuwei.dish.match.utils.ext.gone
|
||||||
import com.shuwei.dish.match.utils.ext.roundedOneDecimalPlace
|
import com.shuwei.dish.match.utils.ext.roundedOneDecimalPlace
|
||||||
import com.shuwei.dish.match.utils.ext.visible
|
import com.shuwei.dish.match.utils.ext.visible
|
||||||
import java.text.DecimalFormat
|
import com.shuwei.dish.match.view.swipereveallayout.ViewBinderHelper
|
||||||
|
|
||||||
class DishPartAdapter(list: MutableList<CookFoodGoodsEntity>) :
|
class DishPartAdapter(list: MutableList<CookFoodGoodsEntity>) :
|
||||||
BaseQuickAdapter<CookFoodGoodsEntity, DishPartAdapter.VH>(list) {
|
BaseQuickAdapter<CookFoodGoodsEntity, DishPartAdapter.VH>(list) {
|
||||||
|
|
||||||
|
var onDeleteClick: ((position: Int) -> Unit)? = null
|
||||||
|
var onItemClick: ((position: Int) -> Unit)? = null
|
||||||
|
|
||||||
|
private val viewBinderHelper = ViewBinderHelper().apply {
|
||||||
|
setOpenOnlyOne(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun closeAll() {
|
||||||
|
viewBinderHelper.closeAll()
|
||||||
|
}
|
||||||
|
|
||||||
inner class VH(var binding: ListItemDishCookBinding) : QuickViewHolder(binding.root)
|
inner class VH(var binding: ListItemDishCookBinding) : QuickViewHolder(binding.root)
|
||||||
|
|
||||||
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
|
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
|
||||||
@@ -27,33 +38,47 @@ class DishPartAdapter(list: MutableList<CookFoodGoodsEntity>) :
|
|||||||
|
|
||||||
override fun onBindViewHolder(holder: VH, position: Int, item: CookFoodGoodsEntity?) {
|
override fun onBindViewHolder(holder: VH, position: Int, item: CookFoodGoodsEntity?) {
|
||||||
holder.binding.run {
|
holder.binding.run {
|
||||||
tvDishName.text = item!!.goodsName
|
val data = item ?: return
|
||||||
tvDishType.text = if (item.materialType == 1) "主辅材:主材" else if (item.materialType == 2) "主辅材:辅材" else ""
|
val itemId = data.goodsId ?: "${position}_${data.goodsName ?: ""}"
|
||||||
//"${DecimalFormat("#").format(item.useWeight)}克"
|
viewBinderHelper.bind(swipeRevealLayout, itemId)
|
||||||
|
// 暂时禁用侧滑能力,后续需要放开时改回 unlockSwipe + layoutDelete.visible()
|
||||||
|
viewBinderHelper.lockSwipe(itemId)
|
||||||
|
swipeRevealLayout.close(false)
|
||||||
|
layoutDelete.gone()
|
||||||
|
|
||||||
|
layoutDelete.setOnClickListener {
|
||||||
|
onDeleteClick?.invoke(holder.bindingAdapterPosition)
|
||||||
|
}
|
||||||
|
clBlock.setOnClickListener {
|
||||||
|
onItemClick?.invoke(holder.bindingAdapterPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
tvDishName.text = data.goodsName
|
||||||
|
tvDishType.text = if (data.materialType == 1) "主辅材:主材" else if (data.materialType == 2) "主辅材:辅材" else ""
|
||||||
tvDishWeight.text =
|
tvDishWeight.text =
|
||||||
if (item.useWeight == null || item.useWeight == 0.toDouble()) "" else "${item.useWeight!!.roundedOneDecimalPlace()}克"
|
if (data.useWeight == null || data.useWeight == 0.toDouble()) "" else "${data.useWeight!!.roundedOneDecimalPlace()}克"
|
||||||
tvDishWeight.setTextColor(
|
tvDishWeight.setTextColor(
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
context,
|
context,
|
||||||
if (item.isSamplingPage) R.color.black999 else R.color.dish_green
|
if (data.isSamplingPage) R.color.black999 else R.color.dish_green
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
ivOperateIcon.run {
|
ivOperateIcon.run {
|
||||||
if (item.isSamplingPage) gone() else visible()
|
if (data.isSamplingPage) gone() else visible()
|
||||||
}
|
}
|
||||||
ivClearIcon.visible()
|
ivClearIcon.visible()
|
||||||
ivClearIcon.setImageResource(
|
ivClearIcon.setImageResource(
|
||||||
if (item.isOriginalData) R.drawable.ic_dish_clear
|
if (data.isOriginalData) R.drawable.ic_dish_clear
|
||||||
else R.drawable.ic_delete
|
else R.drawable.ic_delete
|
||||||
)
|
)
|
||||||
ivOperateIcon.setImageResource(
|
ivOperateIcon.setImageResource(
|
||||||
if (item.isSetFinished) R.drawable.ic_dish_selected
|
if (data.isSetFinished) R.drawable.ic_dish_selected
|
||||||
else R.drawable.ic_dish_unselected
|
else R.drawable.ic_dish_unselected
|
||||||
)
|
)
|
||||||
root.run {
|
clBlock.run {
|
||||||
setBackgroundResource(
|
setBackgroundResource(
|
||||||
if (item.isItemClicked) R.drawable.shape_item_cook_dish
|
if (data.isItemClicked) R.drawable.shape_item_cook_dish
|
||||||
else R.drawable.shape_white_fb_15_corners
|
else R.drawable.shape_white_fb_15_corners
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
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.entity.FoodRecord
|
|
||||||
import com.shuwei.dish.match.databinding.ListItemDishBinding
|
|
||||||
import com.shuwei.dish.match.utils.ext.gone
|
|
||||||
import com.shuwei.dish.match.utils.ext.visible
|
|
||||||
import java.text.DecimalFormat
|
|
||||||
|
|
||||||
class DishShowAdapter(list: MutableList<FoodRecord>) :
|
|
||||||
BaseQuickAdapter<FoodRecord, DishShowAdapter.VH>(list) {
|
|
||||||
|
|
||||||
inner class VH(var binding: ListItemDishBinding) : QuickViewHolder(binding.root)
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
|
|
||||||
val inflater = LayoutInflater.from(context)
|
|
||||||
val binding = ListItemDishBinding.inflate(inflater, parent, false)
|
|
||||||
return VH(binding)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: VH, position: Int, item: FoodRecord?) {
|
|
||||||
holder.binding.run {
|
|
||||||
val isCooking = item!!.isCooking
|
|
||||||
val totalWeight = item.totalWeight ?: 0.toDouble()
|
|
||||||
tvDishName.text = item!!.foodName
|
|
||||||
if (isCooking) {
|
|
||||||
tvDishName.setTextColor(
|
|
||||||
ContextCompat.getColor(holder.itemView.context, R.color.black)
|
|
||||||
)
|
|
||||||
clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners)
|
|
||||||
tvDishCount.visible()
|
|
||||||
tvDishCount.text = "制作统计:-kg"
|
|
||||||
tvShowState.text = "烹饪中"
|
|
||||||
} else if (totalWeight > 0.toDouble()) {
|
|
||||||
tvDishName.setTextColor(
|
|
||||||
ContextCompat.getColor(holder.itemView.context, R.color.dish_green)
|
|
||||||
)
|
|
||||||
clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners)
|
|
||||||
tvDishCount.visible()
|
|
||||||
tvDishCount.text =
|
|
||||||
"累计统计:${df.format(totalWeight / 1000.0F)}kg(${item.count}次)"
|
|
||||||
tvShowState.text = "${df.format((item.foodWeight ?: 0.toDouble()) / 1000.0F)}kg"
|
|
||||||
} else {
|
|
||||||
tvDishName.setTextColor(
|
|
||||||
ContextCompat.getColor(holder.itemView.context, R.color.black999)
|
|
||||||
)
|
|
||||||
clBlock.setBackgroundResource(R.drawable.shape_white_dash_15_corners)
|
|
||||||
tvDishCount.gone()
|
|
||||||
tvShowState.text = "-"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val df = DecimalFormat("0.000")
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
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.ListItemFoodListBinding
|
||||||
|
import com.shuwei.dish.match.entity.FoodRecord
|
||||||
|
import com.shuwei.dish.match.view.swipereveallayout.ViewBinderHelper
|
||||||
|
import com.shuwei.dish.match.utils.ext.gone
|
||||||
|
import com.shuwei.dish.match.utils.ext.visible
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品列表通用 Adapter,合并了 DishShowAdapter 与 SamplingAdapter 的功能。
|
||||||
|
*
|
||||||
|
* @param list 数据列表
|
||||||
|
* @param mode 显示模式:
|
||||||
|
* - [DisplayMode.COOKING_MODE]:制作模式,支持空状态(虚线边框、隐藏统计行、灰色文字)
|
||||||
|
* - [DisplayMode.SAMPLING_MODE]:采样模式,始终显示统计行,重量为零时显示 `-`
|
||||||
|
*/
|
||||||
|
class FoodListAdapter(
|
||||||
|
list: MutableList<FoodRecord>,
|
||||||
|
private val mode: DisplayMode = DisplayMode.COOKING_MODE
|
||||||
|
) : BaseQuickAdapter<FoodRecord, FoodListAdapter.VH>(list) {
|
||||||
|
|
||||||
|
/** 显示模式枚举 */
|
||||||
|
enum class DisplayMode {
|
||||||
|
/** 制作模式(原 DishShowAdapter 逻辑) */
|
||||||
|
COOKING_MODE,
|
||||||
|
/** 采样模式(原 SamplingAdapter 逻辑) */
|
||||||
|
SAMPLING_MODE
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮点击回调,由外部(Activity/Fragment)设置 */
|
||||||
|
var onDeleteClick: ((position: Int) -> Unit)? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* item 主体点击回调,绑定在 mainView(clBlock)上,绕过 SwipeRevealLayout 的触摸拦截。
|
||||||
|
* 外部使用此回调替代 setOnDebouncedItemClick。
|
||||||
|
*/
|
||||||
|
var onItemClick: ((position: Int) -> Unit)? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewBinderHelper 负责:
|
||||||
|
* - 同一时间只允许一个 item 展开(setOpenOnlyOne)
|
||||||
|
* - RecyclerView 复用时恢复开合状态
|
||||||
|
*/
|
||||||
|
private val viewBinderHelper = ViewBinderHelper().apply {
|
||||||
|
setOpenOnlyOne(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 关闭所有已展开的侧滑 item,供外部在点击空白区域时调用 */
|
||||||
|
fun closeAll() {
|
||||||
|
viewBinderHelper.closeAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class VH(var binding: ListItemFoodListBinding) : QuickViewHolder(binding.root)
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
|
||||||
|
val binding = ListItemFoodListBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||||
|
return VH(binding)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* - 烹饪中:黑色文字、实线背景、显示"烹饪中"
|
||||||
|
* - 有累计重量:绿色文字、实线背景、显示累计统计
|
||||||
|
* - 空状态:灰色文字、虚线背景、隐藏统计行
|
||||||
|
*/
|
||||||
|
override fun onBindViewHolder(holder: VH, position: Int, item: FoodRecord?) {
|
||||||
|
holder.binding.run {
|
||||||
|
val isCooking = item!!.isCooking
|
||||||
|
val totalWeight = item.totalWeight ?: 0.0
|
||||||
|
val foodWeight = item.foodWeight ?: 0.0
|
||||||
|
|
||||||
|
// 用 foodId 作为唯一 key 恢复开合状态;不可滑动时锁定
|
||||||
|
val itemId = item.foodId ?: position.toString()
|
||||||
|
viewBinderHelper.bind(swipeRevealLayout, itemId)
|
||||||
|
if (isCooking) {
|
||||||
|
viewBinderHelper.unlockSwipe(itemId)
|
||||||
|
layoutDelete.visible()
|
||||||
|
} else {
|
||||||
|
viewBinderHelper.lockSwipe(itemId)
|
||||||
|
// 非烹饪中不允许侧滑,关闭可能的复用残留状态并隐藏删除按钮
|
||||||
|
swipeRevealLayout.close(false)
|
||||||
|
layoutDelete.gone()
|
||||||
|
}
|
||||||
|
// 绑定删除按钮回调
|
||||||
|
layoutDelete.setOnClickListener { onDeleteClick?.invoke(holder.bindingAdapterPosition) }
|
||||||
|
// 点击主内容区域:
|
||||||
|
// 1) 非烹饪中:先收起所有侧滑,再继续触发点击
|
||||||
|
// 2) 烹饪中:当前 item 若已展开则只收起,不触发点击
|
||||||
|
clBlock.setOnClickListener {
|
||||||
|
if (!isCooking) {
|
||||||
|
viewBinderHelper.closeAll()
|
||||||
|
onItemClick?.invoke(holder.bindingAdapterPosition)
|
||||||
|
} else if (!swipeRevealLayout.isClosed) {
|
||||||
|
viewBinderHelper.closeAll()
|
||||||
|
} else {
|
||||||
|
onItemClick?.invoke(holder.bindingAdapterPosition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tvDishName.text = item.foodName
|
||||||
|
//烹饪中
|
||||||
|
if (isCooking) {
|
||||||
|
tvDishName.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.black))
|
||||||
|
clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners)
|
||||||
|
tvDishCount.visible()
|
||||||
|
tvDishCount.text = "制作统计:-kg"
|
||||||
|
tvShowState.text = "烹饪中"
|
||||||
|
return@run
|
||||||
|
}
|
||||||
|
//非烹饪中,制作模式
|
||||||
|
if (mode == DisplayMode.COOKING_MODE) {
|
||||||
|
if (totalWeight > 0.0) {
|
||||||
|
tvDishName.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.dish_green))
|
||||||
|
clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners)
|
||||||
|
tvDishCount.visible()
|
||||||
|
tvDishCount.text = "累计统计:${df.format(totalWeight / 1000.0F)}kg(${item.count}次)"
|
||||||
|
tvShowState.text = "${df.format(foodWeight / 1000.0F)}kg"
|
||||||
|
} else {
|
||||||
|
tvDishName.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.black999))
|
||||||
|
clBlock.setBackgroundResource(R.drawable.shape_white_dash_15_corners)
|
||||||
|
tvDishCount.gone()
|
||||||
|
tvShowState.text = "-"
|
||||||
|
}
|
||||||
|
return@run
|
||||||
|
}
|
||||||
|
//非烹饪中,采样模式
|
||||||
|
val realTotalWeight = if (totalWeight > 0.0) totalWeight else foodWeight
|
||||||
|
val showTotalWeight = if (realTotalWeight == 0.0) "-" else df.format(realTotalWeight / 1000.0F)
|
||||||
|
tvDishCount.text = "累计统计:${showTotalWeight}kg(${item.count ?: "-"}次)"
|
||||||
|
val showFoodWeight = if (foodWeight == 0.0) "-" else df.format(foodWeight / 1000.0F)
|
||||||
|
tvShowState.text = "${showFoodWeight}kg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val df = DecimalFormat("0.000")
|
||||||
|
}
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
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.entity.FoodRecord
|
|
||||||
import com.shuwei.dish.match.databinding.ListItemDishBinding
|
|
||||||
import com.shuwei.dish.match.utils.ext.visible
|
|
||||||
import java.text.DecimalFormat
|
|
||||||
|
|
||||||
class SamplingAdapter(list: MutableList<FoodRecord>) :
|
|
||||||
BaseQuickAdapter<FoodRecord, SamplingAdapter.VH>(list) {
|
|
||||||
|
|
||||||
inner class VH(var binding: ListItemDishBinding) : QuickViewHolder(binding.root)
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
|
|
||||||
val inflater = LayoutInflater.from(context)
|
|
||||||
val binding = ListItemDishBinding.inflate(inflater, parent, false)
|
|
||||||
return VH(binding)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: VH, position: Int, item: FoodRecord?) {
|
|
||||||
holder.binding.run {
|
|
||||||
val isCooking = item!!.isCooking
|
|
||||||
clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners)
|
|
||||||
val totalWeight = item.totalWeight ?: 0.toDouble()
|
|
||||||
tvDishName.run {
|
|
||||||
text = (item.foodName?:"").ifBlank { "--" }
|
|
||||||
setTextColor(
|
|
||||||
ContextCompat.getColor(
|
|
||||||
holder.itemView.context,
|
|
||||||
if (isCooking) R.color.black else R.color.dish_green
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
tvDishCount.visible()
|
|
||||||
if (isCooking) {
|
|
||||||
tvDishCount.text = "制作统计:-kg"
|
|
||||||
tvShowState.text = "烹饪中"
|
|
||||||
} else {
|
|
||||||
val realTotalWeight = if (totalWeight > 0.toDouble()) totalWeight else (item.foodWeight
|
|
||||||
?: 0.toDouble())
|
|
||||||
val showTotalWeight =
|
|
||||||
if (realTotalWeight == 0.toDouble()) "-" else df.format(realTotalWeight / 1000.0F)
|
|
||||||
tvDishCount.text = "累计统计:${showTotalWeight}kg(${item.count ?: "-"}次)"
|
|
||||||
val foodWeight = item.foodWeight ?: 0.toDouble()
|
|
||||||
val showFoodWeight = if (foodWeight == 0.toDouble()) "-" else df.format(foodWeight / 1000.0F)
|
|
||||||
tvShowState.text = "${showFoodWeight}kg"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val df = DecimalFormat("0.000")
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ 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.ListItemVectorCollectionBinding
|
import com.shuwei.dish.match.databinding.ListItemVectorCollectionBinding
|
||||||
import com.shuwei.dish.match.objbox.FoodCollectionBean
|
import com.shuwei.dish.match.entity.FoodCollectionBean
|
||||||
import com.shuwei.dish.match.utils.ext.load
|
import com.shuwei.dish.match.utils.ext.load
|
||||||
|
|
||||||
class VectorCollectionAdapter (var list: MutableList<FoodCollectionBean>) :
|
class VectorCollectionAdapter (var list: MutableList<FoodCollectionBean>) :
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import android.view.View
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.activity.enableEdgeToEdge
|
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -35,9 +33,14 @@ import java.time.format.DateTimeFormatter
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.getValue
|
import kotlin.getValue
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
open class BaseActivity : AppCompatActivity() {
|
open class BaseActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/** 日期时间格式化器,复用避免每秒重复创建 */
|
||||||
|
private val DATE_FORMATTER =
|
||||||
|
DateTimeFormatter.ofPattern("yyyy年MM月dd日 EEEE***HH:mm:ss", Locale.CHINA)
|
||||||
|
}
|
||||||
|
|
||||||
private lateinit var binding: ActivityBaseBinding
|
private lateinit var binding: ActivityBaseBinding
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -56,13 +59,6 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
statusBarDarkFont(enable = false)
|
statusBarDarkFont(enable = false)
|
||||||
|
|
||||||
// window.setDecorFitsSystemWindows(false) // 启用 Edge-to-Edge
|
|
||||||
// window.insetsController?.apply {
|
|
||||||
// hide(WindowInsets.Type.statusBars()) // 隐藏状态栏
|
|
||||||
// systemBarsBehavior =
|
|
||||||
// WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示
|
|
||||||
// }
|
|
||||||
// 主设备垂直 padding 30dp,子设备 15dp
|
// 主设备垂直 padding 30dp,子设备 15dp
|
||||||
val verticalPadding = if (GlobalData.deviceRole == DeviceRole.MASTER) 30.dp else 10.dp
|
val verticalPadding = if (GlobalData.deviceRole == DeviceRole.MASTER) 30.dp else 10.dp
|
||||||
binding.tvLeftTime.setPadding(0, verticalPadding, 0, verticalPadding)
|
binding.tvLeftTime.setPadding(0, verticalPadding, 0, verticalPadding)
|
||||||
@@ -71,27 +67,18 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
binding.ivBack.setOnClickListener { finish() }
|
binding.ivBack.setOnClickListener { finish() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private var bgState = true
|
|
||||||
fun useBackground(enable: Boolean) {
|
|
||||||
bgState = enable
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
handler.removeCallbacksAndMessages(null)
|
||||||
dismissLoading()
|
dismissLoading()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
ActivityManager.removeActivity(this)
|
ActivityManager.removeActivity(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hideStatusBar() {
|
fun hideStatusBar() {
|
||||||
// enableEdgeToEdge()
|
|
||||||
//// val uiOptions = (View.SYSTEM_UI_FLAG_FULLSCREEN // 隐藏状态栏
|
|
||||||
//// or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) // 隐藏导航栏(可选)
|
|
||||||
// window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
|
|
||||||
hideSystemBars()
|
hideSystemBars()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun statusBarDarkFont(enable: Boolean) {
|
fun statusBarDarkFont(enable: Boolean) {
|
||||||
//window.decorView.systemUiVisibility = if (enable) View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR else 0
|
|
||||||
val color = ContextCompat.getColor(
|
val color = ContextCompat.getColor(
|
||||||
this, if (enable) R.color.black else R.color.white
|
this, if (enable) R.color.black else R.color.white
|
||||||
)
|
)
|
||||||
@@ -105,6 +92,7 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
titleAction: ((TextView) -> Unit)? = null,
|
titleAction: ((TextView) -> Unit)? = null,
|
||||||
rightIconActon: ((ImageView) -> Unit)? = null
|
rightIconActon: ((ImageView) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
|
binding.llTitleBar.visible()
|
||||||
titleBarAction?.invoke(binding.llTitleBar)
|
titleBarAction?.invoke(binding.llTitleBar)
|
||||||
backAction?.invoke(binding.ivBack)
|
backAction?.invoke(binding.ivBack)
|
||||||
titleAction?.invoke(binding.tvTitle)
|
titleAction?.invoke(binding.tvTitle)
|
||||||
@@ -117,7 +105,7 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun setHeaderBackground(isHomePage: Boolean = false) {
|
fun setHeaderBackground(isHomePage: Boolean = false) {
|
||||||
binding.ivHeaderBg.setImageResource(
|
binding.ivHeaderBg.setImageResource(
|
||||||
if (isHomePage) R.drawable.bg_home_page else R.drawable.bg_other_page
|
if (isHomePage) R.drawable.bg_home_page else R.drawable.bg_other_page
|
||||||
)
|
)
|
||||||
@@ -135,14 +123,13 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDateTime() {
|
private fun updateDateTime() {
|
||||||
val formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 EEEE***HH:mm:ss", Locale.CHINA)
|
val dateTime = DATE_FORMATTER.format(LocalDateTime.now(ZoneId.of("Asia/Shanghai")))
|
||||||
val dateTime = formatter.format(LocalDateTime.now(ZoneId.of("Asia/Shanghai")))
|
|
||||||
val arr = dateTime.split("***")
|
val arr = dateTime.split("***")
|
||||||
binding.tvRightTime.text = arr[0]
|
binding.tvRightTime.text = arr[0]
|
||||||
binding.tvLeftTime.text = arr[1]
|
binding.tvLeftTime.text = arr[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
private val updateTask = object : Runnable {
|
private val updateTask = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
updateDateTime()
|
updateDateTime()
|
||||||
@@ -182,27 +169,37 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在主线程延迟执行任务,供子类使用
|
||||||
|
* @param delayMs 延迟毫秒数
|
||||||
|
* @param block 待执行的任务
|
||||||
|
*/
|
||||||
|
protected fun postDelayed(delayMs: Long, block: () -> Unit) {
|
||||||
|
handler.postDelayed(block, delayMs)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
val netViewModel: NetViewModel by viewModels()
|
val netViewModel: NetViewModel by viewModels()
|
||||||
val appViewModel: DbViewModel by viewModels()
|
val appViewModel: DbViewModel by viewModels()
|
||||||
|
|
||||||
private var permissionCallback: ((isGranted: Boolean) -> Unit)? = null
|
private var singlePermissionCallback: ((isGranted: Boolean) -> Unit)? = null
|
||||||
|
private var multiplePermissionsCallback: ((isGranted: Boolean) -> Unit)? = null
|
||||||
private var activityCallback: ((intent: Intent?) -> Unit)? = null
|
private var activityCallback: ((intent: Intent?) -> Unit)? = null
|
||||||
|
|
||||||
fun requestMultiplePermissions(
|
fun requestMultiplePermissions(
|
||||||
permissions: Array<String>,
|
permissions: Array<String>,
|
||||||
callback: (isGranted: Boolean) -> Unit
|
callback: (isGranted: Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
this.permissionCallback = callback
|
this.multiplePermissionsCallback = callback
|
||||||
requestMultiplePermissionsLauncher.launch(permissions)
|
requestMultiplePermissionsLauncher.launch(permissions)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requestPermission(permission: String, callback: (isGranted: Boolean) -> Unit) {
|
fun requestPermission(permission: String, callback: (isGranted: Boolean) -> Unit) {
|
||||||
this.permissionCallback = callback
|
this.singlePermissionCallback = callback
|
||||||
requestPermissionLauncher.launch(permission)
|
requestPermissionLauncher.launch(permission)
|
||||||
}
|
}
|
||||||
|
|
||||||
val requestMultiplePermissionsLauncher = registerForActivityResult(
|
private val requestMultiplePermissionsLauncher = registerForActivityResult(
|
||||||
ActivityResultContracts.RequestMultiplePermissions()
|
ActivityResultContracts.RequestMultiplePermissions()
|
||||||
) { permissions ->
|
) { permissions ->
|
||||||
var isGranted = true
|
var isGranted = true
|
||||||
@@ -211,14 +208,14 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
isGranted = false
|
isGranted = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
permissionCallback?.invoke(isGranted)
|
multiplePermissionsCallback?.invoke(isGranted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 权限请求回调
|
// 权限请求回调
|
||||||
val requestPermissionLauncher = registerForActivityResult(
|
private val requestPermissionLauncher = registerForActivityResult(
|
||||||
ActivityResultContracts.RequestPermission()
|
ActivityResultContracts.RequestPermission()
|
||||||
) { isGranted ->
|
) { isGranted ->
|
||||||
permissionCallback?.invoke(isGranted)
|
singlePermissionCallback?.invoke(isGranted)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startActivity(intent: Intent, callback: (Intent?) -> Unit) {
|
fun startActivity(intent: Intent, callback: (Intent?) -> Unit) {
|
||||||
|
|||||||
@@ -9,29 +9,38 @@ import android.util.Log
|
|||||||
import com.shuwei.dish.match.R
|
import com.shuwei.dish.match.R
|
||||||
import com.shuwei.dish.match.db.DatabaseProvider
|
import com.shuwei.dish.match.db.DatabaseProvider
|
||||||
import com.shuwei.dish.match.objbox.ObjectBox
|
import com.shuwei.dish.match.objbox.ObjectBox
|
||||||
|
import com.shuwei.dish.match.scale.ScaleDeviceConfig
|
||||||
import com.shuwei.dish.match.scale.ScaleServiceManager
|
import com.shuwei.dish.match.scale.ScaleServiceManager
|
||||||
import com.shuwei.dish.match.ui.InitActivity.Companion.TAG
|
|
||||||
import com.shuwei.dish.match.utils.AppUtil
|
import com.shuwei.dish.match.utils.AppUtil
|
||||||
import com.shuwei.dish.match.utils.BootReceiver
|
import com.shuwei.dish.match.utils.BootReceiver
|
||||||
import com.shuwei.dish.match.utils.CrashHandler
|
import com.shuwei.dish.match.utils.CrashHandler
|
||||||
import com.shuwei.dish.match.utils.Weigher2
|
import com.shuwei.dish.match.utils.Weigher2
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BaseApp is the main application class that extends Android's Application class.
|
||||||
|
* It handles initialization of core components, device role determination,
|
||||||
|
* and service management for the weighing system.
|
||||||
|
*/
|
||||||
class BaseApp : Application() {
|
class BaseApp : Application() {
|
||||||
|
|
||||||
|
// Lazy initialization of the database instance
|
||||||
val database by lazy { DatabaseProvider(this).instance }
|
val database by lazy { DatabaseProvider(this).instance }
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
// Set the application instance
|
||||||
instance = this
|
instance = this
|
||||||
|
// Initialize crash handler for error tracking
|
||||||
CrashHandler.init(this)
|
CrashHandler.init(this)
|
||||||
|
// Get and store the unique device ID
|
||||||
val deviceId = AppUtil.getUDID(this)
|
val deviceId = AppUtil.getUDID(this)
|
||||||
Log.d(TAG, "onCreate: deviceId=$deviceId")
|
Log.d(TAG, "onCreate: deviceId=$deviceId")
|
||||||
GlobalData.deviceId = deviceId
|
GlobalData.deviceId = deviceId
|
||||||
|
|
||||||
// 根据设备 ID 判断角色:指定 ID 为主设备,其余为子设备
|
// 根据设备 ID 判断角色:指定 ID 为主设备,其余为子设备
|
||||||
// 主设备是/dev/ttyS7,子设备是/dev/ttyS4
|
// 主设备是/dev/ttyS7,子设备是/dev/ttyS4
|
||||||
if (deviceId == "8fc2ab34-2137-3112-acca-f884ea8736d4") {
|
if (deviceId == ScaleDeviceConfig.DEVICE_ID_2) {
|
||||||
GlobalData.deviceRole = DeviceRole.MASTER
|
GlobalData.deviceRole = DeviceRole.MASTER
|
||||||
Weigher2.setDevicePort("/dev/ttyS7")
|
Weigher2.setDevicePort("/dev/ttyS7")
|
||||||
} else {
|
} else {
|
||||||
@@ -49,8 +58,8 @@ class BaseApp : Application() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private val TAG = "BaseApp"
|
||||||
// const val canteenId = "1678234139391512577"
|
// const val canteenId = "1678234139391512577"
|
||||||
var canteenId = "0"
|
var canteenId = "0"
|
||||||
// var configUrl = ""
|
// var configUrl = ""
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package com.shuwei.dish.match.base
|
|
||||||
|
|
||||||
class BaseReq<T> {
|
|
||||||
var code: Int? = null
|
|
||||||
var success: Boolean? = null
|
|
||||||
var data: T? = null
|
|
||||||
var message: String? = null
|
|
||||||
var result: T? = null
|
|
||||||
var msg: String? = null
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.shuwei.dish.match.entity
|
package com.shuwei.dish.match.entity
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.net.Uri
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
data class HomeModeBean(
|
data class HomeModeBean(
|
||||||
|
|
||||||
var modeName: String = "",
|
var modeName: String = "",
|
||||||
@@ -38,6 +42,44 @@ data class ResetReasoningRecord(
|
|||||||
val list: MutableList<SeasoningEntity>
|
val list: MutableList<SeasoningEntity>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class FoodCollectionBean(
|
||||||
|
var imageUri: Uri? = null,
|
||||||
|
var bitmap: Bitmap? = null,
|
||||||
|
var imageFile: File? = null,
|
||||||
|
var imageVector: FloatArray? = null,
|
||||||
|
var isShowCamera: Boolean = false,
|
||||||
|
var isFinish:Boolean = false,
|
||||||
|
var uploadSuccess:Boolean = false
|
||||||
|
) {
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as FoodCollectionBean
|
||||||
|
|
||||||
|
if (isShowCamera != other.isShowCamera) return false
|
||||||
|
if (isFinish != other.isFinish) return false
|
||||||
|
if (uploadSuccess != other.uploadSuccess) return false
|
||||||
|
if (imageUri != other.imageUri) return false
|
||||||
|
if (bitmap != other.bitmap) return false
|
||||||
|
if (imageFile != other.imageFile) return false
|
||||||
|
if (!imageVector.contentEquals(other.imageVector)) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = isShowCamera.hashCode()
|
||||||
|
result = 31 * result + isFinish.hashCode()
|
||||||
|
result = 31 * result + uploadSuccess.hashCode()
|
||||||
|
result = 31 * result + (imageUri?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (bitmap?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (imageFile?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (imageVector?.contentHashCode() ?: 0)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//data class DishDetailEntity(
|
//data class DishDetailEntity(
|
||||||
// var foodId: String? = null,
|
// var foodId: String? = null,
|
||||||
// var foodWeight: Double? = null,
|
// var foodWeight: Double? = null,
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.shuwei.dish.match.entity
|
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
|
||||||
import androidx.room.Entity
|
|
||||||
import androidx.room.PrimaryKey
|
|
||||||
import com.shuwei.dish.match.db.BaseEntity
|
|
||||||
|
|
||||||
//@Entity(tableName = "dm_dish")
|
|
||||||
//data class DishEntity (
|
|
||||||
// /**
|
|
||||||
// * 菜品id
|
|
||||||
// */
|
|
||||||
// @PrimaryKey var id: Long,
|
|
||||||
// /**
|
|
||||||
// * 菜品名称
|
|
||||||
// */
|
|
||||||
// var name: String? = "",
|
|
||||||
// /**
|
|
||||||
// * 菜品重量
|
|
||||||
// */
|
|
||||||
// var weight: Int? = 0,
|
|
||||||
//
|
|
||||||
// var sort: Int = 0,
|
|
||||||
// @ColumnInfo(name = "create_time") val createTime: Long = System.currentTimeMillis()
|
|
||||||
//): BaseEntity
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
//package com.shuwei.dish.match.entity
|
|
||||||
//
|
|
||||||
//import androidx.room.Ignore
|
|
||||||
//import androidx.room.PrimaryKey
|
|
||||||
//import com.shuwei.dish.match.db.BaseEntity
|
|
||||||
//
|
|
||||||
//data class GoodsInfoEntity(
|
|
||||||
// @PrimaryKey(autoGenerate = true) var id: Long = 0,
|
|
||||||
// var goodsId: Int,
|
|
||||||
// var goodsName: String? = "",
|
|
||||||
// var popularName: String? = "",
|
|
||||||
// var canteenId: String? = "",
|
|
||||||
// var goodsOrRelationCode: String? = "",
|
|
||||||
// var relateionType: Int? = -1,
|
|
||||||
// var relateionType_dictText: String? = "",
|
|
||||||
//
|
|
||||||
// var sort: Int = 0,
|
|
||||||
//
|
|
||||||
// var swMaterBaseMaterial: String? = "",
|
|
||||||
// var preMaterClass: String? = "",
|
|
||||||
// var preUseWeight: Int? = 0,
|
|
||||||
// var preWeight: Int? = 0,
|
|
||||||
// var oil: String? = "",
|
|
||||||
// var sugar: String? = "",
|
|
||||||
// /**
|
|
||||||
// * isDel表示数据是否已删除,1-已删除,为无效数据,0-正常使用,有效数据
|
|
||||||
// */
|
|
||||||
// var isDel: Int = 0,
|
|
||||||
// val createTime: Long = System.currentTimeMillis()
|
|
||||||
//) : BaseEntity {
|
|
||||||
// @Ignore
|
|
||||||
// var pageType: Int = 0
|
|
||||||
//
|
|
||||||
// @Ignore
|
|
||||||
// var isClicked: Boolean = false
|
|
||||||
//
|
|
||||||
// constructor() : this(id = -1, goodsId = -1) // 必需的空构造
|
|
||||||
//}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package com.shuwei.dish.match.objbox
|
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.net.Uri
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
data class FoodClassInfo(
|
|
||||||
var class_names: List<String>,
|
|
||||||
var class_to_idx: Map<String, Int>,
|
|
||||||
var idx_to_class: Map<String, String>
|
|
||||||
)
|
|
||||||
|
|
||||||
data class FoodCollectionBean(
|
|
||||||
var imageUri: Uri? = null,
|
|
||||||
var bitmap: Bitmap? = null,
|
|
||||||
var imageFile: File? = null,
|
|
||||||
var imageVector: FloatArray? = null,
|
|
||||||
var isShowCamera: Boolean = false,
|
|
||||||
var isFinish:Boolean = false,
|
|
||||||
var uploadSuccess:Boolean = false
|
|
||||||
)
|
|
||||||
|
|
||||||
data class ReceiptGoodsInfo(
|
|
||||||
var goodsId: String? = "",
|
|
||||||
var goodsName: String? = "",
|
|
||||||
var procurementUnit: String? = "",
|
|
||||||
var procurementCount: Int? = 0,
|
|
||||||
var procurementPrice: Double? = 0.0,
|
|
||||||
var procurementAmount: Double? = 0.0,
|
|
||||||
var receiptCount: Int? = 0,
|
|
||||||
var goodsWeight: Int? = 0,
|
|
||||||
var goodsState: String? = "",
|
|
||||||
var isSelected: Boolean = false,
|
|
||||||
var isLocalGoods: Boolean = false
|
|
||||||
)
|
|
||||||
|
|
||||||
//data class DropdownInfo(
|
|
||||||
// var id: String,
|
|
||||||
// var name: String
|
|
||||||
//)
|
|
||||||
|
|
||||||
//data class RecognizeResult(
|
|
||||||
// var name: String? = null,
|
|
||||||
// var image: String? = null,
|
|
||||||
// var isSelected: Boolean = false
|
|
||||||
//)
|
|
||||||
|
|
||||||
//data class GoodsSearchInfo(
|
|
||||||
// var id: String? = null,
|
|
||||||
// var name: String? = null,
|
|
||||||
// var isSelected: Boolean = false
|
|
||||||
//)
|
|
||||||
|
|
||||||
data class OperateBean(
|
|
||||||
var obj: Any? = null,
|
|
||||||
var typeList: MutableList<OperateType> = mutableListOf(),
|
|
||||||
var isSelected: Boolean = false,
|
|
||||||
var isLocalGoods: Boolean = false,
|
|
||||||
var isReceiptPage: Boolean = true
|
|
||||||
)
|
|
||||||
|
|
||||||
data class OperateType(
|
|
||||||
var value: String = "",
|
|
||||||
var width: Int = 0,
|
|
||||||
var textColor: String = "#FF999999",
|
|
||||||
var isBoldFont: Boolean = false,
|
|
||||||
var isShowIcon: Boolean = false
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.shuwei.dish.match.objbox
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.net.Uri
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
data class FoodClassInfo(
|
||||||
|
var class_names: List<String>,
|
||||||
|
var class_to_idx: Map<String, Int>,
|
||||||
|
var idx_to_class: Map<String, String>
|
||||||
|
)
|
||||||
|
|
||||||
@@ -1,291 +0,0 @@
|
|||||||
//package com.shuwei.dish.match.ui
|
|
||||||
//
|
|
||||||
//import android.annotation.SuppressLint
|
|
||||||
//import android.content.Intent
|
|
||||||
//import android.os.Bundle
|
|
||||||
//import android.util.Log
|
|
||||||
//import android.view.View
|
|
||||||
//import androidx.activity.addCallback
|
|
||||||
//import androidx.activity.viewModels
|
|
||||||
//import androidx.recyclerview.widget.ItemTouchHelper
|
|
||||||
//import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
//import com.shuwei.dish.match.R
|
|
||||||
//import com.shuwei.dish.match.adapter.DishPartAdapter
|
|
||||||
//import com.shuwei.dish.match.base.BaseActivity
|
|
||||||
//import com.shuwei.dish.match.base.BaseApp
|
|
||||||
//import com.shuwei.dish.match.databinding.ActivityDishSamplingBinding
|
|
||||||
//import com.shuwei.dish.match.dialog.FoodSearchDialog
|
|
||||||
//import com.shuwei.dish.match.dialog.CommonDialog
|
|
||||||
//import com.shuwei.dish.match.entity.CookFoodEntity
|
|
||||||
//import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
|
||||||
//import com.shuwei.dish.match.entity.FoodRecord
|
|
||||||
//import com.shuwei.dish.match.net.NetViewModel
|
|
||||||
//import com.shuwei.dish.match.utils.AddressUtil
|
|
||||||
//import com.shuwei.dish.match.utils.KeyboardUtil
|
|
||||||
//import com.shuwei.dish.match.utils.SwipeCallback
|
|
||||||
//import com.shuwei.dish.match.utils.WeightUtil
|
|
||||||
//import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
|
||||||
//import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
|
||||||
//import com.shuwei.dish.match.utils.ext.gone
|
|
||||||
//import com.shuwei.dish.match.utils.ext.startActivity
|
|
||||||
//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 java.io.Serializable
|
|
||||||
//
|
|
||||||
//class DishSamplingActivity : BaseActivity() {
|
|
||||||
//
|
|
||||||
// private lateinit var binding: ActivityDishSamplingBinding
|
|
||||||
//
|
|
||||||
// var foodName: String? = null
|
|
||||||
//
|
|
||||||
// private var foodId: String? = null
|
|
||||||
//
|
|
||||||
// companion object {
|
|
||||||
// private const val TAG = "DishSamplingActivity"
|
|
||||||
// public const val FOOD_NAME = "foodName"
|
|
||||||
// public const val PAGE_FROM = "pageFrom"
|
|
||||||
// public const val HOME = "home"
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private var pageFrom: String? = null
|
|
||||||
//
|
|
||||||
// override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
// super.onCreate(savedInstanceState)
|
|
||||||
// binding = ActivityDishSamplingBinding.inflate(layoutInflater)
|
|
||||||
// setContentView(binding.root)
|
|
||||||
// pageFrom = intent.getStringExtra(PAGE_FROM)
|
|
||||||
// setTitleBar()
|
|
||||||
// setHeaderBackground()
|
|
||||||
// addViewClickListener()
|
|
||||||
// foodName = intent.getStringExtra(FOOD_NAME)
|
|
||||||
// binding.etInputDish.setText(foodName)
|
|
||||||
//
|
|
||||||
// WeightUtil.addWeightListener(
|
|
||||||
// weightKey = TAG,
|
|
||||||
// getWeight = { address, state, weight ->
|
|
||||||
// //Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
|
||||||
// if (address == AddressUtil.ONE) {
|
|
||||||
// tempDishEntity?.useWeight = weight.toDouble()
|
|
||||||
// binding.tvDishPartWeight.text = "${weight}"
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// addBackKeyListener()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun setTitleBar() {
|
|
||||||
// setTitleBar(titleBarAction = {
|
|
||||||
// it.visible()
|
|
||||||
// }, titleAction = {
|
|
||||||
// it.text = "菜品采集"
|
|
||||||
// }, rightIconActon = {
|
|
||||||
// it.gone()
|
|
||||||
// it.setImageResource(R.drawable.ic_setting)
|
|
||||||
// it.setOnClickListener {
|
|
||||||
// //startActivity<DeviceSettingActivity>()
|
|
||||||
// }
|
|
||||||
// }, backAction = {
|
|
||||||
// it.visible()
|
|
||||||
// it.setOnClickListener {
|
|
||||||
// onBackPressedDispatcher.onBackPressed()
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// fun getCookFoodList() {
|
|
||||||
// appViewModel.getCookFoodList(cookMode = 1)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 监听返回键
|
|
||||||
// */
|
|
||||||
// fun addBackKeyListener() {
|
|
||||||
// onBackPressedDispatcher.addCallback(this) {
|
|
||||||
// if (list.isEmpty().not()) {
|
|
||||||
// //说明有新增的食材
|
|
||||||
// saveDataRemindDialog()
|
|
||||||
// return@addCallback
|
|
||||||
// }
|
|
||||||
// if (pageFrom == HOME) {
|
|
||||||
// startActivity<SamplingListActivity>()
|
|
||||||
// }
|
|
||||||
// onBackPressedDispatcher.onBackPressed()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun saveDataRemindDialog() {
|
|
||||||
// CommonDialog(this)
|
|
||||||
// .setTitle("返回提示")
|
|
||||||
// .setContent("您好,当前页面存在未保存的数据,\n确认返回吗?")
|
|
||||||
// .setNegativeButton("取消")
|
|
||||||
// .setPositiveButton("确认") {
|
|
||||||
// if (pageFrom == HOME) {
|
|
||||||
// startActivity<SamplingListActivity>()
|
|
||||||
// }
|
|
||||||
// finish()
|
|
||||||
// }
|
|
||||||
// .setOnDismissCallback { hideStatusBar() }
|
|
||||||
// .show()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// val list: MutableList<CookFoodGoodsEntity> = mutableListOf()
|
|
||||||
//
|
|
||||||
// private var tempDishEntity: CookFoodGoodsEntity? = null
|
|
||||||
//
|
|
||||||
// private var dishMaterialType = 1
|
|
||||||
//
|
|
||||||
// private val dishAdapter by lazy {
|
|
||||||
// DishPartAdapter(list).apply {
|
|
||||||
// addOnItemChildClickListener(R.id.ivOperateIcon) { _, _, position ->
|
|
||||||
// //删除操作
|
|
||||||
// list.removeAt(position)
|
|
||||||
// notifyItemRemoved(position)
|
|
||||||
// notifyItemRangeChanged(position, list.size - position)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SuppressLint("NotifyDataSetChanged")
|
|
||||||
// private fun addViewClickListener() {
|
|
||||||
// binding.rvDishPartList.run {
|
|
||||||
// layoutManager =
|
|
||||||
// LinearLayoutManager(this@DishSamplingActivity, LinearLayoutManager.VERTICAL, false)
|
|
||||||
// adapter = dishAdapter
|
|
||||||
// val itemTouchHelper = ItemTouchHelper(SwipeCallback(dishAdapter) { position ->
|
|
||||||
// list.removeAt(position)
|
|
||||||
// dishAdapter.notifyItemRemoved(position)
|
|
||||||
// dishAdapter.notifyItemRangeChanged(position, list.size - position)
|
|
||||||
// toast("已删除")
|
|
||||||
// })
|
|
||||||
// itemTouchHelper.attachToRecyclerView(this)
|
|
||||||
// }
|
|
||||||
// binding.etInputDishType.addOnActionSearchListener {
|
|
||||||
// searchDishType()
|
|
||||||
// }
|
|
||||||
// binding.ivDishTypeSearch.setOnClickListener {
|
|
||||||
// searchDishType()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// binding.ivWeightClear.setOnClickListener {
|
|
||||||
// WeightUtil.tareTwo(AddressUtil.ONE)
|
|
||||||
// }
|
|
||||||
// binding.ivWeightAdd.setOnClickListener {
|
|
||||||
// if (tempDishEntity == null) {
|
|
||||||
// toast("请输入食材名称")
|
|
||||||
// return@setOnClickListener
|
|
||||||
// }
|
|
||||||
// if (binding.rgSampling.checkedRadioButtonId == -1) {
|
|
||||||
// toast("请选择主辅材类型")
|
|
||||||
// return@setOnClickListener
|
|
||||||
// }
|
|
||||||
// val realWeight = tempDishEntity!!.useWeight ?: 0.0
|
|
||||||
// if (realWeight <= 0.toDouble()) {
|
|
||||||
// toast("食材用量需要大于0")
|
|
||||||
// return@setOnClickListener
|
|
||||||
// }
|
|
||||||
// if (tempDishEntity?.goodsName != binding.etInputDishType.text.toString().trim()) {
|
|
||||||
// toast("所选择的食材名称与输入框内容不一致")
|
|
||||||
// return@setOnClickListener
|
|
||||||
// }
|
|
||||||
// tempDishEntity!!.apply {
|
|
||||||
// isSamplingPage = true
|
|
||||||
// materialType = dishMaterialType
|
|
||||||
// }
|
|
||||||
// val result = list.firstOrNull { it.goodsId == tempDishEntity!!.goodsId }
|
|
||||||
// if (result != null) {
|
|
||||||
// toast("${result.goodsName}食材已添加,请勿重复操作")
|
|
||||||
// return@setOnClickListener
|
|
||||||
// }
|
|
||||||
// list.add(tempDishEntity!!)
|
|
||||||
// dishAdapter.notifyDataSetChanged()
|
|
||||||
// tempDishEntity = null
|
|
||||||
// binding.etInputDishType.setText("")
|
|
||||||
// binding.rgSampling.clearCheck()
|
|
||||||
// }
|
|
||||||
// binding.rgSampling.setOnCheckedChangeListener { group, checkedId ->
|
|
||||||
// dishMaterialType = if (checkedId == R.id.rbDishTypeFirst) 1 else 2
|
|
||||||
// }
|
|
||||||
// binding.ivDishSearch.setOnClickListener { v ->
|
|
||||||
// jumpSearch(v)
|
|
||||||
// }
|
|
||||||
// binding.btnCook.clickWithDebounce {
|
|
||||||
// val showFoodName = binding.etInputDish.text.toString().trim()
|
|
||||||
// if (showFoodName.isBlank()) {
|
|
||||||
// toast("菜品名称为空")
|
|
||||||
// return@clickWithDebounce
|
|
||||||
// }
|
|
||||||
// if (list.isEmpty()) {
|
|
||||||
// toast("菜品构成信息未设置")
|
|
||||||
// return@clickWithDebounce
|
|
||||||
// }
|
|
||||||
// val food = FoodRecord()
|
|
||||||
// binding.etInputDish.let {
|
|
||||||
// if (it.tag != null && it.tag.toString() == it.text.toString()) {
|
|
||||||
// food.foodId = foodId
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// food.foodName = showFoodName
|
|
||||||
// food.cookMode = 1
|
|
||||||
// Log.d(TAG, "goToSubmit: goodsList:${list.toJsonString()}")
|
|
||||||
//// startActivity<SubmitDishActivity> {
|
|
||||||
// startActivity<SubmitFoodActivity> {
|
|
||||||
// putExtra(SubmitFoodActivity.GOODS_LIST, list as java.io.Serializable)
|
|
||||||
// putExtra(SubmitFoodActivity.FOOD_ITEM, food as Serializable)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// binding.etInputDish.let { v ->
|
|
||||||
// v.addOnActionSearchListener {
|
|
||||||
// jumpSearch(v)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun jumpSearch(v: View) {
|
|
||||||
// val intent = Intent(this, FoodSearchActivity::class.java).apply {
|
|
||||||
// putExtra(FoodSearchActivity.FOOD_NAME, binding.etInputDish.text.toString().trim())
|
|
||||||
// }
|
|
||||||
// startActivity(intent) {
|
|
||||||
// foodId = it?.getStringExtra(FoodSearchActivity.FOOD_ID)
|
|
||||||
// foodName = it?.getStringExtra(FoodSearchActivity.FOOD_NAME)
|
|
||||||
// binding.etInputDish.run {
|
|
||||||
// setText(foodName)
|
|
||||||
// tag = foodName
|
|
||||||
// setSelection(text.length)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// KeyboardUtil.hideKeyboard(v)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun searchDishType() {
|
|
||||||
// val inputText = binding.etInputDishType.text.toString().trim()
|
|
||||||
// FoodSearchDialog(
|
|
||||||
// activity = this@DishSamplingActivity,
|
|
||||||
// defGoodsName = inputText
|
|
||||||
// ) { item ->
|
|
||||||
// val filterResult = list.firstOrNull { it.goodsName == item.goodsName }
|
|
||||||
// if (filterResult != null) {
|
|
||||||
// toast("不允许重复添加同一食材")
|
|
||||||
// return@FoodSearchDialog
|
|
||||||
// }
|
|
||||||
// binding.etInputDishType.run {
|
|
||||||
// setText(item.goodsName)
|
|
||||||
// setSelection(length())
|
|
||||||
// }
|
|
||||||
// tempDishEntity = CookFoodGoodsEntity().apply {
|
|
||||||
// goodsId = item.goodsId
|
|
||||||
// goodsName = item.goodsName
|
|
||||||
//
|
|
||||||
// relateionType = item.relateionType ?: 0
|
|
||||||
// goodsOrRelationCode = item.goodsOrRelationCode
|
|
||||||
//
|
|
||||||
// isNewDishType = true
|
|
||||||
// // TODO: 待定
|
|
||||||
// //allEdible = item.allEdible
|
|
||||||
// }
|
|
||||||
// }.show()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
@@ -99,6 +99,9 @@ class FoodRecognizeActivity : BaseActivity() {
|
|||||||
/** 右侧自定义滚动指示条最小高度 */
|
/** 右侧自定义滚动指示条最小高度 */
|
||||||
private val scrollIndicatorMinHeightPx by lazy { (24 * resources.displayMetrics.density).toInt() }
|
private val scrollIndicatorMinHeightPx by lazy { (24 * resources.displayMetrics.density).toInt() }
|
||||||
|
|
||||||
|
/** 食材搜索弹窗,持有引用防止重复打开 */
|
||||||
|
private var foodSearchDialog: FoodSearchDialog? = null
|
||||||
|
|
||||||
private val scrollListener = object : RecyclerView.OnScrollListener() {
|
private val scrollListener = object : RecyclerView.OnScrollListener() {
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
updateScrollIndicator()
|
updateScrollIndicator()
|
||||||
@@ -259,14 +262,15 @@ class FoodRecognizeActivity : BaseActivity() {
|
|||||||
* 初始化按钮点击事件
|
* 初始化按钮点击事件
|
||||||
*/
|
*/
|
||||||
private fun initClickListeners() {
|
private fun initClickListeners() {
|
||||||
// 更换食材:打开食材搜索弹窗
|
// 更换食材:打开食材搜索弹窗,已打开时跳过
|
||||||
binding.btnChangeFood.clickWithDebounce {
|
binding.btnChangeFood.clickWithDebounce {
|
||||||
// val currentName = list.getOrNull(selectedPosition)?.goodsName
|
// val currentName = list.getOrNull(selectedPosition)?.goodsName
|
||||||
FoodSearchDialog(
|
if (foodSearchDialog?.isShowing == true) return@clickWithDebounce
|
||||||
|
foodSearchDialog = FoodSearchDialog(
|
||||||
activity = this,
|
activity = this,
|
||||||
// defGoodsName = currentName,
|
// defGoodsName = currentName,
|
||||||
onItemSelected = { item -> updateSelectedFood(item) }
|
onItemSelected = { item -> updateSelectedFood(item) }
|
||||||
).show()
|
).also { it.show() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消:关闭页面
|
// 取消:关闭页面
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.shuwei.dish.match.ui
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.view.animation.RotateAnimation
|
import android.view.animation.RotateAnimation
|
||||||
import androidx.activity.addCallback
|
import androidx.activity.addCallback
|
||||||
@@ -33,6 +35,34 @@ class InitActivity : BaseActivity() {
|
|||||||
private lateinit var binding: ActivityInitBinding
|
private lateinit var binding: ActivityInitBinding
|
||||||
private var startTime = 0L // 倒计时开始时间
|
private var startTime = 0L // 倒计时开始时间
|
||||||
private var lastNetworkCheckTime = 0L // 上次检测网络的时间
|
private var lastNetworkCheckTime = 0L // 上次检测网络的时间
|
||||||
|
private val countdownHandler = Handler(Looper.getMainLooper())
|
||||||
|
private val countdownTask = object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
val elapsedTime = SystemClock.elapsedRealtime() - startTime
|
||||||
|
val remainingTime = 60 - (elapsedTime / 1000).toInt()
|
||||||
|
val currentNetworkCheckTime = (elapsedTime / 1000).toInt()
|
||||||
|
|
||||||
|
// 每 10 秒检测一次网络
|
||||||
|
if (currentNetworkCheckTime > 0 && currentNetworkCheckTime % 10 == 0 && currentNetworkCheckTime != lastNetworkCheckTime.toInt()) {
|
||||||
|
lastNetworkCheckTime = currentNetworkCheckTime.toLong()
|
||||||
|
checkNetworkConnection()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 倒计时未结束,继续更新 UI
|
||||||
|
if (remainingTime > 0) {
|
||||||
|
binding.tvCountdown.text = "${remainingTime}秒"
|
||||||
|
countdownHandler.postDelayed(this, 100)
|
||||||
|
} else {
|
||||||
|
// 倒计时结束,最后检测一次网络
|
||||||
|
if (NetworkUtils.isNetworkConnected(this@InitActivity)) {
|
||||||
|
startNextPage()
|
||||||
|
} else {
|
||||||
|
// 网络未连接,显示"连接网络"按钮
|
||||||
|
showNetworkButton()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("HardwareIds")
|
@SuppressLint("HardwareIds")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -108,6 +138,7 @@ class InitActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
countdownHandler.removeCallbacksAndMessages(null)
|
||||||
WeightUtil.stopContinuousRead()
|
WeightUtil.stopContinuousRead()
|
||||||
ScaleServiceManager.stop()
|
ScaleServiceManager.stop()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
@@ -155,7 +186,7 @@ class InitActivity : BaseActivity() {
|
|||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
// 页面不可见时停止倒计时
|
// 页面不可见时停止倒计时
|
||||||
handler.removeCallbacksAndMessages(null)
|
countdownHandler.removeCallbacks(countdownTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,31 +209,8 @@ class InitActivity : BaseActivity() {
|
|||||||
* 使用 SystemClock.elapsedRealtime() 确保精确计时
|
* 使用 SystemClock.elapsedRealtime() 确保精确计时
|
||||||
*/
|
*/
|
||||||
private fun scheduleCountdown() {
|
private fun scheduleCountdown() {
|
||||||
handler.postDelayed({
|
countdownHandler.removeCallbacks(countdownTask)
|
||||||
val elapsedTime = SystemClock.elapsedRealtime() - startTime
|
countdownHandler.postDelayed(countdownTask, 100)
|
||||||
val remainingTime = 60 - (elapsedTime / 1000).toInt()
|
|
||||||
val currentNetworkCheckTime = (elapsedTime / 1000).toInt()
|
|
||||||
|
|
||||||
// 每 10 秒检测一次网络
|
|
||||||
if (currentNetworkCheckTime > 0 && currentNetworkCheckTime % 10 == 0 && currentNetworkCheckTime != lastNetworkCheckTime.toInt()) {
|
|
||||||
lastNetworkCheckTime = currentNetworkCheckTime.toLong()
|
|
||||||
checkNetworkConnection()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 倒计时未结束,继续更新 UI
|
|
||||||
if (remainingTime > 0) {
|
|
||||||
binding.tvCountdown.text = "${remainingTime}秒"
|
|
||||||
scheduleCountdown()
|
|
||||||
} else {
|
|
||||||
// 倒计时结束,最后检测一次网络
|
|
||||||
if (NetworkUtils.isNetworkConnected(this)) {
|
|
||||||
startNextPage()
|
|
||||||
} else {
|
|
||||||
// 网络未连接,显示"连接网络"按钮
|
|
||||||
showNetworkButton()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 100) // 每 100ms 检查一次,确保精确性
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,7 +219,7 @@ class InitActivity : BaseActivity() {
|
|||||||
private fun checkNetworkConnection() {
|
private fun checkNetworkConnection() {
|
||||||
if (NetworkUtils.isNetworkConnected(this)) {
|
if (NetworkUtils.isNetworkConnected(this)) {
|
||||||
// 网络连接成功,停止倒计时并跳转到 HomeActivity
|
// 网络连接成功,停止倒计时并跳转到 HomeActivity
|
||||||
handler.removeCallbacksAndMessages(null)
|
countdownHandler.removeCallbacks(countdownTask)
|
||||||
startNextPage()
|
startNextPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import androidx.activity.addCallback
|
|||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.shuwei.dish.match.R
|
import com.shuwei.dish.match.R
|
||||||
import com.shuwei.dish.match.adapter.DishPartAdapter
|
import com.shuwei.dish.match.adapter.DishPartAdapter
|
||||||
@@ -29,7 +28,6 @@ import com.shuwei.dish.match.utils.CameraUtils
|
|||||||
import com.shuwei.dish.match.utils.ImageUtil
|
import com.shuwei.dish.match.utils.ImageUtil
|
||||||
import com.shuwei.dish.match.utils.KeyboardUtil
|
import com.shuwei.dish.match.utils.KeyboardUtil
|
||||||
import com.shuwei.dish.match.utils.SpTool
|
import com.shuwei.dish.match.utils.SpTool
|
||||||
import com.shuwei.dish.match.utils.SwipeCallback
|
|
||||||
import com.shuwei.dish.match.utils.WeightUtil
|
import com.shuwei.dish.match.utils.WeightUtil
|
||||||
import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
||||||
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
||||||
@@ -354,12 +352,29 @@ class PrepareFoodActivity : BaseActivity() {
|
|||||||
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 {
|
||||||
setOnItemClickListener { _, _, positon ->
|
val adapter = this
|
||||||
|
onItemClick = { positon ->
|
||||||
list.forEachIndexed { index, entity ->
|
list.forEachIndexed { index, entity ->
|
||||||
entity.isItemClicked = index == positon
|
entity.isItemClicked = index == positon
|
||||||
}
|
}
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
onDeleteClick = onDeleteClick@{ positon ->
|
||||||
|
Log.d(TAG, "onFoodItemClick: ${list[positon].toJsonString()}")
|
||||||
|
if (list[positon].isNewDishType.not()) {
|
||||||
|
toast("只能删除刚添加的食材")
|
||||||
|
return@onDeleteClick
|
||||||
|
}
|
||||||
|
CommonDialog(this@PrepareFoodActivity)
|
||||||
|
.setTitle("删除确认")
|
||||||
|
.setContent("确定删除食材「${list[positon].goodsName}」吗?")
|
||||||
|
.setNegativeButton("取消")
|
||||||
|
.setPositiveButton("删除") {
|
||||||
|
adapter.removeAt(positon)
|
||||||
|
toast("已删除")
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
addOnItemChildClickListener(R.id.ivClearIcon) { _, _, positon ->
|
addOnItemChildClickListener(R.id.ivClearIcon) { _, _, positon ->
|
||||||
Log.d(TAG, "onFoodItemClick: ${list[positon].toJsonString()}")
|
Log.d(TAG, "onFoodItemClick: ${list[positon].toJsonString()}")
|
||||||
if (list[positon].isOriginalData) {
|
if (list[positon].isOriginalData) {
|
||||||
@@ -371,7 +386,7 @@ class PrepareFoodActivity : BaseActivity() {
|
|||||||
notifyItemChanged(positon)
|
notifyItemChanged(positon)
|
||||||
return@addOnItemChildClickListener
|
return@addOnItemChildClickListener
|
||||||
}
|
}
|
||||||
removeAt(positon)
|
adapter.removeAt(positon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -384,18 +399,17 @@ class PrepareFoodActivity : BaseActivity() {
|
|||||||
layoutManager =
|
layoutManager =
|
||||||
LinearLayoutManager(this@PrepareFoodActivity, LinearLayoutManager.VERTICAL, false)
|
LinearLayoutManager(this@PrepareFoodActivity, LinearLayoutManager.VERTICAL, false)
|
||||||
adapter = dishPartAdapter
|
adapter = dishPartAdapter
|
||||||
val itemTouchHelper = ItemTouchHelper(SwipeCallback(dishPartAdapter) { position ->
|
addOnItemTouchListener(object : androidx.recyclerview.widget.RecyclerView.SimpleOnItemTouchListener() {
|
||||||
if (list[position].isNewDishType.not()) {
|
override fun onInterceptTouchEvent(
|
||||||
toast("只能删除刚添加的食材")
|
rv: androidx.recyclerview.widget.RecyclerView,
|
||||||
dishPartAdapter.notifyItemChanged(position)
|
e: android.view.MotionEvent
|
||||||
return@SwipeCallback
|
): Boolean {
|
||||||
|
if (e.action == android.view.MotionEvent.ACTION_DOWN) {
|
||||||
|
dishPartAdapter.closeAll()
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
list.removeAt(position)
|
|
||||||
dishPartAdapter.notifyItemRemoved(position)
|
|
||||||
dishPartAdapter.notifyItemRangeChanged(position, list.size - position)
|
|
||||||
toast("已删除")
|
|
||||||
})
|
})
|
||||||
itemTouchHelper.attachToRecyclerView(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,10 +551,10 @@ class PrepareFoodActivity : BaseActivity() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
Log.d(TAG, "takePhoto queryFood, 数据添加完成")
|
Log.d(TAG, "takePhoto queryFood, 数据添加完成")
|
||||||
handler.postDelayed({
|
postDelayed(1000) {
|
||||||
dismissLoading()
|
dismissLoading()
|
||||||
loadRecognizeResultPage(foodList)
|
loadRecognizeResultPage(foodList)
|
||||||
}, 1000)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MotionEvent
|
||||||
import androidx.activity.addCallback
|
import androidx.activity.addCallback
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.shuwei.dish.match.R
|
import com.shuwei.dish.match.R
|
||||||
import com.shuwei.dish.match.adapter.SamplingAdapter
|
import com.shuwei.dish.match.adapter.FoodListAdapter
|
||||||
import com.shuwei.dish.match.base.BaseActivity
|
import com.shuwei.dish.match.base.BaseActivity
|
||||||
import com.shuwei.dish.match.base.BaseApp
|
import com.shuwei.dish.match.base.BaseApp
|
||||||
import com.shuwei.dish.match.databinding.ActivitySamplingModeBinding
|
import com.shuwei.dish.match.databinding.ActivitySamplingModeBinding
|
||||||
@@ -19,7 +19,6 @@ import com.shuwei.dish.match.databinding.LayoutEmptyViewBinding
|
|||||||
import com.shuwei.dish.match.dialog.CommonDialog
|
import com.shuwei.dish.match.dialog.CommonDialog
|
||||||
import com.shuwei.dish.match.entity.FoodRecord
|
import com.shuwei.dish.match.entity.FoodRecord
|
||||||
import com.shuwei.dish.match.utils.DateTimeUtil
|
import com.shuwei.dish.match.utils.DateTimeUtil
|
||||||
import com.shuwei.dish.match.utils.SwipeCallback
|
|
||||||
import com.shuwei.dish.match.utils.ext.gone
|
import com.shuwei.dish.match.utils.ext.gone
|
||||||
import com.shuwei.dish.match.utils.ext.startActivity
|
import com.shuwei.dish.match.utils.ext.startActivity
|
||||||
import com.shuwei.dish.match.utils.ext.toast
|
import com.shuwei.dish.match.utils.ext.toast
|
||||||
@@ -160,9 +159,26 @@ class SamplingModeActivity : BaseActivity() {
|
|||||||
|
|
||||||
private var list: MutableList<FoodRecord> = mutableListOf()
|
private var list: MutableList<FoodRecord> = mutableListOf()
|
||||||
private val dishAdapter by lazy {
|
private val dishAdapter by lazy {
|
||||||
SamplingAdapter(list = list).apply {
|
FoodListAdapter(list = list, mode = FoodListAdapter.DisplayMode.SAMPLING_MODE).apply {
|
||||||
isStateViewEnable = true
|
isStateViewEnable = true
|
||||||
setOnItemClickListener { adapter, view, position ->
|
onDeleteClick = { position ->
|
||||||
|
CommonDialog(this@SamplingModeActivity)
|
||||||
|
.setTitle("删除确认")
|
||||||
|
.setContent("确定要删除「${list[position].foodName}」吗?")
|
||||||
|
.setNegativeButton("取消")
|
||||||
|
.setPositiveButton("删除") {
|
||||||
|
deleteCookFoodAndGoods(foodId = list[position].foodId ?: "") {
|
||||||
|
if (list.size > 1) {
|
||||||
|
removeAt(position)
|
||||||
|
} else {
|
||||||
|
loadEmptyView()
|
||||||
|
}
|
||||||
|
toast("已删除")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
onItemClick = { position ->
|
||||||
judgeDeviceConfig {
|
judgeDeviceConfig {
|
||||||
onItemClick(position)
|
onItemClick(position)
|
||||||
}
|
}
|
||||||
@@ -192,22 +208,15 @@ class SamplingModeActivity : BaseActivity() {
|
|||||||
layoutManager =
|
layoutManager =
|
||||||
LinearLayoutManager(this@SamplingModeActivity, LinearLayoutManager.VERTICAL, false)
|
LinearLayoutManager(this@SamplingModeActivity, LinearLayoutManager.VERTICAL, false)
|
||||||
adapter = dishAdapter
|
adapter = dishAdapter
|
||||||
val itemTouchHelper = ItemTouchHelper(SwipeCallback(dishAdapter) { position ->
|
// 点击列表空白区域时关闭已展开的侧滑 item
|
||||||
if (list[position].isCooking.not()) {
|
addOnItemTouchListener(object : androidx.recyclerview.widget.RecyclerView.SimpleOnItemTouchListener() {
|
||||||
toast("只能删除烹饪中的菜品")
|
override fun onInterceptTouchEvent(rv: androidx.recyclerview.widget.RecyclerView, e: MotionEvent): Boolean {
|
||||||
dishAdapter.notifyItemChanged(position)
|
if (e.action == MotionEvent.ACTION_DOWN) {
|
||||||
return@SwipeCallback
|
dishAdapter.closeAll()
|
||||||
}
|
|
||||||
deleteCookFoodAndGoods(foodId = list[position].foodId ?: "") {
|
|
||||||
if (list.size > 1) {
|
|
||||||
dishAdapter.removeAt(position)
|
|
||||||
} else {
|
|
||||||
loadEmptyView()
|
|
||||||
}
|
}
|
||||||
toast("已删除")
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
itemTouchHelper.attachToRecyclerView(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 -> "调料区设置"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,11 +147,13 @@ class SubmitFoodActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 初始化 RecyclerView,2列 GridLayoutManager */
|
/** 初始化 RecyclerView,24列 GridLayoutManager */
|
||||||
private fun setupRecyclerView() {
|
private fun setupRecyclerView() {
|
||||||
binding.rvSeasoning.itemAnimator = null
|
binding.rvSeasoning.let {
|
||||||
binding.rvSeasoning.layoutManager = GridLayoutManager(this, 2)
|
it.itemAnimator = null
|
||||||
binding.rvSeasoning.adapter = seasoningAdapter
|
it.layoutManager = GridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false)
|
||||||
|
it.adapter = seasoningAdapter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import com.shuwei.dish.match.base.BaseFragment
|
|||||||
import com.shuwei.dish.match.databinding.FragmentDeviceConfigBinding
|
import com.shuwei.dish.match.databinding.FragmentDeviceConfigBinding
|
||||||
import com.shuwei.dish.match.ui.SamplingModeActivity
|
import com.shuwei.dish.match.ui.SamplingModeActivity
|
||||||
import com.shuwei.dish.match.ui.CookingModeActivity
|
import com.shuwei.dish.match.ui.CookingModeActivity
|
||||||
|
import com.shuwei.dish.match.ui.HomeActivity
|
||||||
|
import com.shuwei.dish.match.utils.MultiClickDetector
|
||||||
import com.shuwei.dish.match.utils.SpTool
|
import com.shuwei.dish.match.utils.SpTool
|
||||||
import com.shuwei.dish.match.utils.ext.appendText
|
import com.shuwei.dish.match.utils.ext.appendText
|
||||||
import com.shuwei.dish.match.utils.ext.buildSpannableString
|
import com.shuwei.dish.match.utils.ext.buildSpannableString
|
||||||
@@ -110,7 +112,13 @@ class DeviceConfigFragment : BaseFragment<FragmentDeviceConfigBinding>() {
|
|||||||
}
|
}
|
||||||
activity?.finish()
|
activity?.finish()
|
||||||
}
|
}
|
||||||
|
// TODO: 临时测试----------------------
|
||||||
|
detector.setOnMultiClickListener(binding.tvSetting) {
|
||||||
|
activity?.startActivity<HomeActivity>()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val detector = MultiClickDetector(targetCount = 3, intervalMs = 500)
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * 添加称重监听
|
// * 添加称重监听
|
||||||
|
|||||||
@@ -3,25 +3,24 @@ package com.shuwei.dish.match.ui.fragment
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.chad.library.adapter4.util.setOnDebouncedItemClick
|
import com.shuwei.dish.match.adapter.FoodListAdapter
|
||||||
import com.shuwei.dish.match.adapter.DishShowAdapter
|
|
||||||
import com.shuwei.dish.match.base.BaseApp
|
import com.shuwei.dish.match.base.BaseApp
|
||||||
import com.shuwei.dish.match.base.BaseFragment
|
import com.shuwei.dish.match.base.BaseFragment
|
||||||
import com.shuwei.dish.match.databinding.FragmentDishListBinding
|
import com.shuwei.dish.match.databinding.FragmentDishListBinding
|
||||||
import com.shuwei.dish.match.databinding.LayoutEmptyViewBinding
|
import com.shuwei.dish.match.databinding.LayoutEmptyViewBinding
|
||||||
import com.shuwei.dish.match.entity.CookFoodEntity
|
import com.shuwei.dish.match.entity.CookFoodEntity
|
||||||
import com.shuwei.dish.match.entity.FoodRecord
|
import com.shuwei.dish.match.entity.FoodRecord
|
||||||
|
import com.shuwei.dish.match.dialog.CommonDialog
|
||||||
import com.shuwei.dish.match.net.UiState
|
import com.shuwei.dish.match.net.UiState
|
||||||
import com.shuwei.dish.match.ui.PrepareFoodActivity
|
import com.shuwei.dish.match.ui.PrepareFoodActivity
|
||||||
import com.shuwei.dish.match.ui.CookingModeActivity
|
import com.shuwei.dish.match.ui.CookingModeActivity
|
||||||
import com.shuwei.dish.match.ui.SubmitFoodActivity
|
import com.shuwei.dish.match.ui.SubmitFoodActivity
|
||||||
import com.shuwei.dish.match.utils.SwipeCallback
|
|
||||||
import com.shuwei.dish.match.utils.ext.startActivity
|
import com.shuwei.dish.match.utils.ext.startActivity
|
||||||
import com.shuwei.dish.match.utils.ext.toast
|
import com.shuwei.dish.match.utils.ext.toast
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
@@ -52,14 +51,26 @@ class DishListFragment : BaseFragment<FragmentDishListBinding>() {
|
|||||||
|
|
||||||
private var list: MutableList<FoodRecord> = mutableListOf()
|
private var list: MutableList<FoodRecord> = mutableListOf()
|
||||||
private val dishAdapter by lazy {
|
private val dishAdapter by lazy {
|
||||||
DishShowAdapter(list = list).apply {
|
FoodListAdapter(list = list).apply {
|
||||||
isStateViewEnable = true
|
isStateViewEnable = true
|
||||||
setOnDebouncedItemClick { adapter, view, position ->
|
onDeleteClick = { position ->
|
||||||
if (isAdded.not() || isVisible.not()) {
|
CommonDialog(activity)
|
||||||
return@setOnDebouncedItemClick
|
.setTitle("删除确认")
|
||||||
}
|
.setContent("确定要删除「${list[position].foodName}」吗?")
|
||||||
activity.judgeDeviceConfig {
|
.setNegativeButton("取消")
|
||||||
onItemClick(position)
|
.setPositiveButton("删除") {
|
||||||
|
activity.deleteCookFoodAndGoods(foodId = list[position].foodId ?: "") {
|
||||||
|
removeAt(position)
|
||||||
|
activity.toast("已删除")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
onItemClick = { position ->
|
||||||
|
if (isAdded && isVisible) {
|
||||||
|
activity.judgeDeviceConfig {
|
||||||
|
onItemClick(position)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,18 +111,15 @@ class DishListFragment : BaseFragment<FragmentDishListBinding>() {
|
|||||||
layoutManager =
|
layoutManager =
|
||||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
adapter = dishAdapter
|
adapter = dishAdapter
|
||||||
val itemTouchHelper = ItemTouchHelper(SwipeCallback(dishAdapter) { position ->
|
// 点击列表空白区域时关闭已展开的侧滑 item
|
||||||
if (list[position].isCooking.not()) {
|
addOnItemTouchListener(object : androidx.recyclerview.widget.RecyclerView.SimpleOnItemTouchListener() {
|
||||||
activity.toast("只能删除烹饪中的菜品")
|
override fun onInterceptTouchEvent(rv: androidx.recyclerview.widget.RecyclerView, e: MotionEvent): Boolean {
|
||||||
dishAdapter.notifyItemChanged(position)
|
if (e.action == MotionEvent.ACTION_DOWN) {
|
||||||
return@SwipeCallback
|
dishAdapter.closeAll()
|
||||||
}
|
}
|
||||||
activity.deleteCookFoodAndGoods(foodId = list[position].foodId ?: "") {
|
return false
|
||||||
dishAdapter.removeAt(position)
|
|
||||||
activity.toast("已删除")
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
itemTouchHelper.attachToRecyclerView(this)
|
|
||||||
}
|
}
|
||||||
addViewListener()
|
addViewListener()
|
||||||
initObserver()
|
initObserver()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import com.shuwei.dish.match.databinding.FragmentVectorCollectionBinding
|
|||||||
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.entity.CookFoodGoodsEntity
|
||||||
import com.shuwei.dish.match.objbox.FoodCollectionBean
|
import com.shuwei.dish.match.entity.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
|
||||||
import com.shuwei.dish.match.ui.SingleFragmentActivity
|
import com.shuwei.dish.match.ui.SingleFragmentActivity
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
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.adapter.DishPartAdapter
|
import com.shuwei.dish.match.adapter.DishPartAdapter
|
||||||
import com.shuwei.dish.match.adapter.DishShowAdapter
|
import com.shuwei.dish.match.adapter.FoodListAdapter
|
||||||
import com.shuwei.dish.match.adapter.SamplingAdapter
|
|
||||||
import androidx.core.view.isEmpty
|
|
||||||
|
|
||||||
class SwipeCallback(
|
class SwipeCallback(
|
||||||
private val adapter: BaseQuickAdapter<*,*>,
|
private val adapter: BaseQuickAdapter<*,*>,
|
||||||
@@ -40,14 +38,7 @@ class SwipeCallback(
|
|||||||
// ItemTouchHelper.UP or ItemTouchHelper.DOWN
|
// ItemTouchHelper.UP or ItemTouchHelper.DOWN
|
||||||
var swipeFlags = ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT
|
var swipeFlags = ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT
|
||||||
|
|
||||||
if (adapter is SamplingAdapter) {
|
if (adapter is FoodListAdapter) {
|
||||||
if (adapter.items.isEmpty()) {
|
|
||||||
return makeMovementFlags(0, 0)
|
|
||||||
}
|
|
||||||
if (!adapter.items[position].isCooking) {
|
|
||||||
swipeFlags = 0
|
|
||||||
}
|
|
||||||
} else if (adapter is DishShowAdapter) {
|
|
||||||
if (adapter.items.isEmpty()) {
|
if (adapter.items.isEmpty()) {
|
||||||
return makeMovementFlags(0, 0)
|
return makeMovementFlags(0, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
+1133
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,271 @@
|
|||||||
|
/**
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Chau Thai
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.shuwei.dish.match.view.swipereveallayout;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewBinderHelper provides a quick and easy solution to restore the open/close state
|
||||||
|
* of the items in RecyclerView, ListView, GridView or any view that requires its child view
|
||||||
|
* to bind the view to a data object.
|
||||||
|
*
|
||||||
|
* <p>When you bind you data object to a view, use {@link #bind(SwipeRevealLayout, String)} to
|
||||||
|
* save and restore the open/close state of the view.</p>
|
||||||
|
*
|
||||||
|
* <p>Optionally, if you also want to save and restore the open/close state when the device's
|
||||||
|
* orientation is changed, call {@link #saveStates(Bundle)} in {@link android.app.Activity#onSaveInstanceState(Bundle)}
|
||||||
|
* and {@link #restoreStates(Bundle)} in {@link android.app.Activity#onRestoreInstanceState(Bundle)}</p>
|
||||||
|
*/
|
||||||
|
public class ViewBinderHelper {
|
||||||
|
private static final String BUNDLE_MAP_KEY = "ViewBinderHelper_Bundle_Map_Key";
|
||||||
|
|
||||||
|
private Map<String, Integer> mapStates = Collections.synchronizedMap(new HashMap<String, Integer>());
|
||||||
|
private Map<String, SwipeRevealLayout> mapLayouts = Collections.synchronizedMap(new HashMap<String, SwipeRevealLayout>());
|
||||||
|
private Set<String> lockedSwipeSet = Collections.synchronizedSet(new HashSet<String>());
|
||||||
|
|
||||||
|
private volatile boolean openOnlyOne = false;
|
||||||
|
private final Object stateChangeLock = new Object();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Help to save and restore open/close state of the swipeLayout. Call this method
|
||||||
|
* when you bind your view holder with the data object.
|
||||||
|
*
|
||||||
|
* @param swipeLayout swipeLayout of the current view.
|
||||||
|
* @param id a string that uniquely defines the data object of the current view.
|
||||||
|
*/
|
||||||
|
public void bind(final SwipeRevealLayout swipeLayout, final String id) {
|
||||||
|
if (swipeLayout.shouldRequestLayout()) {
|
||||||
|
swipeLayout.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
mapLayouts.values().remove(swipeLayout);
|
||||||
|
mapLayouts.put(id, swipeLayout);
|
||||||
|
|
||||||
|
swipeLayout.abort();
|
||||||
|
swipeLayout.setDragStateChangeListener(new SwipeRevealLayout.DragStateChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onDragStateChanged(int state) {
|
||||||
|
mapStates.put(id, state);
|
||||||
|
|
||||||
|
if (openOnlyOne) {
|
||||||
|
closeOthers(id, swipeLayout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// first time binding.
|
||||||
|
if (!mapStates.containsKey(id)) {
|
||||||
|
mapStates.put(id, SwipeRevealLayout.STATE_CLOSE);
|
||||||
|
swipeLayout.close(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// not the first time, then close or open depends on the current state.
|
||||||
|
else {
|
||||||
|
int state = mapStates.get(id);
|
||||||
|
|
||||||
|
if (state == SwipeRevealLayout.STATE_CLOSE || state == SwipeRevealLayout.STATE_CLOSING ||
|
||||||
|
state == SwipeRevealLayout.STATE_DRAGGING) {
|
||||||
|
swipeLayout.close(false);
|
||||||
|
} else {
|
||||||
|
swipeLayout.open(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set lock swipe
|
||||||
|
swipeLayout.setLockDrag(lockedSwipeSet.contains(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only if you need to restore open/close state when the orientation is changed.
|
||||||
|
* Call this method in {@link android.app.Activity#onSaveInstanceState(Bundle)}
|
||||||
|
*/
|
||||||
|
public void saveStates(Bundle outState) {
|
||||||
|
if (outState == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Bundle statesBundle = new Bundle();
|
||||||
|
for (Map.Entry<String, Integer> entry : mapStates.entrySet()) {
|
||||||
|
statesBundle.putInt(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
outState.putBundle(BUNDLE_MAP_KEY, statesBundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only if you need to restore open/close state when the orientation is changed.
|
||||||
|
* Call this method in {@link android.app.Activity#onRestoreInstanceState(Bundle)}
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"unchecked", "ConstantConditions"})
|
||||||
|
public void restoreStates(Bundle inState) {
|
||||||
|
if (inState == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (inState.containsKey(BUNDLE_MAP_KEY)) {
|
||||||
|
HashMap<String, Integer> restoredMap = new HashMap<>();
|
||||||
|
|
||||||
|
Bundle statesBundle = inState.getBundle(BUNDLE_MAP_KEY);
|
||||||
|
Set<String> keySet = statesBundle.keySet();
|
||||||
|
|
||||||
|
if (keySet != null) {
|
||||||
|
for (String key : keySet) {
|
||||||
|
restoredMap.put(key, statesBundle.getInt(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mapStates = restoredMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lock swipe for some layouts.
|
||||||
|
* @param id a string that uniquely defines the data object.
|
||||||
|
*/
|
||||||
|
public void lockSwipe(String... id) {
|
||||||
|
setLockSwipe(true, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlock swipe for some layouts.
|
||||||
|
* @param id a string that uniquely defines the data object.
|
||||||
|
*/
|
||||||
|
public void unlockSwipe(String... id) {
|
||||||
|
setLockSwipe(false, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param openOnlyOne If set to true, then only one row can be opened at a time.
|
||||||
|
*/
|
||||||
|
public void setOpenOnlyOne(boolean openOnlyOne) {
|
||||||
|
this.openOnlyOne = openOnlyOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a specific layout.
|
||||||
|
* @param id unique id which identifies the data object which is bind to the layout.
|
||||||
|
*/
|
||||||
|
public void openLayout(final String id) {
|
||||||
|
synchronized (stateChangeLock) {
|
||||||
|
mapStates.put(id, SwipeRevealLayout.STATE_OPEN);
|
||||||
|
|
||||||
|
if (mapLayouts.containsKey(id)) {
|
||||||
|
final SwipeRevealLayout layout = mapLayouts.get(id);
|
||||||
|
layout.open(true);
|
||||||
|
}
|
||||||
|
else if (openOnlyOne) {
|
||||||
|
closeOthers(id, mapLayouts.get(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close a specific layout.
|
||||||
|
* @param id unique id which identifies the data object which is bind to the layout.
|
||||||
|
*/
|
||||||
|
public void closeLayout(final String id) {
|
||||||
|
synchronized (stateChangeLock) {
|
||||||
|
mapStates.put(id, SwipeRevealLayout.STATE_CLOSE);
|
||||||
|
|
||||||
|
if (mapLayouts.containsKey(id)) {
|
||||||
|
final SwipeRevealLayout layout = mapLayouts.get(id);
|
||||||
|
layout.close(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭所有已展开的侧滑布局,用于点击空白区域时收起侧滑。
|
||||||
|
*/
|
||||||
|
public void closeAll() {
|
||||||
|
synchronized (stateChangeLock) {
|
||||||
|
for (Map.Entry<String, Integer> entry : mapStates.entrySet()) {
|
||||||
|
entry.setValue(SwipeRevealLayout.STATE_CLOSE);
|
||||||
|
}
|
||||||
|
for (SwipeRevealLayout layout : mapLayouts.values()) {
|
||||||
|
layout.close(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close others swipe layout.
|
||||||
|
* @param id layout which bind with this data object id will be excluded.
|
||||||
|
* @param swipeLayout will be excluded.
|
||||||
|
*/
|
||||||
|
private void closeOthers(String id, SwipeRevealLayout swipeLayout) {
|
||||||
|
synchronized (stateChangeLock) {
|
||||||
|
// close other rows if openOnlyOne is true.
|
||||||
|
if (getOpenCount() > 1) {
|
||||||
|
for (Map.Entry<String, Integer> entry : mapStates.entrySet()) {
|
||||||
|
if (!entry.getKey().equals(id)) {
|
||||||
|
entry.setValue(SwipeRevealLayout.STATE_CLOSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SwipeRevealLayout layout : mapLayouts.values()) {
|
||||||
|
if (layout != swipeLayout) {
|
||||||
|
layout.close(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLockSwipe(boolean lock, String... id) {
|
||||||
|
if (id == null || id.length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (lock)
|
||||||
|
lockedSwipeSet.addAll(Arrays.asList(id));
|
||||||
|
else
|
||||||
|
lockedSwipeSet.removeAll(Arrays.asList(id));
|
||||||
|
|
||||||
|
for (String s : id) {
|
||||||
|
SwipeRevealLayout layout = mapLayouts.get(s);
|
||||||
|
if (layout != null) {
|
||||||
|
layout.setLockDrag(lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getOpenCount() {
|
||||||
|
int total = 0;
|
||||||
|
|
||||||
|
for (int state : mapStates.values()) {
|
||||||
|
if (state == SwipeRevealLayout.STATE_OPEN || state == SwipeRevealLayout.STATE_OPENING) {
|
||||||
|
total++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#FFEF5350" />
|
||||||
|
<!-- 仅右侧两个角有圆角,与前景层圆角半径一致 -->
|
||||||
|
<corners
|
||||||
|
android:topRightRadius="15dp"
|
||||||
|
android:bottomRightRadius="15dp" />
|
||||||
|
</shape>
|
||||||
@@ -1,32 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- 白色垃圾桶图标:使用 evenOdd 填充规则实现条纹镂空,无硬编码背景色依赖 -->
|
<!-- 白色垃圾桶图标-->
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="40dp"
|
android:width="24dp"
|
||||||
android:height="40dp"
|
android:height="24dp"
|
||||||
android:viewportWidth="40"
|
android:viewportWidth="1024"
|
||||||
android:viewportHeight="40">
|
android:viewportHeight="1024">
|
||||||
|
|
||||||
<!-- 桶盖 -->
|
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FFFFFF"
|
android:fillColor="#FFFFFF"
|
||||||
android:fillType="evenOdd"
|
android:pathData="M913.5,225.8h-241V128c0,-34.5 -28.3,-62.8 -62.8,-62.8H413.3c-34.5,0 -62.8,28.3 -62.8,62.8v97.8H111.1c-25.8,0 -46.9,21.1 -46.9,46.9 0,25.8 21.1,46.9 46.9,46.9h81v590.3c0,25.8 21.1,46.9 46.9,46.9h546.4c25.8,0 46.9,-21.1 46.9,-46.9 0,-1.1 -0.1,-2.2 -0.1,-3.3V319.5h81.5c25.8,0 46.9,-21.1 46.9,-46.9 -0.2,-25.7 -21.3,-46.8 -47.1,-46.8zM448.1,156.1c0,-0.1 0,-0.1 0,0l128,-0.1s0.1,0 0.1,0.1v69.7h-128v-69.7zM737,863H287V319.5h450V863z" />
|
||||||
android:pathData="
|
|
||||||
M10,13 A1,1 0 0,1 10,11 L14,11 L14,9
|
|
||||||
A2,2 0 0,1 16,7 L24,7
|
|
||||||
A2,2 0 0,1 26,9 L26,11 L30,11
|
|
||||||
A1,1 0 0,1 30,13 Z
|
|
||||||
M16,9 L16,11 L24,11 L24,9 Z" />
|
|
||||||
|
|
||||||
<!-- 桶身:外轮廓 + 三条竖槽镂空,evenOdd 使竖槽透明 -->
|
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FFFFFF"
|
android:fillColor="#FFFFFF"
|
||||||
android:fillType="evenOdd"
|
android:pathData="M420.8,767.8c27.4,0 49.8,-22.4 49.8,-49.8V466c0,-27.4 -22.4,-49.8 -49.8,-49.8S371,438.6 371,466v252c0,27.4 22.4,49.8 49.8,49.8zM602.9,767.8c27.4,0 49.8,-22.4 49.8,-49.8V466c0,-27.4 -22.4,-49.8 -49.8,-49.8s-49.8,22.4 -49.8,49.8v252c0,27.4 22.4,49.8 49.8,49.8z" />
|
||||||
android:pathData="
|
|
||||||
M12,15 L13.5,33
|
|
||||||
A2,2 0 0,0 15.5,35 L24.5,35
|
|
||||||
A2,2 0 0,0 26.5,33 L28,15 Z
|
|
||||||
M17,18 L17,32 L19,32 L19,18 Z
|
|
||||||
M19.5,18 L19.5,32 L21.5,32 L21.5,18 Z
|
|
||||||
M22,18 L22,32 L24,32 L24,18 Z" />
|
|
||||||
|
|
||||||
</vector>
|
</vector>
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
android:id="@+id/ivLoading"
|
android:id="@+id/ivLoading"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:src="@drawable/loading_spinner"
|
android:src="@drawable/loading"
|
||||||
android:contentDescription="加载中" />
|
android:contentDescription="加载中" />
|
||||||
|
|
||||||
<!-- 倒计时文字 -->
|
<!-- 倒计时文字 -->
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:ignore="ContentDescription"
|
tools:ignore="ContentDescription"
|
||||||
tools:src="@drawable/bg_home_page" />
|
tools:src="@drawable/bg_other_page" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvLeftTime"
|
android:id="@+id/tvLeftTime"
|
||||||
|
|||||||
@@ -1,293 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
tools:background="@drawable/bg_other_page">
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:id="@+id/llSearchBar"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="100dp"-->
|
|
||||||
<!-- android:layout_margin="30dp"-->
|
|
||||||
<!-- android:background="@drawable/shape_white_30_corners"-->
|
|
||||||
<!-- android:gravity="center_vertical"-->
|
|
||||||
<!-- android:orientation="horizontal">-->
|
|
||||||
|
|
||||||
<!-- <EditText-->
|
|
||||||
<!-- android:id="@+id/etInputDish"-->
|
|
||||||
<!-- android:layout_width="0dp"-->
|
|
||||||
<!-- android:layout_height="80dp"-->
|
|
||||||
<!-- android:layout_marginStart="28dp"-->
|
|
||||||
<!-- android:layout_weight="1"-->
|
|
||||||
<!-- android:autofillHints=""-->
|
|
||||||
<!-- android:background="@color/white"-->
|
|
||||||
<!-- android:gravity="center"-->
|
|
||||||
<!-- android:hint="@string/dish_search_hint"-->
|
|
||||||
<!-- android:inputType="text"-->
|
|
||||||
<!-- android:imeOptions="actionSearch"-->
|
|
||||||
<!-- android:paddingStart="3dp"-->
|
|
||||||
<!-- android:paddingEnd="3dp"-->
|
|
||||||
<!-- android:textColor="@color/black333"-->
|
|
||||||
<!-- android:textColorHint="@color/gray_c8"-->
|
|
||||||
<!-- android:textSize="40sp"-->
|
|
||||||
<!-- tools:ignore="TextFields" />-->
|
|
||||||
|
|
||||||
<!-- <ImageView-->
|
|
||||||
<!-- android:id="@+id/ivDishSearch"-->
|
|
||||||
<!-- android:layout_width="60dp"-->
|
|
||||||
<!-- android:layout_height="60dp"-->
|
|
||||||
<!-- android:layout_marginStart="20dp"-->
|
|
||||||
<!-- android:layout_marginEnd="20dp"-->
|
|
||||||
<!-- android:paddingStart="10dp"-->
|
|
||||||
<!-- android:paddingEnd="10dp"-->
|
|
||||||
<!-- android:src="@drawable/ic_search_gray"-->
|
|
||||||
<!-- tools:ignore="ContentDescription" />-->
|
|
||||||
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginEnd="30dp"-->
|
|
||||||
<!-- android:layout_marginBottom="30dp"-->
|
|
||||||
<!-- android:background="@drawable/shape_white_30_corners"-->
|
|
||||||
<!-- android:gravity="center_vertical"-->
|
|
||||||
<!-- android:orientation="vertical">-->
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="113dp"-->
|
|
||||||
<!-- android:gravity="center_vertical"-->
|
|
||||||
<!-- android:orientation="horizontal">-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:layout_width="0dp"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginEnd="30dp"-->
|
|
||||||
<!-- android:layout_weight="1"-->
|
|
||||||
<!-- android:text="@string/dish_name"-->
|
|
||||||
<!-- android:textColor="@color/black666"-->
|
|
||||||
<!-- android:textSize="28sp" />-->
|
|
||||||
|
|
||||||
<!-- <EditText-->
|
|
||||||
<!-- android:id="@+id/etInputDishType"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="80dp"-->
|
|
||||||
<!-- android:background="@color/white"-->
|
|
||||||
<!-- android:gravity="center_vertical"-->
|
|
||||||
<!-- android:hint="@string/dish_search_hint2"-->
|
|
||||||
<!-- android:textColor="@color/black333"-->
|
|
||||||
<!-- android:textColorHint="@color/gray_c8"-->
|
|
||||||
<!-- android:imeOptions="actionSearch"-->
|
|
||||||
<!-- android:inputType="text"-->
|
|
||||||
<!-- android:textSize="28sp"-->
|
|
||||||
<!-- android:maxLines="1"-->
|
|
||||||
<!-- android:paddingEnd="6dp"-->
|
|
||||||
<!-- android:paddingStart="6dp"-->
|
|
||||||
<!-- android:ellipsize="end"/>-->
|
|
||||||
|
|
||||||
<!-- <ImageView-->
|
|
||||||
<!-- android:id="@+id/ivDishTypeSearch"-->
|
|
||||||
<!-- android:layout_width="80dp"-->
|
|
||||||
<!-- android:layout_height="80dp"-->
|
|
||||||
<!-- android:padding="24dp"-->
|
|
||||||
<!-- android:layout_marginEnd="6dp"-->
|
|
||||||
<!-- android:src="@drawable/ic_search_green"-->
|
|
||||||
<!-- tools:ignore="ContentDescription" />-->
|
|
||||||
|
|
||||||
<!-- <!– <ImageView–>-->
|
|
||||||
<!-- <!– android:id="@+id/ivDishTypeSearch"–>-->
|
|
||||||
<!-- <!– android:layout_width="62dp"–>-->
|
|
||||||
<!-- <!– android:layout_height="62dp"–>-->
|
|
||||||
<!-- <!– android:layout_marginStart="15dp"–>-->
|
|
||||||
<!-- <!– android:layout_marginEnd="15dp"–>-->
|
|
||||||
<!-- <!– android:paddingStart="15dp"–>-->
|
|
||||||
<!-- <!– android:paddingEnd="15dp"–>-->
|
|
||||||
<!-- <!– android:src="@drawable/ic_search_green"–>-->
|
|
||||||
<!-- <!– tools:ignore="ContentDescription" />–>-->
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<!-- <com.google.android.material.divider.MaterialDivider-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="1dp"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginEnd="30dp"-->
|
|
||||||
<!-- app:dividerColor="@color/gray_eb" />-->
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="113dp"-->
|
|
||||||
<!-- android:gravity="center_vertical"-->
|
|
||||||
<!-- android:orientation="horizontal">-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginEnd="30dp"-->
|
|
||||||
<!-- android:text="@string/dish_from_type"-->
|
|
||||||
<!-- android:textColor="@color/black666"-->
|
|
||||||
<!-- android:textSize="28sp" />-->
|
|
||||||
|
|
||||||
<!-- <RadioGroup-->
|
|
||||||
<!-- android:id="@+id/rgSampling"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="80dp"-->
|
|
||||||
<!-- android:gravity="center_vertical|end"-->
|
|
||||||
<!-- android:orientation="horizontal">-->
|
|
||||||
|
|
||||||
<!-- <RadioButton-->
|
|
||||||
<!-- android:id="@+id/rbDishTypeFirst"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:background="@color/white"-->
|
|
||||||
<!-- android:button="@null"-->
|
|
||||||
<!-- android:drawableStart="@drawable/selector_dish_type"-->
|
|
||||||
<!-- android:drawablePadding="30dp"-->
|
|
||||||
<!-- android:gravity="center"-->
|
|
||||||
<!-- android:paddingStart="30dp"-->
|
|
||||||
<!-- android:paddingEnd="30dp"-->
|
|
||||||
<!-- android:text="@string/dish_type_first"-->
|
|
||||||
<!-- android:textColor="@color/dish_type_font"-->
|
|
||||||
<!-- android:textSize="30sp"-->
|
|
||||||
<!-- android:textStyle="bold" />-->
|
|
||||||
|
|
||||||
<!-- <RadioButton-->
|
|
||||||
<!-- android:id="@+id/rbDishTypeSecond"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:background="@color/white"-->
|
|
||||||
<!-- android:button="@null"-->
|
|
||||||
<!-- android:checked="false"-->
|
|
||||||
<!-- android:drawableStart="@drawable/selector_dish_type"-->
|
|
||||||
<!-- android:drawablePadding="30dp"-->
|
|
||||||
<!-- android:gravity="center"-->
|
|
||||||
<!-- android:paddingStart="30dp"-->
|
|
||||||
<!-- android:paddingEnd="30dp"-->
|
|
||||||
<!-- android:text="@string/dish_type_second"-->
|
|
||||||
<!-- android:textColor="@color/dish_type_font"-->
|
|
||||||
<!-- android:textSize="30sp"-->
|
|
||||||
<!-- android:textStyle="bold" />-->
|
|
||||||
<!-- </RadioGroup>-->
|
|
||||||
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<!-- <com.google.android.material.divider.MaterialDivider-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="1dp"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginEnd="30dp"-->
|
|
||||||
<!-- app:dividerColor="@color/gray_eb" />-->
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="170dp"-->
|
|
||||||
<!-- android:gravity="center_vertical"-->
|
|
||||||
<!-- android:orientation="horizontal">-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginEnd="30dp"-->
|
|
||||||
<!-- android:text="@string/dish_part_weight_remind"-->
|
|
||||||
<!-- android:textColor="@color/black666"-->
|
|
||||||
<!-- android:textSize="28sp" />-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:id="@+id/tvDishPartWeight"-->
|
|
||||||
<!-- android:layout_width="0dp"-->
|
|
||||||
<!-- android:layout_height="100dp"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_weight="1"-->
|
|
||||||
<!-- android:autofillHints=""-->
|
|
||||||
<!-- android:background="@drawable/shape_white_f6_10_corners"-->
|
|
||||||
<!-- android:gravity="center"-->
|
|
||||||
<!-- android:hint="-"-->
|
|
||||||
<!-- android:maxLines="1"-->
|
|
||||||
<!-- android:paddingStart="20dp"-->
|
|
||||||
<!-- android:paddingEnd="20dp"-->
|
|
||||||
<!-- android:text=""-->
|
|
||||||
<!-- android:textColor="@color/dish_green"-->
|
|
||||||
<!-- android:textColorHint="@color/gray_d6"-->
|
|
||||||
<!-- android:textSize="60sp"-->
|
|
||||||
<!-- tools:ignore="HardcodedText" />-->
|
|
||||||
|
|
||||||
<!-- <ImageView-->
|
|
||||||
<!-- android:id="@+id/ivWeightClear"-->
|
|
||||||
<!-- android:layout_width="90dp"-->
|
|
||||||
<!-- android:layout_height="90dp"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:src="@drawable/ic_weight_clear"-->
|
|
||||||
<!-- tools:ignore="ContentDescription" />-->
|
|
||||||
|
|
||||||
<!-- <ImageView-->
|
|
||||||
<!-- android:id="@+id/ivWeightAdd"-->
|
|
||||||
<!-- android:layout_width="90dp"-->
|
|
||||||
<!-- android:layout_height="90dp"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginEnd="30dp"-->
|
|
||||||
<!-- android:src="@drawable/ic_weight_add"-->
|
|
||||||
<!-- tools:ignore="ContentDescription" />-->
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="0dp"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginTop="0dp"-->
|
|
||||||
<!-- android:layout_marginEnd="30dp"-->
|
|
||||||
<!-- android:layout_weight="1"-->
|
|
||||||
<!-- android:background="@drawable/shape_white_30_corners"-->
|
|
||||||
<!-- android:orientation="vertical">-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginStart="30dp"-->
|
|
||||||
<!-- android:layout_marginTop="40dp"-->
|
|
||||||
<!-- android:layout_marginBottom="40dp"-->
|
|
||||||
<!-- android:text="@string/dish_composition"-->
|
|
||||||
<!-- android:textColor="@color/black666"-->
|
|
||||||
<!-- android:textSize="28sp" />-->
|
|
||||||
|
|
||||||
<!-- <androidx.recyclerview.widget.RecyclerView-->
|
|
||||||
<!-- android:id="@+id/rvDishPartList"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- android:layout_marginBottom="20dp"-->
|
|
||||||
<!-- android:overScrollMode="never"-->
|
|
||||||
<!-- tools:itemCount="3"-->
|
|
||||||
<!-- tools:listitem="@layout/list_item_dish_cook"-->
|
|
||||||
<!-- android:scrollbars="vertical"/>-->
|
|
||||||
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:id="@+id/btnCook"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="90dp"-->
|
|
||||||
<!-- android:layout_margin="30dp"-->
|
|
||||||
<!-- android:gravity="center"-->
|
|
||||||
<!-- android:text="@string/goCooking"-->
|
|
||||||
<!-- android:textColor="@color/white"-->
|
|
||||||
<!-- android:textSize="32sp"-->
|
|
||||||
<!-- android:textStyle="bold"-->
|
|
||||||
<!-- android:background="@drawable/shape_green_bg"-->
|
|
||||||
<!-- android:foreground="?android:attr/selectableItemBackground"-->
|
|
||||||
<!-- android:clickable="true" />-->
|
|
||||||
|
|
||||||
<!--<!– android:background="@drawable/ripple_effect_green"–>-->
|
|
||||||
<!--<!– android:background="@drawable/shape_green_bg"–>-->
|
|
||||||
<!--<!– android:background="?attr/selectableItemBackground"–>-->
|
|
||||||
<!--<!– android:clickable="true"–>-->
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:overScrollMode="never"
|
android:overScrollMode="never"
|
||||||
tools:listitem="@layout/list_item_dish" />
|
tools:listitem="@layout/list_item_food_list" />
|
||||||
|
|
||||||
<com.scwang.smart.refresh.footer.ClassicsFooter
|
<com.scwang.smart.refresh.footer.ClassicsFooter
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
android:layout_height="120dp"
|
android:layout_height="120dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="30dp"
|
||||||
android:layout_marginHorizontal="32dp"
|
android:layout_marginHorizontal="32dp"
|
||||||
android:background="@drawable/shape_white_e6_12_corners"
|
android:background="@drawable/shape_white_fb_15_corners2"
|
||||||
android:foreground="?android:attr/selectableItemBackground"
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
android:clipToOutline="true">
|
android:clipToOutline="true">
|
||||||
|
|
||||||
@@ -23,7 +23,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"
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:src="@drawable/ic_arrow_right2"
|
android:src="@drawable/ic_arrow_right3"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -54,8 +54,8 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginHorizontal="32dp"
|
android:layout_marginHorizontal="32dp"
|
||||||
android:layout_marginTop="32dp"
|
android:layout_marginTop="50dp"
|
||||||
android:background="@drawable/shape_white_e6_12_corners"
|
android:background="@drawable/shape_white_fb_15_corners2"
|
||||||
android:foreground="?android:attr/selectableItemBackground"
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
android:clipToOutline="true">
|
android:clipToOutline="true">
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:src="@drawable/ic_arrow_right2"
|
android:src="@drawable/ic_arrow_right3"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -85,8 +85,8 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginHorizontal="32dp"
|
android:layout_marginHorizontal="32dp"
|
||||||
android:layout_marginTop="32dp"
|
android:layout_marginTop="50dp"
|
||||||
android:background="@drawable/shape_white_e6_12_corners"
|
android:background="@drawable/shape_white_fb_15_corners2"
|
||||||
android:foreground="?android:attr/selectableItemBackground"
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
android:clipToOutline="true">
|
android:clipToOutline="true">
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:src="@drawable/ic_arrow_right2"
|
android:src="@drawable/ic_arrow_right3"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,14 @@
|
|||||||
android:layout_height="660dp"
|
android:layout_height="660dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:layout_marginHorizontal="12dp"
|
android:layout_marginHorizontal="20dp"
|
||||||
android:overScrollMode="never" />
|
tools:itemCount="26"
|
||||||
|
app:spanCount="4"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
|
tools:listitem="@layout/item_seasoning_weight"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:scrollbarStyle="insideInset"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:overScrollMode="never"
|
android:overScrollMode="never"
|
||||||
tools:listitem="@layout/list_item_dish" />
|
tools:listitem="@layout/list_item_food_list" />
|
||||||
|
|
||||||
<com.scwang.smart.refresh.footer.ClassicsFooter
|
<com.scwang.smart.refresh.footer.ClassicsFooter
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="110dp"
|
||||||
android:layout_marginHorizontal="4dp"
|
android:layout_marginHorizontal="5dp"
|
||||||
android:layout_marginVertical="4dp"
|
android:layout_marginVertical="5dp"
|
||||||
android:background="@drawable/shape_scale_cell"
|
android:paddingHorizontal="10dp"
|
||||||
android:gravity="center_vertical"
|
android:orientation="vertical"
|
||||||
android:orientation="horizontal"
|
android:gravity="center"
|
||||||
android:paddingHorizontal="16dp">
|
android:background="@drawable/shape_white_fb_15_corners2">
|
||||||
|
<!-- android:background="@drawable/shape_scale_cell"-->
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvSeasoningName"
|
android:id="@+id/tvSeasoningName"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
@@ -26,8 +26,10 @@
|
|||||||
android:id="@+id/tvSeasoningWeight"
|
android:id="@+id/tvSeasoningWeight"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginTop="6dp"
|
||||||
android:textColor="@color/dish_green"
|
android:textColor="@color/dish_green"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
android:textSize="26sp"
|
android:textSize="26sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:text="100g" />
|
tools:text="100g" />
|
||||||
|
|||||||
@@ -1,85 +1,109 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.shuwei.dish.match.view.swipereveallayout.SwipeRevealLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/swipeRevealLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="120dp"
|
android:layout_height="120dp"
|
||||||
android:layout_marginStart="30dp"
|
android:layout_marginStart="30dp"
|
||||||
android:layout_marginEnd="30dp"
|
android:layout_marginEnd="30dp"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:background="@drawable/shape_white_fb_15_corners">
|
app:dragEdge="right">
|
||||||
|
|
||||||
<TextView
|
<FrameLayout
|
||||||
android:id="@+id/tvDishName"
|
android:id="@+id/layoutDelete"
|
||||||
android:layout_width="0dp"
|
android:layout_width="160dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="120dp"
|
||||||
android:layout_marginStart="30dp"
|
android:background="@drawable/bg_swipe_delete">
|
||||||
android:layout_marginEnd="30dp"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:includeFontPadding="false"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="30sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/tvDishType"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/tvDishWeight"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
|
||||||
tools:text="雪菜" />
|
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/tvDishType"
|
android:layout_width="48dp"
|
||||||
android:layout_width="0dp"
|
android:layout_height="48dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_gravity="center"
|
||||||
android:layout_marginTop="15dp"
|
android:contentDescription="删除"
|
||||||
android:ellipsize="end"
|
android:src="@drawable/ic_trash_white" />
|
||||||
android:includeFontPadding="false"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="@color/black999"
|
|
||||||
android:textSize="26sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="@id/tvDishName"
|
|
||||||
app:layout_constraintStart_toStartOf="@id/tvDishName"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvDishName"
|
|
||||||
tools:text="主辅材:主材" />
|
|
||||||
|
|
||||||
<ImageView
|
</FrameLayout>
|
||||||
android:id="@+id/ivOperateIcon"
|
|
||||||
android:layout_width="80dp"
|
|
||||||
android:layout_height="60dp"
|
|
||||||
tools:src="@drawable/ic_dish_selected"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/ivClearIcon"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
|
|
||||||
<ImageView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/ivClearIcon"
|
android:id="@+id/clBlock"
|
||||||
android:layout_width="80dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="120dp"
|
||||||
android:src="@drawable/ic_delete"
|
android:background="@drawable/shape_white_fb_15_corners">
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvDishWeight"
|
android:id="@+id/tvDishName"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="30dp"
|
android:layout_marginStart="30dp"
|
||||||
android:textColor="@color/dish_green"
|
android:layout_marginEnd="30dp"
|
||||||
android:textSize="32sp"
|
android:ellipsize="end"
|
||||||
android:textStyle="bold"
|
android:includeFontPadding="false"
|
||||||
android:hint="-"
|
android:maxLines="1"
|
||||||
android:textColorHint="@color/gray_d6"
|
android:textColor="@color/black"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/ivOperateIcon"
|
android:textSize="30sp"
|
||||||
app:layout_constraintEnd_toStartOf="@id/ivOperateIcon"
|
android:textStyle="bold"
|
||||||
app:layout_constraintTop_toTopOf="@id/ivOperateIcon"
|
app:layout_constraintBottom_toTopOf="@+id/tvDishType"
|
||||||
tools:text="375克"
|
app:layout_constraintEnd_toStartOf="@+id/tvDishWeight"
|
||||||
tools:ignore="HardcodedText" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
|
tools:text="雪菜" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
<TextView
|
||||||
|
android:id="@+id/tvDishType"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="@color/black999"
|
||||||
|
android:textSize="26sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/tvDishName"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tvDishName"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvDishName"
|
||||||
|
tools:text="主辅材:主材" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivOperateIcon"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/ivClearIcon"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="ContentDescription"
|
||||||
|
tools:src="@drawable/ic_dish_selected" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivClearIcon"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:src="@drawable/ic_delete"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvDishWeight"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="30dp"
|
||||||
|
android:hint="-"
|
||||||
|
android:textColor="@color/dish_green"
|
||||||
|
android:textColorHint="@color/gray_d6"
|
||||||
|
android:textSize="32sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/ivOperateIcon"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/ivOperateIcon"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/ivOperateIcon"
|
||||||
|
tools:ignore="HardcodedText"
|
||||||
|
tools:text="375克" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</com.shuwei.dish.match.view.swipereveallayout.SwipeRevealLayout>
|
||||||
|
|||||||
+28
-7
@@ -1,19 +1,40 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.shuwei.dish.match.view.swipereveallayout.SwipeRevealLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/swipeRevealLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="15dp"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
android:layout_marginTop="7dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
app:dragEdge="right">
|
||||||
|
|
||||||
|
<!-- 后景层(secondaryView = getChildAt(0)):删除按钮,右对齐 -->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/layoutDelete"
|
||||||
|
android:layout_width="160dp"
|
||||||
|
android:layout_height="150dp"
|
||||||
|
android:background="@drawable/bg_swipe_delete">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:contentDescription="删除"
|
||||||
|
android:src="@drawable/ic_trash_white" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!-- 前景层(mainView = getChildAt(1)):item 主内容 -->
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/clBlock"
|
android:id="@+id/clBlock"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="150dp"
|
android:layout_height="150dp"
|
||||||
android:layout_marginStart="15dp"
|
|
||||||
android:layout_marginTop="7dp"
|
|
||||||
android:layout_marginEnd="15dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:background="@drawable/shape_white_fb_15_corners"
|
android:background="@drawable/shape_white_fb_15_corners"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
android:paddingStart="30dp"
|
android:paddingStart="30dp"
|
||||||
android:paddingEnd="30dp">
|
android:paddingEnd="30dp">
|
||||||
|
|
||||||
@@ -63,4 +84,4 @@
|
|||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</com.shuwei.dish.match.view.swipereveallayout.SwipeRevealLayout>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
android:id="@+id/tvLockRemind"
|
android:id="@+id/tvLockRemind"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginVertical="15dp"
|
||||||
android:text="@string/lock_remind"
|
android:text="@string/lock_remind"
|
||||||
android:textColor="@color/lock_remind"
|
android:textColor="@color/lock_remind"
|
||||||
android:textSize="26sp"
|
android:textSize="26sp"
|
||||||
@@ -22,14 +22,14 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="180dp"
|
android:layout_height="180dp"
|
||||||
android:layout_marginStart="60dp"
|
android:layout_marginStart="60dp"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginVertical="15dp"
|
||||||
android:layout_marginEnd="60dp"
|
android:layout_marginEnd="60dp"
|
||||||
app:cardBackgroundColor="@color/white"
|
app:cardBackgroundColor="@color/white"
|
||||||
app:cardCornerRadius="30dp"
|
app:cardCornerRadius="30dp"
|
||||||
app:cardElevation="0dp"
|
app:cardElevation="0dp"
|
||||||
app:rippleColor="#B0BEC5">
|
app:rippleColor="#B0BEC5">
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
@@ -46,44 +46,48 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="40dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="start|center_vertical"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvModeName"
|
android:id="@+id/tvModeName"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="@string/mode_cook"
|
tools:text="@string/mode_cook"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/ivModeIcon"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/tvModeDesc"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/ivRightIcon"
|
||||||
|
android:layout_marginStart="40dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
android:textColor="@color/mode_name"
|
android:textColor="@color/mode_name"
|
||||||
android:textSize="36sp"
|
android:textSize="36sp"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvModeDesc"
|
android:id="@+id/tvModeDesc"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="16dp"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tvModeName"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/tvModeName"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvModeName"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="@string/cook_mode_desc"
|
tools:text="@string/cook_mode_desc"
|
||||||
android:textColor="@color/mode_desc"
|
android:textColor="@color/mode_desc"
|
||||||
android:textSize="26sp" />
|
android:textSize="26sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ivRightIcon"
|
android:id="@+id/ivRightIcon"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_marginEnd="40dp"
|
android:layout_marginEnd="40dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:src="@drawable/ic_arrow_right"
|
android:src="@drawable/ic_arrow_right"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
</LinearLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<declare-styleable name="SwipeRevealLayout">
|
||||||
|
<attr name="dragEdge">
|
||||||
|
<flag name="left" value="1" />
|
||||||
|
<flag name="right" value="2" />
|
||||||
|
<flag name="top" value="4" />
|
||||||
|
<flag name="bottom" value="8" />
|
||||||
|
</attr>
|
||||||
|
|
||||||
|
<attr name="mode">
|
||||||
|
<enum name="normal" value="0" />
|
||||||
|
<enum name="same_level" value="1" />
|
||||||
|
</attr>
|
||||||
|
|
||||||
|
<attr name="flingVelocity" format="integer" />
|
||||||
|
|
||||||
|
<attr name="minDistRequestDisallowParent" format="dimension" />
|
||||||
|
</declare-styleable>
|
||||||
|
</resources>
|
||||||
Reference in New Issue
Block a user