修改熟重和菜品称重位置,菜品构成删除未生效问题优化
This commit is contained in:
@@ -7,6 +7,7 @@ import android.text.style.AbsoluteSizeSpan
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.LineHeightSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.util.SparseIntArray
|
||||
import android.widget.TextView
|
||||
import androidx.core.graphics.toColorInt
|
||||
import androidx.core.view.forEach
|
||||
@@ -18,7 +19,7 @@ import com.shuwei.dish.match.db.AppRepository
|
||||
import com.shuwei.dish.match.dialog.CommonDialog
|
||||
import com.shuwei.dish.match.entity.SeasoningEntity
|
||||
import com.shuwei.dish.match.entity.ResetReasoningRecord
|
||||
import com.shuwei.dish.match.utils.DataUtil
|
||||
import com.shuwei.dish.match.utils.AddressUtil
|
||||
import com.shuwei.dish.match.utils.JsonAssetsLoader
|
||||
import com.shuwei.dish.match.utils.MultiClickDetector
|
||||
import com.shuwei.dish.match.utils.WeightUtil
|
||||
@@ -61,6 +62,8 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
private lateinit var appViewModel: AppViewModel
|
||||
|
||||
private var cookMode: Int = 0
|
||||
private val weightArray = SparseIntArray()
|
||||
private val addressArray = AddressUtil.getWeighAddressArray()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -126,11 +129,21 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
}
|
||||
addGridItemListener()
|
||||
loadSeasoning()
|
||||
addWeighListener()
|
||||
}
|
||||
|
||||
private fun addWeighListener() {
|
||||
WeightUtil.addWeightListener { address, state, weight ->
|
||||
weightArray.put(address, weight)
|
||||
val item = seasoningItems.firstOrNull { address == addressArray[it.sort]}
|
||||
item?.useWeight = weight.toDouble()
|
||||
setGridData(seasoningItems)
|
||||
}
|
||||
}
|
||||
|
||||
private var seasoningItems = mutableListOf<SeasoningEntity>()
|
||||
private fun addGridItemListener() {
|
||||
binding.include.root.forEach { child->
|
||||
binding.include.root.forEach { child ->
|
||||
(child as TextView).run {
|
||||
clickWithDebounce {
|
||||
val sort = tag.toString().toInt()
|
||||
@@ -167,8 +180,7 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
this,
|
||||
"default_seasoning_list.json"
|
||||
)
|
||||
val addressArray = DataUtil.getWeighAddressArray()
|
||||
val weightArray = WeightUtil.weightArray
|
||||
// val weightArray = WeightUtil.weightArray
|
||||
appViewModel.clearAllSeasoning {
|
||||
record?.list?.forEach { entity ->
|
||||
entity.useWeight = weightArray[addressArray[entity.sort]].toDouble()
|
||||
@@ -197,8 +209,8 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun initConfigData() {
|
||||
repeat(12) {num->
|
||||
val firstOne = seasoningItems.firstOrNull {it.sort == num}
|
||||
repeat(12) { num ->
|
||||
val firstOne = seasoningItems.firstOrNull { it.sort == num }
|
||||
if (firstOne == null) {
|
||||
seasoningItems.add(SeasoningEntity().also { it.sort = num })
|
||||
}
|
||||
@@ -215,7 +227,7 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun clickGridItem(sort: Int, entity: SeasoningEntity) {
|
||||
val currentAddress = DataUtil.getWeighAddressArray().get(sort)
|
||||
val currentAddress = AddressUtil.getWeighAddressArray().get(sort)
|
||||
// val seasoningEntity = list.first{it.sort == sort}
|
||||
BottomDialog2(
|
||||
weighIndex = sort,
|
||||
|
||||
@@ -20,6 +20,7 @@ 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.utils.AddressUtil
|
||||
import com.shuwei.dish.match.utils.KeyboardUtil
|
||||
import com.shuwei.dish.match.utils.WeightUtil
|
||||
import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
||||
@@ -140,9 +141,11 @@ class DishSamplingActivity : BaseActivity() {
|
||||
|
||||
private val dishAdapter by lazy {
|
||||
DishPartAdapter(list).apply {
|
||||
addOnItemChildClickListener(R.id.ivOperateIcon) { _, _, positon ->
|
||||
addOnItemChildClickListener(R.id.ivOperateIcon) { _, _, position ->
|
||||
//删除操作
|
||||
removeAt(positon)
|
||||
list.removeAt(position)
|
||||
notifyItemRemoved(position)
|
||||
notifyItemRangeChanged(position, list.size - position)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +181,7 @@ class DishSamplingActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
binding.ivWeightClear.setOnClickListener {
|
||||
Weigher.tareTwo(2)
|
||||
Weigher.tareTwo(AddressUtil.ONE)
|
||||
}
|
||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
||||
import com.shuwei.dish.match.entity.FoodRecord
|
||||
import com.shuwei.dish.match.http.HttpUtil
|
||||
import com.shuwei.dish.match.http.UrlConfig
|
||||
import com.shuwei.dish.match.utils.AddressUtil
|
||||
import com.shuwei.dish.match.utils.SwipeCallback
|
||||
import com.shuwei.dish.match.utils.WeightUtil
|
||||
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
||||
@@ -74,7 +75,7 @@ class PrepareCookActivity : BaseActivity() {
|
||||
|
||||
private fun addViewClickListener() {
|
||||
binding.ivWeightClear.setOnClickListener {
|
||||
Weigher.tareTwo(2)
|
||||
Weigher.tareTwo(AddressUtil.ONE)
|
||||
}
|
||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||
@@ -272,7 +273,10 @@ class PrepareCookActivity : BaseActivity() {
|
||||
dishPartAdapter.notifyItemChanged(position)
|
||||
return@SwipeCallback
|
||||
}
|
||||
dishPartAdapter.removeAt(position)
|
||||
// dishPartAdapter.removeAt(position)
|
||||
list.removeAt(position)
|
||||
dishPartAdapter.notifyItemRemoved(position)
|
||||
dishPartAdapter.notifyItemRangeChanged(position, list.size - position)
|
||||
toast("已删除")
|
||||
})
|
||||
itemTouchHelper.attachToRecyclerView(this)
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
//
|
||||
// private fun addViewListener() {
|
||||
// addWeightListener()
|
||||
// binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(1) }
|
||||
// binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(AddressUtil.TWO) }
|
||||
//
|
||||
// binding.btnCook.clickWithDebounce {
|
||||
// cook()
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.shuwei.dish.match.entity.FoodRecord
|
||||
import com.shuwei.dish.match.entity.SeasoningEntity
|
||||
import com.shuwei.dish.match.http.HttpUtil
|
||||
import com.shuwei.dish.match.http.UrlConfig
|
||||
import com.shuwei.dish.match.utils.DataUtil
|
||||
import com.shuwei.dish.match.utils.AddressUtil
|
||||
import com.shuwei.dish.match.utils.WeightUtil
|
||||
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
||||
import com.shuwei.dish.match.utils.ext.gone
|
||||
@@ -150,7 +150,7 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
|
||||
private fun addViewListener() {
|
||||
addWeightListener()
|
||||
binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(1) }
|
||||
binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(AddressUtil.TWO) }
|
||||
|
||||
binding.btnCook.clickWithDebounce {
|
||||
cook()
|
||||
@@ -232,7 +232,7 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private val weightRelateArray by lazy {
|
||||
DataUtil.getWeighAddressArray()
|
||||
AddressUtil.getWeighAddressArray()
|
||||
}
|
||||
|
||||
// private fun prepareData(acton: () -> Unit) {
|
||||
|
||||
Reference in New Issue
Block a user