Bladeren bron

fix 扫码界面不需要倒计时

RobinTan1024 4 jaren geleden
bovenliggende
commit
5b4b42a443

+ 1 - 0
app/src/main/java/com/doverfuelingsolutions/issp/fusion/FusionManager.kt

@@ -258,6 +258,7 @@ object FusionManager : LifecycleObserver, OnFdcClientStateChangedListener,
     suspend fun lockOrder(pumpId: Int, transactionNo: String, token: Int, lock: Boolean) = suspendCoroutine<DFSResult<Boolean>> {
         ThreadUtil.io {
             val callback = OnFdcServiceResponseReceivedListener { _, response ->
+                DFSLog.v("Fusion.lockOrder($pumpId, $transactionNo, $token, $lock)", response)
                 if (response != null && response.singleDeviceClass != null && response.overallResult.equals("Success", true)) {
                     it.resume(DFSResult.success(true))
                 } else {

+ 9 - 0
app/src/main/java/com/doverfuelingsolutions/issp/view/widget/FragmentToolbar.kt

@@ -24,12 +24,18 @@ class FragmentToolbar(context: Context, attrs: AttributeSet) : FrameLayout(conte
             field = value
             buttonHome.visibility = if (value) VISIBLE else GONE
         }
+    private var isTimerVisible = true
+        set(value) {
+            field = value
+            countdownNum.visibility = if (value) VISIBLE else GONE
+        }
     private var title = ""
         set(value) {
             field = value
             materialToolbar.title = value
         }
 
+    // 当值=-1时,不启用倒计时
     private val countdownTime: Int
     private var currentTime: Int = 0
     private var countdownAutoStart = true
@@ -53,6 +59,7 @@ class FragmentToolbar(context: Context, attrs: AttributeSet) : FrameLayout(conte
 
         buttonBack.setOnClickListener { backHandler?.invoke() }
         buttonHome.setOnClickListener { homeHandler?.invoke() }
+        if (countdownTime <= 0) isTimerVisible = false
     }
 
     private lateinit var job: Job
@@ -68,6 +75,8 @@ class FragmentToolbar(context: Context, attrs: AttributeSet) : FrameLayout(conte
     }
 
     private fun startCountdown(repeatTime: Int = countdownTime) {
+        if (repeatTime <= 0) return
+
         stopCountdown()
         job = GlobalScope.launch(Dispatchers.Main) {
             repeat(repeatTime) {