秤精度精确到0.1g并接口因此产生的数据问题;提交页面初始不为0优化;设置页面引起页面跳转问题优化;初始化版本使用项目versionCode
This commit is contained in:
@@ -8,6 +8,7 @@ import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.LineHeightSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.util.Log
|
||||
import android.util.SparseArray
|
||||
import android.util.SparseIntArray
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
@@ -39,6 +40,7 @@ import com.shuwei.dish.match.databinding.ActivityDeviceConfigBinding
|
||||
import com.shuwei.dish.match.dialog.BottomDialog2
|
||||
import com.shuwei.dish.match.utils.SpTool
|
||||
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
||||
import com.shuwei.dish.match.utils.ext.gone
|
||||
|
||||
class DeviceConfigActivity : BaseActivity() {
|
||||
|
||||
@@ -65,7 +67,8 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
private lateinit var appViewModel: AppViewModel
|
||||
|
||||
private var cookMode: Int = 0
|
||||
private val weightArray = SparseIntArray()
|
||||
// private val weightArray = SparseIntArray()
|
||||
private val weightArray = SparseArray<Double>()
|
||||
private val addressArray = AddressUtil.getWeighAddressArray()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -80,14 +83,14 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
}, titleAction = {
|
||||
it.text = "设备配置"
|
||||
}, rightIconActon = {
|
||||
it.visible()
|
||||
it.alpha = 0.0F
|
||||
it.setImageResource(R.drawable.ic_setting)
|
||||
it.setOnClickListener {
|
||||
detector.setOnDelayedMultiClickListener(it) {
|
||||
defaultDataSettingDialog()
|
||||
}
|
||||
}
|
||||
it.gone()
|
||||
// it.alpha = 0.0F
|
||||
// it.setImageResource(R.drawable.ic_setting)
|
||||
// it.setOnClickListener {_->
|
||||
// detector.setOnDelayedMultiClickListener(it) {
|
||||
// defaultDataSettingDialog()
|
||||
// }
|
||||
// }
|
||||
})
|
||||
|
||||
loadQualitySpan(isEnable = false)
|
||||
@@ -193,9 +196,11 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
appViewModel.clearAllSeasoning {
|
||||
record?.list?.forEach { entity ->
|
||||
entity.useWeight = weightArray[addressArray[entity.sort]].toDouble()
|
||||
appViewModel.saveSeasoning(entity) {}
|
||||
appViewModel.saveSeasoning(entity) {
|
||||
updateGridData(entity)
|
||||
}
|
||||
}
|
||||
loadSeasoning()
|
||||
// loadSeasoning()
|
||||
}
|
||||
}.onFailure { it.printStackTrace() }
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.shuwei.dish.match.viewmodel.factory.AppFactory
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.toString
|
||||
|
||||
class InitActivity : BaseActivity() {
|
||||
companion object {
|
||||
@@ -47,35 +48,36 @@ class InitActivity : BaseActivity() {
|
||||
|
||||
// setHeaderBackground(isHomePage = true)
|
||||
setHeaderBgVisible(false)
|
||||
BaseApp.appVersion = AppUtil.getAppVersionCode(this).toString()
|
||||
|
||||
// // 获取 ANDROID_ID
|
||||
// var androidId =
|
||||
// Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
// androidId = "39a7abdd06b3c7ab"
|
||||
// BaseApp.deviceId = androidId
|
||||
// SpTool.put(SpTool.DEVICE_ID, androidId)
|
||||
// BaseApp.configUrl = UrlConfig.BASE_URL
|
||||
// BaseApp.canteenId = "0"
|
||||
// 获取 ANDROID_ID
|
||||
var androidId =
|
||||
Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
androidId = "39a7abdd06b3c7ab"
|
||||
BaseApp.deviceId = androidId
|
||||
SpTool.put(SpTool.DEVICE_ID, androidId)
|
||||
BaseApp.configUrl = UrlConfig.BASE_URL
|
||||
BaseApp.canteenId = "0"
|
||||
// // TODO: 以上保存deviceId用于临时使用,后续改为下面注释方式
|
||||
|
||||
var deviceId = AppUtil.getUDID(this)
|
||||
Log.d(TAG, "onCreate: deviceId=$deviceId")
|
||||
// deviceId = "39a7abdd06b3c7ab"
|
||||
deviceId = "3ea47dc0-3cf0-3c2f-909c-265a9a65572e"
|
||||
// deviceId = "6ce7cd59-b875-38b2-b73d-88a570be3212"
|
||||
|
||||
BaseApp.deviceId = deviceId
|
||||
|
||||
SpTool.put(SpTool.DEVICE_ID, deviceId)
|
||||
val deviceConfigCache = SpTool.getString(SpTool.DEVICE_CONFIG_CACHE)
|
||||
val checkResult = checkConfigData(deviceConfigCache)
|
||||
if (checkResult.not()) {
|
||||
binding.ivQrCode.visible()
|
||||
binding.btnInit.visible()
|
||||
//进行初始化操作
|
||||
initConfig()
|
||||
return
|
||||
}
|
||||
// var deviceId = AppUtil.getUDID(this)
|
||||
// Log.d(TAG, "onCreate: deviceId=$deviceId")
|
||||
//// deviceId = "39a7abdd06b3c7ab"
|
||||
// deviceId = "3ea47dc0-3cf0-3c2f-909c-265a9a65572e"
|
||||
//// deviceId = "6ce7cd59-b875-38b2-b73d-88a570be3212"
|
||||
//
|
||||
// BaseApp.deviceId = deviceId
|
||||
//
|
||||
// SpTool.put(SpTool.DEVICE_ID, deviceId)
|
||||
// val deviceConfigCache = SpTool.getString(SpTool.DEVICE_CONFIG_CACHE)
|
||||
// val checkResult = checkConfigData(deviceConfigCache)
|
||||
// if (checkResult.not()) {
|
||||
// binding.ivQrCode.visible()
|
||||
// binding.btnInit.visible()
|
||||
// //进行初始化操作
|
||||
// initConfig()
|
||||
// return
|
||||
// }
|
||||
|
||||
binding.ivQrCode.invisible()
|
||||
binding.btnInit.invisible()
|
||||
@@ -118,21 +120,21 @@ class InitActivity : BaseActivity() {
|
||||
if (it.isEmpty()) {
|
||||
//无调料信息打开采样历史列表页面,点击设置配置调料信息
|
||||
startActivity<SamplingListActivity>()
|
||||
finish()
|
||||
// finish()
|
||||
return@loadSeasoning
|
||||
}
|
||||
appViewModel.countCookFood(cookMode = 1) { count ->
|
||||
if (count > 0) {
|
||||
//有烹饪中数据打开采样历史列表页面
|
||||
startActivity<SamplingListActivity>()
|
||||
finish()
|
||||
// finish()
|
||||
return@countCookFood
|
||||
}
|
||||
//无烹饪数据打开新增采样页面
|
||||
startActivity<DishSamplingActivity> {
|
||||
putExtra(DishSamplingActivity.PAGE_FROM, DishSamplingActivity.HOME)
|
||||
}
|
||||
finish()
|
||||
// finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,7 +171,7 @@ class InitActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun getDeviceConfig() {
|
||||
val tokenUrl = "${UrlConfig.DEVICE_TOKEN}?qrcodeId=${BaseApp.deviceId}&appVersion=1"
|
||||
val tokenUrl = "${UrlConfig.DEVICE_TOKEN}?qrcodeId=${BaseApp.deviceId}&appVersion=${BaseApp.appVersion}"
|
||||
HttpUtil.get(url = tokenUrl, doSuccess = { token ->
|
||||
Log.d(TAG, "initConfig: $token")
|
||||
getConfig(token.toString())
|
||||
@@ -178,7 +180,7 @@ class InitActivity : BaseActivity() {
|
||||
})
|
||||
}
|
||||
private fun getConfig(token: String) {
|
||||
val deviceConfigUrl = "${UrlConfig.DEVICE_CONFIG}?equipmentCode=${BaseApp.deviceId}&&appVersion=1"
|
||||
val deviceConfigUrl = "${UrlConfig.DEVICE_CONFIG}?equipmentCode=${BaseApp.deviceId}&&appVersion=${BaseApp.appVersion}"
|
||||
HttpUtil.get(url = deviceConfigUrl, header = mutableMapOf(
|
||||
"X-Access-Token" to token
|
||||
), doSuccess = {
|
||||
@@ -192,7 +194,7 @@ class InitActivity : BaseActivity() {
|
||||
HttpUtil.loopGetToken = true
|
||||
SpTool.put(SpTool.DEVICE_CONFIG_CACHE, data)
|
||||
startActivity<HomeActivity>()
|
||||
finish()
|
||||
// finish()
|
||||
}, doFailure = { code, msg ->
|
||||
Log.d(TAG, "getDeviceConfig: $code,$msg")
|
||||
toast("初始化设备失败,请稍后重试,code=${code},msg=${msg}")
|
||||
@@ -217,4 +219,9 @@ class InitActivity : BaseActivity() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
WeightUtil.stopContinuousRead()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -96,8 +96,8 @@ class PrepareCookActivity : BaseActivity() {
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
val weight = binding.tvDishPartWeight.text.toString().toInt()
|
||||
if (weight <= 0) {
|
||||
val weight = binding.tvDishPartWeight.text.toString().toDouble()
|
||||
if (weight <= 0.toDouble()) {
|
||||
toast("食材用量需要大于0")
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
@@ -394,4 +394,15 @@ class SamplingListActivity : BaseActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
private var isVisible = false
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
isVisible = true
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
isVisible = false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -191,4 +191,15 @@ class SelectDishActivity : BaseActivity() {
|
||||
// dialog = toast("不允许返回操作")
|
||||
}
|
||||
|
||||
private var isVisible = false
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
isVisible = true
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
isVisible = false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ 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
|
||||
import com.shuwei.dish.match.utils.ext.roundedOneDecimalPlace
|
||||
import com.shuwei.dish.match.utils.ext.startActivity
|
||||
import com.shuwei.dish.match.utils.ext.toJsonString
|
||||
import com.shuwei.dish.match.utils.ext.toType
|
||||
@@ -151,9 +152,7 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
|
||||
private val firstGoodsArray by lazy {
|
||||
SparseArray<Int>()
|
||||
}
|
||||
private val firstGoodsArray = SparseArray<Double>()
|
||||
|
||||
private fun addViewListener() {
|
||||
addWeightListener()
|
||||
@@ -187,7 +186,7 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
return@addWeightListener
|
||||
}
|
||||
var realUseWeight = firstWeight - weight
|
||||
realUseWeight = if (realUseWeight > 0) realUseWeight else 0
|
||||
realUseWeight = if (realUseWeight > 0) realUseWeight else 0.0
|
||||
seasoningArray.put(address, realUseWeight.toDouble())
|
||||
|
||||
// refreshSeasoningWeight()
|
||||
@@ -195,7 +194,7 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
val item = seasoningItems.firstOrNull { address == addressArray[it.sort]}
|
||||
item?.let {
|
||||
val lastWeight = seasoningArray.get(address) ?: 0.toDouble()
|
||||
it.useWeight = lastWeight + getCookingSeasoning(address)
|
||||
it.useWeight = (lastWeight + getCookingSeasoning(address)).roundedOneDecimalPlace()
|
||||
updateGridData(it)
|
||||
}
|
||||
})
|
||||
@@ -419,7 +418,10 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
seasoningItems.clear()
|
||||
seasoningItems.addAll(list)
|
||||
initConfigData()
|
||||
setGridData(list)
|
||||
// setGridData(list)
|
||||
list.forEach { entity ->
|
||||
updateGridData(entity.also { it.useWeight = 0.0 })
|
||||
}
|
||||
seasoningCookingItems = seasoningItems.map { it.copy() }.toList()
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ class DishListFragment : BaseFragment<FragmentDishListBinding>() {
|
||||
DishShowAdapter(list = list).apply {
|
||||
isStateViewEnable = true
|
||||
setOnDebouncedItemClick { adapter, view, position ->
|
||||
if (isAdded.not() || isVisible.not()) {
|
||||
return@setOnDebouncedItemClick
|
||||
}
|
||||
activity.judgeDeviceConfig {
|
||||
onItemClick(position)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user