This commit is contained in:
2026-02-06 17:31:52 +08:00
parent a4f3f9527c
commit 873ae95c0b
6 changed files with 58 additions and 45 deletions
@@ -7,6 +7,7 @@ import android.util.Log
import android.view.View import android.view.View
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
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
@@ -23,6 +24,7 @@ import com.shuwei.dish.match.entity.FoodRecord
import com.shuwei.dish.match.net.NetViewModel import com.shuwei.dish.match.net.NetViewModel
import com.shuwei.dish.match.utils.AddressUtil import com.shuwei.dish.match.utils.AddressUtil
import com.shuwei.dish.match.utils.KeyboardUtil 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.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
@@ -167,6 +169,13 @@ class DishSamplingActivity : BaseActivity() {
layoutManager = layoutManager =
LinearLayoutManager(this@DishSamplingActivity, LinearLayoutManager.VERTICAL, false) LinearLayoutManager(this@DishSamplingActivity, LinearLayoutManager.VERTICAL, false)
adapter = dishAdapter 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 { binding.etInputDishType.addOnActionSearchListener {
searchDishType() searchDishType()
@@ -285,6 +294,7 @@ class DishSamplingActivity : BaseActivity() {
relateionType = item.relateionType ?: 0 relateionType = item.relateionType ?: 0
goodsOrRelationCode = item.goodsOrRelationCode goodsOrRelationCode = item.goodsOrRelationCode
isNewDishType = true
// TODO: 待定 // TODO: 待定
//allEdible = item.allEdible //allEdible = item.allEdible
} }
@@ -88,7 +88,14 @@ class PrepareCookActivity : BaseActivity() {
} }
binding.ivWeightAdd.setOnClickListener { addWeight() } binding.ivWeightAdd.setOnClickListener { addWeight() }
binding.tvAddFood.clickWithDebounce { addFood() } binding.tvAddFood.clickWithDebounce { addFood() }
binding.btnCook.clickWithDebounce { goToSubmit() } binding.btnCook.clickWithDebounce {
val count = list.count { it.isSetFinished.not() }
if (count > 0) {
showRemindDialog()
return@clickWithDebounce
}
openSubmitPage()
}
binding.rgCook.setOnCheckedChangeListener { group, checkedId -> binding.rgCook.setOnCheckedChangeListener { group, checkedId ->
if (clickIndex < 0 || clickIndex >= list.size) return@setOnCheckedChangeListener if (clickIndex < 0 || clickIndex >= list.size) return@setOnCheckedChangeListener
val tempType = val tempType =
@@ -146,19 +153,13 @@ class PrepareCookActivity : BaseActivity() {
} }
} }
private fun goToSubmit() { private fun openSubmitPage() {
val count = list.count { it.isSetFinished.not() }
if (count > 0) {
showRemindDialog()
return
}
getGoodsList() getGoodsList()
if (goodsList.isNullOrEmpty()) { if (goodsList.isNullOrEmpty()) {
toast("菜品构成信息未设置") toast("菜品构成信息")
return return
} }
Log.d(TAG, "goToSubmit: goodsList:${goodsList?.toJsonString()}") Log.d(TAG, "goToSubmit: goodsList:${goodsList?.toJsonString()}")
startActivity<SubmitFoodActivity> { startActivity<SubmitFoodActivity> {
putExtra(SubmitFoodActivity.GOODS_LIST, goodsList as Serializable) putExtra(SubmitFoodActivity.GOODS_LIST, goodsList as Serializable)
putExtra(SubmitFoodActivity.FOOD_ITEM, food as Serializable) putExtra(SubmitFoodActivity.FOOD_ITEM, food as Serializable)
@@ -169,8 +170,7 @@ class PrepareCookActivity : BaseActivity() {
if (goodsList == null) { if (goodsList == null) {
goodsList = mutableListOf() goodsList = mutableListOf()
} }
list.forEach { list.filter { it.isSetFinished }.forEach {
if (it.isSetFinished) {
goodsList?.add(CookFoodGoodsEntity().apply { goodsList?.add(CookFoodGoodsEntity().apply {
foodId = food!!.foodId foodId = food!!.foodId
goodsId = it.goodsId goodsId = it.goodsId
@@ -183,7 +183,6 @@ class PrepareCookActivity : BaseActivity() {
}) })
} }
} }
}
private fun showRemindDialog() { private fun showRemindDialog() {
val remindBinding = LayoutFoodRemindBinding.inflate(layoutInflater) val remindBinding = LayoutFoodRemindBinding.inflate(layoutInflater)
@@ -193,7 +192,7 @@ class PrepareCookActivity : BaseActivity() {
rightText = "确认无误" rightText = "确认无误"
onLeftClick = { dismiss() } onLeftClick = { dismiss() }
onRightClick = { onRightClick = {
goToSubmit() openSubmitPage()
dismiss() dismiss()
} }
onDismiss = { hideStatusBar() } onDismiss = { hideStatusBar() }
@@ -274,10 +273,12 @@ class PrepareCookActivity : BaseActivity() {
materialType = "主材" materialType = "主材"
binding.rgCook.check(R.id.rbDishTypeFirst) binding.rgCook.check(R.id.rbDishTypeFirst)
} }
2 -> { 2 -> {
materialType = "辅材" materialType = "辅材"
binding.rgCook.check(R.id.rbDishTypeSecond) binding.rgCook.check(R.id.rbDishTypeSecond)
} }
else -> { else -> {
materialType = "" materialType = ""
binding.rgCook.clearCheck() binding.rgCook.clearCheck()
@@ -87,9 +87,9 @@ class SamplingListActivity : BaseActivity() {
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent) super.onNewIntent(intent)
val isCooking = intent?.getBooleanExtra(IS_COOKING, false) ?: false // val isCooking = intent?.getBooleanExtra(IS_COOKING, false) ?: false
//toast("isCooking=$isCooking") // //toast("isCooking=$isCooking")
refreshPage(isCooking) // refreshPage(isCooking)
} }
@Deprecated("Deprecated in Java") @Deprecated("Deprecated in Java")
@@ -168,20 +168,20 @@ class SelectDishActivity : BaseActivity() {
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent) super.onNewIntent(intent)
runCatching { // runCatching {
val isCooking = intent?.getBooleanExtra(IS_COOKING, false) ?: false // val isCooking = intent?.getBooleanExtra(IS_COOKING, false) ?: false
val lastDinnerType = intent?.getStringExtra(DINNER_TYPE) ?: "0" // val lastDinnerType = intent?.getStringExtra(DINNER_TYPE) ?: "0"
if (lastDinnerType == "1" || lastDinnerType == "2" || lastDinnerType == "3") { // if (lastDinnerType == "1" || lastDinnerType == "2" || lastDinnerType == "3") {
fragmentList[lastDinnerType.toInt() - 1].getDishList(1, lastDinnerType) // fragmentList[lastDinnerType.toInt() - 1].getDishList(1, lastDinnerType)
} // }
when (lastDinnerType) { // when (lastDinnerType) {
"1" -> binding.dishRadioGroup.check(R.id.rbBreakfast) // "1" -> binding.dishRadioGroup.check(R.id.rbBreakfast)
"2" -> binding.dishRadioGroup.check(R.id.rbLunch) // "2" -> binding.dishRadioGroup.check(R.id.rbLunch)
"3" -> binding.dishRadioGroup.check(R.id.rbDinner) // "3" -> binding.dishRadioGroup.check(R.id.rbDinner)
} // }
}.onFailure { // }.onFailure {
it.printStackTrace() // it.printStackTrace()
} // }
} }
@Deprecated("Deprecated in Java") @Deprecated("Deprecated in Java")
@@ -262,11 +262,12 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvDishPartList" android:id="@+id/rvDishPartList"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginBottom="20dp" android:layout_marginBottom="20dp"
android:overScrollMode="never" android:overScrollMode="never"
tools:itemCount="3" tools:itemCount="3"
tools:listitem="@layout/list_item_dish_cook" /> tools:listitem="@layout/list_item_dish_cook"
android:scrollbars="vertical"/>
</LinearLayout> </LinearLayout>
@@ -253,11 +253,12 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvDishPartList" android:id="@+id/rvDishPartList"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginBottom="20dp" android:layout_marginBottom="20dp"
android:overScrollMode="never" android:overScrollMode="never"
tools:itemCount="3" tools:itemCount="3"
tools:listitem="@layout/list_item_dish_cook" /> tools:listitem="@layout/list_item_dish_cook"
android:scrollbars="vertical" />
</LinearLayout> </LinearLayout>