Commit fdd59633 authored by tongzifang's avatar tongzifang

fix

parent f472763d
...@@ -30,7 +30,7 @@ android { ...@@ -30,7 +30,7 @@ android {
} }
} }
group 'com.qmai.android.zqtoolkit' group 'com.qmai.android.zqtoolkit'
version '1.2.6.2' version '1.2.8'
gradlePublish { gradlePublish {
......
...@@ -33,13 +33,6 @@ object ScaleHub : ScaleBaseAction { ...@@ -33,13 +33,6 @@ object ScaleHub : ScaleBaseAction {
private var connectJob: CoroutineScope? = null private var connectJob: CoroutineScope? = null
private var weightJob: CoroutineScope? = null private var weightJob: CoroutineScope? = null
private var scaleKit: ScaleBaseKit? = null private var scaleKit: ScaleBaseKit? = null
// private val scaleKit by lazy {
// when {
// ScaleChecker.isZQ() -> ZqScaleKit
// ScaleChecker.isSUNMI() -> SunmiScaleKit
// else -> AclasScaleKit
// }
// }
fun manualInitSDK(scale: ScaleInfo) { fun manualInitSDK(scale: ScaleInfo) {
...@@ -64,32 +57,30 @@ object ScaleHub : ScaleBaseAction { ...@@ -64,32 +57,30 @@ object ScaleHub : ScaleBaseAction {
/** /**
* fix-20220707 中崎称类型多,通过DeviceUtils.getModel()判断不准确,现改为默认中崎 * fix-20220707 中崎称类型多,通过DeviceUtils.getModel()判断不准确,现改为默认中崎
*/ */
private fun tryInitSDK( private fun tryInitSDK2B(
scale: ScaleInfo scale: ScaleInfo
) { ) {
if (scaleKit == null) { scaleKit = when (scale.brand?.brand) {
scaleKit = when { QmScaleBrand.ZQEB.brand -> ZqScaleKit
QmScaleBrand.SUNMI.brand -> SunmiScaleKit
QmScaleBrand.ACLAS.brand -> AclasScaleKit
else -> when {
ScaleChecker.isSUNMI_S2CC() -> SunmiScaleKit ScaleChecker.isSUNMI_S2CC() -> SunmiScaleKit
ScaleChecker.isAclas() -> AclasScaleKit ScaleChecker.isAclas() -> AclasScaleKit
else -> when (scale.brand?.brand) { else -> null
QmScaleBrand.ZQEB.brand -> ZqScaleKit
QmScaleBrand.SUNMI.brand -> SunmiScaleKit
QmScaleBrand.ACLAS.brand -> AclasScaleKit
else -> null
}
}
//通过tryInitSDK连接的,如果没有指定brand和model,赋一个默认的,若连接成功会被保存
if (scaleKit != null && (scale.brand == null || scale.model == null)) {
scale.brand = QmScaleBrand.find(scaleKit)
scale.model = QmScaleModel.find(scaleKit)
} }
} }
//通过tryInitSDK连接的,如果没有指定brand和model,赋一个默认的,若连接成功会被保存
if (scaleKit != null && (scale.brand == null || scale.model == null)) {
scale.brand = QmScaleBrand.find(scaleKit)
scale.model = QmScaleModel.find(scaleKit)
}
} }
override fun connect(cxt: Context?, scale: ScaleInfo) { override fun connect(cxt: Context?, scale: ScaleInfo) {
when (scale.appType) { when (scale.appType) {
SHOP_ASSITANT_2C -> tryInitSDK2C() SHOP_ASSITANT_2C -> tryInitSDK2C()
SHOP_ASSITANT_2B -> tryInitSDK(scale) SHOP_ASSITANT_2B -> tryInitSDK2B(scale)
} }
scaleKit?.run { scaleKit?.run {
if (connectJob == null) { if (connectJob == null) {
...@@ -107,9 +98,11 @@ object ScaleHub : ScaleBaseAction { ...@@ -107,9 +98,11 @@ object ScaleHub : ScaleBaseAction {
collectScaleInfo() collectScaleInfo()
} }
connectJob?.launch(context = Dispatchers.IO) { connectJob?.launch(context = Dispatchers.IO) {
scaleKit?.connect(cxt, scale)
collectConnectData() collectConnectData()
} }
connectJob?.launch(context = Dispatchers.IO) {
scaleKit?.connect(cxt, scale)
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment