liugl
2020-11-02 080f7b67b66121fb325d777ba066112a2ace6825
app/src/main/java/com/okgoincar/base/MoneyBroadCastReceiver.kt
@@ -3,7 +3,6 @@
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
import android.os.Handler
import android.os.Looper
import cn.sinata.xldutils.netstatus.NetUtils
@@ -18,6 +17,27 @@
import org.greenrobot.eventbus.EventBus
import java.lang.Exception
/***
 * 为了支持本页面所需的 MyApplication.currentOrderId 所以在订单列表获取处,订单页面,设置了这个常量的值
 *
 * 1:接单后 重车时无网
 *  --车载屏无反应
 *  缓存 订单开始状态
 *  来网后空车时 --》 查看是否有进行中id,是否有缓存
 *
 *
 * 2:接单后 空车时无网
 *
 *
 *
 * 3:接单后 正常状态
 *
 *
 *
 * 4:接单后 都没有网络
 *
 *
 */
class MoneyBroadCastReceiver : BroadcastReceiver() {
    override fun onReceive(contexts: Context?, intent: Intent?) {
        if (intent == null && contexts == null) {
@@ -67,7 +87,6 @@
                }
            }
        }
        fun callOver(contexts: Context, travelFee: Double) {
            if (MyApplication.currentOrderId.isEmpty()) {
@@ -124,11 +143,13 @@
                if (bean.startTime <= 0L) {
                    if (NetUtils.isNetworkConnected(MyApplication.getInstance())){
                        CacheKey.saveLocalOrderBeanNull()
                        MyApplication.currentOrderId = ""
                        callEndOrder(contexts,bean.money)
                    }
                }else{
                    if (NetUtils.isNetworkConnected(MyApplication.getInstance())){
                        CacheKey.saveLocalOrderBeanNull()
                        MyApplication.currentOrderId = ""
                        val map = getMapByAny()
                        map["orderId"] = bean.orderId
                        map["orderType"] = bean.orderType