From bd6a8872438a35d47821c5d5da7fe149e5fed3ab Mon Sep 17 00:00:00 2001
From: lmw <125975490@qq.com>
Date: 星期三, 21 六月 2023 09:53:36 +0800
Subject: [PATCH] 处理收不到广播

---
 app/src/main/java/com/okgoincar/base/MoneyBroadCastReceiver.kt |   53 +++++++++++++++++++++++++++++------------------------
 1 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/app/src/main/java/com/okgoincar/base/MoneyBroadCastReceiver.kt b/app/src/main/java/com/okgoincar/base/MoneyBroadCastReceiver.kt
index d0070f1..e98e7f3 100644
--- a/app/src/main/java/com/okgoincar/base/MoneyBroadCastReceiver.kt
+++ b/app/src/main/java/com/okgoincar/base/MoneyBroadCastReceiver.kt
@@ -5,6 +5,7 @@
 import android.content.Intent
 import android.os.Handler
 import android.os.Looper
+import android.util.Log
 import cn.sinata.xldutils.netstatus.NetUtils
 import cn.sinata.xldutils.utils.toast
 import com.google.gson.Gson
@@ -40,35 +41,39 @@
  */
 class MoneyBroadCastReceiver : BroadcastReceiver() {
     override fun onReceive(contexts: Context?, intent: Intent?) {
-//        if (intent == null && contexts == null) {
-//            toast("内容获取为空,广播接收消息错误")
-//            return
-//        }
-//        try {
-//            Handler(Looper.getMainLooper()).post {
-//                when (intent!!.action) {
-//                    "wisdom.intent.action.ledLight" -> {
-//                        val isHeavy = intent!!.getBooleanExtra("isHeavy", true)
-//                        if (isHeavy) {
-//                            callStatue(contexts!!, 5) //代表让订单到进行中
-//                        }
-//                    }
-//
-//                    "wisdom.intent.action.priceDevice" -> {
-//                        var price = intent.getDoubleExtra("price", 0.0) //计价器价格,单位为元
-//                        var mileage = intent.getDoubleExtra("mileage", 0.0) //里程,单位为km
-//                        callOver(contexts!!, price)
-//                    }
-//                }
-//            }
-//        } catch (e: Exception) {
-//
-//        }
+        MyApplication.upLog("收到广播,Action:${intent?.action}")
+        Log.e("MoneyBroadCastReceiver","收到广播,Action:${intent?.action}")
+        if (intent == null && contexts == null) {
+            toast("内容获取为空,广播接收消息错误")
+            return
+        }
+        try {
+            Handler(Looper.getMainLooper()).post {
+                when (intent!!.action) {
+                    "wisdom.intent.action.ledLight" -> {
+                        val isHeavy = intent!!.getBooleanExtra("isHeavy", true)
+                        MyApplication.upLog("广播内容,isHeavy:${isHeavy}")
+                        if (isHeavy) {
+                            callStatue(contexts!!, 5) //代表让订单到进行中
+                        }
+                    }
+
+                    "wisdom.intent.action.priceDevice" -> {
+                        var price = intent.getDoubleExtra("price", 0.0) //计价器价格,单位为元
+                        var mileage = intent.getDoubleExtra("mileage", 0.0) //里程,单位为km
+                        callOver(contexts!!, price)
+                    }
+                }
+            }
+        } catch (e: Exception) {
+
+        }
     }
 
     companion object {
         fun callStatue(contexts: Context, i: Int) {
             if (MyApplication.currentOrderId.isEmpty()) {
+                MyApplication.upLog("callStatue error,MyApplication.currentOrderId.isEmpty")
                 toast("没有进行中的订单,无法开始")
                 return
             }

--
Gitblit v1.7.1