餐盘柜接口改造
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
package com.sw.platecabinet.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.activity.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.sw.plate.utils.AppUtil
|
||||
import com.sw.platecabinet.GlobalData
|
||||
import com.sw.platecabinet.databinding.ActivityDeviceInitBinding
|
||||
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
||||
import com.sw.platecabinet.utils.QRCodeUtil
|
||||
import com.sw.platecabinet.viewmodel.DeviceViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import kotlin.getValue
|
||||
import com.sw.platecabinet.ext.gone
|
||||
import com.sw.platecabinet.ext.invisible
|
||||
|
||||
/**
|
||||
* 设备初始化界面
|
||||
*/
|
||||
class DeviceInitActivity : BaseActivity<ActivityDeviceInitBinding>() {
|
||||
|
||||
private val deviceViewModel by viewModels<DeviceViewModel>()
|
||||
// private val deviceViewModel by viewModels<DeviceViewModel>()
|
||||
|
||||
override fun inflateViewBinding(): ActivityDeviceInitBinding {
|
||||
return ActivityDeviceInitBinding.inflate(layoutInflater)
|
||||
@@ -32,31 +27,36 @@ class DeviceInitActivity : BaseActivity<ActivityDeviceInitBinding>() {
|
||||
var deviceId = AppUtil.getUDID(this)
|
||||
deviceId = "be154831-3466-3ba2-a2ea-57652c919fed"
|
||||
GlobalData.deviceId = deviceId
|
||||
val isSuccess = deviceViewModel.checkEquipmentInfo()
|
||||
if (isSuccess) {
|
||||
// val isSuccess = deviceViewModel.checkEquipmentInfo()
|
||||
// if (isSuccess) {
|
||||
// goLoginActivity()
|
||||
// return
|
||||
// }
|
||||
// binding.ivQrCode.setImageBitmap(
|
||||
// QRCodeUtil.generateQRCode(
|
||||
// content = GlobalData.deviceId,
|
||||
// size = 200
|
||||
// )
|
||||
// )
|
||||
// binding.btnInit.setOnClickListener {
|
||||
// deviceViewModel.getDeviceToken()
|
||||
// }
|
||||
binding.btnInit.gone()
|
||||
binding.ivQrCode.invisible()
|
||||
binding.root.postDelayed({
|
||||
goLoginActivity()
|
||||
return
|
||||
}
|
||||
binding.ivQrCode.setImageBitmap(
|
||||
QRCodeUtil.generateQRCode(
|
||||
content = GlobalData.deviceId,
|
||||
size = 200
|
||||
)
|
||||
)
|
||||
binding.btnInit.setOnClickListener {
|
||||
deviceViewModel.getDeviceToken()
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
override fun registerDataChange() {
|
||||
super.registerDataChange()
|
||||
lifecycleScope.launch {
|
||||
deviceViewModel.deviceInfoResult.collect { it ->
|
||||
if (it == true) {
|
||||
goLoginActivity()
|
||||
}
|
||||
}
|
||||
}
|
||||
// lifecycleScope.launch {
|
||||
// deviceViewModel.deviceInfoResult.collect { it ->
|
||||
// if (it == true) {
|
||||
// goLoginActivity()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private fun goLoginActivity() {
|
||||
|
||||
Reference in New Issue
Block a user