|
@@ -19,7 +19,13 @@ import com.hboxs.serialport.sbc.VBoxMessage
|
|
|
import com.hboxs.serialport.sbc.VboxSerialPortSendQueue
|
|
|
import com.hboxs.serialport.sbc.frame.VboxCommand
|
|
|
import com.hboxs.serialport.sbc.frame.VboxWriteCommand
|
|
|
-import com.module.database.room.entity.LocalOrderBean
|
|
|
+import com.quyunshuo.module.home.R
|
|
|
+import com.quyunshuo.module.home.databinding.HomeFragmentMakeBinding
|
|
|
+import com.quyunshuo.module.home.dialog.AgainBuyDialog
|
|
|
+import com.quyunshuo.module.home.enums.LogoEnum
|
|
|
+import com.quyunshuo.module.home.fragment.vm.MakeFragmentVM
|
|
|
+import com.quyunshuo.module.home.utils.SimplePlayerUtil
|
|
|
+import com.quyunshuo.module.home.weight.ProgressView
|
|
|
import com.quyunshuo.sbm10.base.DialogClickListener
|
|
|
import com.quyunshuo.sbm10.base.addressenum.PlcD2StatusEnum
|
|
|
import com.quyunshuo.sbm10.base.ktx.observeLiveData
|
|
@@ -30,17 +36,9 @@ import com.quyunshuo.sbm10.common.constant.Heartbeat
|
|
|
import com.quyunshuo.sbm10.common.constant.MMKVName
|
|
|
import com.quyunshuo.sbm10.common.constant.event.ApiMessageEvent
|
|
|
import com.quyunshuo.sbm10.common.ui.BaseFragment
|
|
|
-import com.quyunshuo.sbm10.common.util.ByteUtils
|
|
|
import com.quyunshuo.sbm10.common.util.LongClickUtils
|
|
|
-import com.quyunshuo.sbm10.common.util.XLogUtil
|
|
|
-import com.quyunshuo.module.home.R
|
|
|
-import com.quyunshuo.module.home.databinding.HomeFragmentMakeBinding
|
|
|
-import com.quyunshuo.module.home.dialog.AgainBuyDialog
|
|
|
-import com.quyunshuo.module.home.enums.LogoEnum
|
|
|
-import com.quyunshuo.module.home.fragment.vm.MakeFragmentVM
|
|
|
-import com.quyunshuo.module.home.utils.SimplePlayerUtil
|
|
|
-import com.quyunshuo.module.home.weight.ProgressView
|
|
|
import com.quyunshuo.sbm10.common.util.UiUtil
|
|
|
+import com.quyunshuo.sbm10.common.util.XLogUtil
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -51,7 +49,6 @@ import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
import java.lang.ref.WeakReference
|
|
|
import java.math.BigDecimal
|
|
|
-import java.util.UUID
|
|
|
|
|
|
/**
|
|
|
* 首页Fragment
|
|
@@ -77,6 +74,7 @@ class MakeFragment : BaseFragment<HomeFragmentMakeBinding, MakeFragmentVM>(), Li
|
|
|
private var isMakePoc = false
|
|
|
private var firstItem: ShoppingCartBean? = null
|
|
|
private var productCount = 1
|
|
|
+ private var additionalText =0
|
|
|
// lateinit var materialHashMap: HashMap<String, String>
|
|
|
// val gson = Gson()
|
|
|
// val type = object : TypeToken<HashMap<String, String>>() {}.type
|
|
@@ -111,8 +109,11 @@ class MakeFragment : BaseFragment<HomeFragmentMakeBinding, MakeFragmentVM>(), Li
|
|
|
if (selectPro != null) {
|
|
|
shoppingCartItems = parseShoppingCartData(selectPro).toMutableList()
|
|
|
saveShoppingCartItems = parseShoppingCartData(selectPro).toMutableList()//保存购物车的清单
|
|
|
-
|
|
|
+ for (i in shoppingCartItems) {
|
|
|
+ additionalText+=i.count
|
|
|
+ }
|
|
|
Log.d(TAG, "制作列表: " + shoppingCartItems)
|
|
|
+ Log.d(TAG, "additionalText: "+additionalText)
|
|
|
// if (shoppingCartItems.isNotEmpty()) {
|
|
|
// mViewModel.startSendMake(shoppingCartItems[0].nameChinese)
|
|
|
// val item = shoppingCartItems[0]
|
|
@@ -160,7 +161,7 @@ class MakeFragment : BaseFragment<HomeFragmentMakeBinding, MakeFragmentVM>(), Li
|
|
|
override fun initObserve() {
|
|
|
observeLiveData(mViewModel.D2Value, ::getD2Value)
|
|
|
observeLiveData(mViewModel.D170Value, ::dataChange)
|
|
|
- lifecycle.addObserver(mViewModel.threadHomeParam)
|
|
|
+ lifecycle.addObserver(mViewModel.threadMakeParam)
|
|
|
lifecycle.addObserver(myHandler)
|
|
|
lifecycle.addObserver(this)
|
|
|
}
|
|
@@ -227,12 +228,13 @@ class MakeFragment : BaseFragment<HomeFragmentMakeBinding, MakeFragmentVM>(), Li
|
|
|
internal class MyHandler(fragment: Fragment) : Handler(), LifecycleObserver {
|
|
|
var mWeakReference: WeakReference<Fragment> = WeakReference(fragment)
|
|
|
var fragment: MakeFragment = mWeakReference.get() as MakeFragment
|
|
|
+ private val TAG = "MakeFragment"
|
|
|
override fun handleMessage(msg: android.os.Message) {
|
|
|
when (msg.what) {
|
|
|
1 -> {
|
|
|
if (fragment.mBinding != null) {
|
|
|
if (fragment.isMakePoc) {
|
|
|
- Log.d("makefragment", "进度条: " + fragment.plannedSpeed)
|
|
|
+ Log.d(TAG, "initProgress: 进度条1 "+ fragment.plannedSpeed)
|
|
|
fragment.plannedSpeed++
|
|
|
fragment.mBinding.progressView.setCurrentProgress(fragment.plannedSpeed)
|
|
|
val sysTime = System.currentTimeMillis() //获取系统时间
|
|
@@ -247,20 +249,23 @@ class MakeFragment : BaseFragment<HomeFragmentMakeBinding, MakeFragmentVM>(), Li
|
|
|
}
|
|
|
if (percentage >= 99) {
|
|
|
fragment.mBinding.tvProgressDescribe.setText(99.toString() + "%")
|
|
|
+ Log.d(TAG, "initProgress: 进度条2 "+ fragment.plannedSpeed)
|
|
|
} else {
|
|
|
+ Log.d(TAG, "initProgress: 进度条4 "+ fragment.plannedSpeed)
|
|
|
fragment.mBinding.tvProgressDescribe.setText(
|
|
|
percentage.toInt().toString() + "%"
|
|
|
)
|
|
|
// }
|
|
|
}
|
|
|
} else {
|
|
|
- Log.d("makefragment", "initProgress: 进度条")
|
|
|
+ Log.d(TAG, "initProgress: 进度条3 "+ fragment.plannedSpeed)
|
|
|
fragment.plannedSpeed = 1
|
|
|
fragment.mBinding.progressView.setCurrentProgress(fragment.plannedSpeed)
|
|
|
fragment.mBinding.tvProgressDescribe.text =
|
|
|
UiUtil.getStringRes(R.string.make_loading)
|
|
|
}
|
|
|
if (fragment.plannedSpeed >= fragment.mBinding.progressView.maxProgress) {
|
|
|
+ Log.d(TAG, "initProgress: 进度条5 "+ fragment.plannedSpeed)
|
|
|
fragment.jobHandler?.cancel()
|
|
|
}
|
|
|
}
|
|
@@ -351,27 +356,15 @@ class MakeFragment : BaseFragment<HomeFragmentMakeBinding, MakeFragmentVM>(), Li
|
|
|
Log.d(TAG, "initProgress: 进度条: true")
|
|
|
if (isProcessing) {
|
|
|
val nameId = UiUtil.getResId(shoppingCartItems[0].nameId, R.string::class.java)
|
|
|
-// if (SpUtils.getBoolean(MMKVName.MATERIAL,true)==true) {
|
|
|
if (shoppingCartItems[0].productNo.equals("E01")) {
|
|
|
Heartbeat.productMaking = "E01"
|
|
|
-// sweet -= 40
|
|
|
} else if (shoppingCartItems[0].productNo.equals("E02")) {
|
|
|
Heartbeat.productMaking = "E02"
|
|
|
-// salty -= 40
|
|
|
}
|
|
|
-// box -= 1
|
|
|
-// val map = hashMapOf(
|
|
|
-// "sweet" to sweet.toString(),
|
|
|
-// "salty" to salty.toString(),
|
|
|
-// "box" to box.toString(),
|
|
|
-// )
|
|
|
-// SpUtils.putString(MMKVName.MATERIAL_VALUE, gson.toJson(map))
|
|
|
-// Log.d(TAG, "cmdHeartbeat: MATERIAL_VALUE2 " + map)
|
|
|
-// }
|
|
|
- val additionalText = saveShoppingCartItems.size // 要添加的字符串
|
|
|
+// val additionalText = saveShoppingCartItems.size // 要添加的字符串
|
|
|
mBinding.tvMakingProduct.text =
|
|
|
getString(nameId) + productCount + "/" + additionalText
|
|
|
- mViewModel.threadHomeParam.stopSendMake()
|
|
|
+ mViewModel.threadMakeParam.stopSendMake()
|
|
|
Log.d(TAG, "startMake:stopMake ")
|
|
|
initProgress()
|
|
|
if (againBuyDialog != null) {
|
|
@@ -395,13 +388,13 @@ class MakeFragment : BaseFragment<HomeFragmentMakeBinding, MakeFragmentVM>(), Li
|
|
|
mBinding.tvProgressDescribe.setText(100.toString() + "%")
|
|
|
if (isShowAgainBuyDialog) {
|
|
|
isShowAgainBuyDialog = false
|
|
|
+ jobHandler?.cancel()
|
|
|
if (shoppingCartItems.isNotEmpty()) {
|
|
|
showAgainBuyDialog(1)
|
|
|
- isMakePoc = false
|
|
|
} else {
|
|
|
showAgainBuyDialog(2)
|
|
|
- isMakePoc = false
|
|
|
}
|
|
|
+ isMakePoc = false
|
|
|
}
|
|
|
}
|
|
|
|