From 798c626c95adfa29cdb54a04a55e0776f3b22c80 Mon Sep 17 00:00:00 2001
From: liugl <liugl@sinata.cn>
Date: 星期五, 04 九月 2020 15:47:34 +0800
Subject: [PATCH] 8.31
---
app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt b/app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt
index 9aab87f..ff3fc27 100644
--- a/app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt
+++ b/app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt
@@ -23,49 +23,57 @@
class MainBroadCastReceiver : BroadcastReceiver() {
override fun onReceive(contexts: Context?, intent: Intent?) {
- if (intent == null){
+ if (intent == null) {
toast("内容获取为空,广播接收消息错误")
return
}
try {
Handler(Looper.getMainLooper()).post {
- val b = intent.getBooleanExtra("isLogin",true)
- toast("isLogin=$b")
- if (!b){
+ val b = intent.getBooleanExtra("isLogin", true)
+ if (!b) {
+ loginOut(contexts)
CacheUtil.get().clear()
EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP))
- }else{
- if (getToken().isNullOrEmpty()){
+ } else {
+ if (getToken().isNullOrEmpty()) {
Handler(Looper.getMainLooper()).post {
- toast("开始登录")
+// toast("开始登录")
}
var driverCertificate = intent.getStringExtra("driverCertificate")
- if (driverCertificate == null){
- toast("身份证获取失败")
- }else{
- if (contexts == null){
- toast("上下文为空,使用全局跳转")
- toLoginActivity(MyApplication.getInstance(),driverCertificate)
- }else{
- toLoginActivity(MyApplication.getInstance(),driverCertificate)
+ if (driverCertificate == null) {
+// toast("身份证获取失败")
+ } else {
+ if (contexts == null) {
+// toast("上下文为空,使用全局跳转")
+ toLoginActivity(MyApplication.getInstance(), driverCertificate)
+ } else {
+ toLoginActivity(MyApplication.getInstance(), driverCertificate)
}
}
}
}
}
- }catch (e:Exception){
+ } catch (e: Exception) {
}
}
- private fun toLoginActivity(context: Context?,driverCertificate: String?) {
+ private fun loginOut(context: Context?) {
+ var map = getMapByAny()
+ callNet(context!!, Api.loginOut, map) {
+ toast("Ok退签")
+ }
+ }
+
+ private fun toLoginActivity(context: Context?, driverCertificate: String?) {
var map = getMapByAny()
map["identification"] = driverCertificate
- callNet(context!!,Api.loginByIdentification,map){
+ callNet(context!!, Api.loginByIdentification, map) {
toast("登录成功")
var bean = Gson().fromJson<LoginBean>(it, LoginBean::class.java)
+ CacheKey.putKeyStr("identification", driverCertificate!!)
CacheKey.putKeyStr("appid", bean.data.appid)
CacheKey.putKeyStr("token", bean.data.token)
CacheKey.putKeyStr("userId", bean.data.id.toString())
@@ -73,7 +81,7 @@
CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
Handler(Looper.getMainLooper()).post {
var intent = Intent()
- intent.setClass(context,SlabMainActivity::class.java)
+ intent.setClass(context, SlabMainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
}
--
Gitblit v1.7.1