From a7446bb3995654a2c5e8d03589111d16e0734bfc Mon Sep 17 00:00:00 2001 From: liugl <liugl@sinata.cn> Date: 星期五, 31 七月 2020 15:04:08 +0800 Subject: [PATCH] 7.31 --- app/src/main/java/com/okgoincar/base/MyApplication.kt | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletions(-) diff --git a/app/src/main/java/com/okgoincar/base/MyApplication.kt b/app/src/main/java/com/okgoincar/base/MyApplication.kt index dd2a56c..1524573 100644 --- a/app/src/main/java/com/okgoincar/base/MyApplication.kt +++ b/app/src/main/java/com/okgoincar/base/MyApplication.kt @@ -23,11 +23,17 @@ import com.okgoincar.netUtls.getUserId import com.okgoincar.utils.Cache.CacheKey import com.google.gson.Gson +import com.okgoincar.base.gpsnav.util.TTSController import com.okgoincar.bean.CarLocationBean +import com.okgoincar.bean.OrderResData import com.okgoincar.bean.OrderSimpleData import com.okgoincar.bean.websocket.HeartBean import com.okgoincar.netUtls.Api import com.okgoincar.slab.MySlabBaseActivity +import com.okgoincar.slab.SlabLoginActivity +import com.okgoincar.utils.Cache.CacheUtil +import org.greenrobot.eventbus.EventBus +import org.jetbrains.anko.startActivity import org.jetbrains.anko.toast import org.json.JSONObject import java.security.SecureRandom @@ -93,6 +99,12 @@ Const.SOCKET_METHOD.OK -> { testReceiveNum++ } + Const.SOCKET_METHOD.OFFLINE -> { + CacheUtil.get().clear() + NettyClient.getInstance().stopService() + EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP)) + toast("您的账号已在其他平台登录") + } Const.SOCKET_METHOD.ORDER_STATUS -> { val orderSimpleData = Gson().fromJson( @@ -106,7 +118,9 @@ val act = activities[activities.size - 1] (act as MySlabBaseActivity).showOrder( orderSimpleData.orderId.toString(), - orderSimpleData.orderType.toString() + orderSimpleData.orderType.toString(), + orderSimpleData.time, + 1 ) } if (orderSimpleData.status == 2) { @@ -116,6 +130,21 @@ orderSimpleData.orderType.toString() ) } + } + + Const.SOCKET_METHOD.REASSIGN -> { + val orderSimpleData = + Gson().fromJson( + data, + OrderResData::class.java + ) + val act = activities[activities.size - 1] + (act as MySlabBaseActivity).showOrder( + orderSimpleData.orderId.toString(), + orderSimpleData.orderType.toString(), + 30, + 2 + ) } } } else { @@ -268,12 +297,21 @@ companion object { private const val TAG = "MyApplication" public var appContext: MyApplication? = null + protected var mTtsManager: TTSController? = null fun getInstance(): MyApplication? { if (appContext == null) { appContext = MyApplication() } return appContext + } + + fun getTTsManager():TTSController{ + if (mTtsManager == null){ + mTtsManager = TTSController.getInstance(getInstance()) + mTtsManager?.init() + } + return mTtsManager!! } fun getLocation(): AMapLocation { @@ -339,6 +377,7 @@ } private val activities = ArrayList<Activity?>() + private var showNum = 0 override fun onActivityPaused(activity: Activity?) { } @@ -347,6 +386,7 @@ } override fun onActivityStarted(activity: Activity?) { + showNum++ } override fun onActivityDestroyed(activity: Activity?) { @@ -357,6 +397,13 @@ } override fun onActivityStopped(activity: Activity?) { + showNum-- + Handler(Looper.getMainLooper()).postDelayed({ + if (showNum == 0){ + getTTsManager().setVideoText("OK出行司机已置于后台,可能会导致听单异常,里程计费差异,请勿切换。") + } + },600) + } override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) { -- Gitblit v1.7.1