唐浩
2020-07-18 6bed01a5a2468cd389d4e483dbeb90347b701310
app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt
@@ -3,10 +3,35 @@
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Handler
import android.os.Looper
import cn.sinata.xldutils.utils.toast
import com.okgoincar.slab.SlabLoginActivity
import com.okgoincar.utils.Cache.CacheUtil
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.startActivity
class MainBroadCastReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        toast("获取的action="+intent!!.getStringExtra("isLogin"))
        toast("收到广播1")
        Handler(Looper.getMainLooper()).post {
            val b = intent!!.getBooleanExtra("isLogin",false)
            val driverName = intent!!.getStringExtra("driverName")
            toast("司机名字=$driverName")
            if (!b){
                toast("LED退出登录")
                CacheUtil.get().clear()
                EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP))
//                context?.startActivity<SlabLoginActivity>()
            }else{
                toast("开始登录")
            }
            var heay = intent.getBooleanExtra("isHeavy",false)
            toast("获取的网约=$heay") //顶灯
            var price = intent.getDoubleExtra("price",0.0)
            toast("收到的显示价格$price")
            var mileage = intent.getDoubleExtra("mileage",0.0)
            toast("收到的显示价格$mileage")
        }
    }
}