[shuttle-B1/B2] 弱网增加登陆状态缓存
This commit is contained in:
@@ -6,6 +6,7 @@ package com.mogo.och.common.module.bean.dpmsg
|
||||
|
||||
object BusCacheKey{
|
||||
const val BUS_LINE_CACHE = "bus_line_cache"
|
||||
const val BUS_LOGIN_STATUS_CACHE = "bus_login_status_cache"
|
||||
}
|
||||
|
||||
open class BaseDPMsg(open var type: Int) // 0: 常规 1:确认路线/站点 2:开/关车门 3:结束订单
|
||||
|
||||
@@ -3,11 +3,18 @@ package com.mogo.och.common.module.biz.model
|
||||
import android.annotation.SuppressLint
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.SharedPrefs
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.och.common.module.bean.dpmsg.BusCacheKey
|
||||
import com.mogo.och.common.module.bean.dpmsg.LoginCacheStatus
|
||||
import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean
|
||||
import com.mogo.och.common.module.biz.callback.ILoginCallback
|
||||
import com.mogo.och.common.module.biz.callback.ILoginViewCallback
|
||||
import com.mogo.och.common.module.biz.constant.LoginStatusManager
|
||||
import com.mogo.och.common.module.biz.constant.LoginStatusManager.isLogin
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.data.manager.cache.CacheDataManager
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object OchCommonLoginStatusDefaultModel : OchCommonLoginStatusModel() {
|
||||
@@ -29,6 +36,19 @@ object OchCommonLoginStatusDefaultModel : OchCommonLoginStatusModel() {
|
||||
loginViewCallback?.showLoginDialogFragment()
|
||||
}
|
||||
loginCallback?.loginSuccess(data)
|
||||
|
||||
updateLoginLocalStatus(isLogin())
|
||||
|
||||
}
|
||||
|
||||
private fun updateLoginLocalStatus(isLogin: Boolean) {
|
||||
var loginCacheStatus = LoginCacheStatus(if (isLogin){
|
||||
1
|
||||
}else {
|
||||
0
|
||||
},DateTimeUtil.getCurrentTimeStamp())
|
||||
CacheDataManager.instance.putCacheData(mContext, BusCacheKey.BUS_LOGIN_STATUS_CACHE,
|
||||
GsonUtils.toJson(loginCacheStatus))
|
||||
}
|
||||
|
||||
override fun loginFail(isLogin: Boolean) {
|
||||
@@ -39,6 +59,8 @@ object OchCommonLoginStatusDefaultModel : OchCommonLoginStatusModel() {
|
||||
loginViewCallback?.showLoginDialogFragment()
|
||||
}
|
||||
loginCallback?.loginFail(isLogin)
|
||||
|
||||
updateLoginLocalStatus(isLogin)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,6 +72,20 @@ public class BusRoutesResult {
|
||||
this.writeVersion = writeVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
BusRoutesResult that = (BusRoutesResult) o;
|
||||
return lineId == that.lineId
|
||||
&& lineType == that.lineType
|
||||
&& status == that.status
|
||||
&& sites.equals(that.sites)
|
||||
&& name.equals(that.name)
|
||||
&& writeVersion == that.writeVersion
|
||||
&& runningDur.equals(that.runningDur);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BusRoutesResult{" +
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mogo.och.data.bean
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/3/31
|
||||
*/
|
||||
data class BusTransferData (
|
||||
var loginStatus: Int,
|
||||
var routesResult: BusRoutesResult,
|
||||
)
|
||||
@@ -73,8 +73,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.amapnavi3dmap
|
||||
implementation project(":OCH:mogo-och-common-module")
|
||||
// implementation project(":OCH:mogo-och-data")
|
||||
api project(":OCH:mogo-och-common-module")
|
||||
compileOnly project(":libraries:mogo-map")
|
||||
implementation project(':core:mogo-core-res')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
@@ -67,6 +67,7 @@ import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.data.bean.BusRoutesResult;
|
||||
import com.mogo.och.data.bean.BusStationBean;
|
||||
import com.mogo.och.data.bean.BusTransferData;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -190,7 +191,6 @@ public class BusPassengerModel {
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
}
|
||||
queryDriverByLocalDriver();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,6 +228,13 @@ public class BusPassengerModel {
|
||||
updatePassengerRouteInfo(routesResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = onError ="
|
||||
+ ", sn = " +BusPassengerServiceManager.INSTANCE.getDriverAppSn());
|
||||
queryDriverByLocalDriver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg
|
||||
@@ -244,6 +251,7 @@ public class BusPassengerModel {
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
return;
|
||||
}
|
||||
queryDriverByLocalDriver();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -261,8 +269,10 @@ public class BusPassengerModel {
|
||||
}
|
||||
|
||||
private void updatePassengerRouteInfo(BusRoutesResult result) {
|
||||
if (routesResult == null) return;
|
||||
|
||||
if (result == null){
|
||||
clearLocalRouteResult();
|
||||
return;
|
||||
}
|
||||
if (mRouteLineInfoCallback != null){
|
||||
mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur());
|
||||
mRouteLineInfoCallback.hideNoTaskView();
|
||||
@@ -373,22 +383,20 @@ public class BusPassengerModel {
|
||||
DateTimeUtil.getCurrentTimeStamp(), msg.getMsg(),
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM);
|
||||
}
|
||||
} else if (baseMsg != null && baseMsg.getType() == DPMsgType.TYPE_LOGIN_STATUS.getType()) {
|
||||
LoginCacheStatus msg = GsonUtils.fromJson(new String(byteArray), LoginCacheStatus.class);
|
||||
if (msg != null) {
|
||||
mDriverStatusCallback.changeOperationStatus(msg.getLoginStatus() == 1);
|
||||
}
|
||||
} else if (baseMsg != null && baseMsg.getType() == DPMsgType.TYPE_TASK_DETAILS.getType()) {
|
||||
TaskDetailsMsg msg = GsonUtils.fromJson(new String(byteArray), TaskDetailsMsg.class);
|
||||
|
||||
Logger.d(SceneConstant.M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(msg));
|
||||
if (msg == null || msg.getMsg().isEmpty()) {
|
||||
clearLocalRouteResult();
|
||||
return;
|
||||
}
|
||||
BusRoutesResult result = GsonUtils.fromJson(msg.getMsg(), BusRoutesResult.class);
|
||||
|
||||
if (result != null && result.getWriteVersion() > routesResult.getWriteVersion()) {
|
||||
routesResult = result;
|
||||
BusTransferData result = GsonUtils.fromJson(msg.getMsg(), BusTransferData.class);
|
||||
if (msg != null && mDriverStatusCallback != null) {
|
||||
mDriverStatusCallback.changeOperationStatus(result.getLoginStatus() == 1);
|
||||
}
|
||||
if (result != null) { //已司机端传来的为准
|
||||
routesResult = result.getRoutesResult();
|
||||
updatePassengerRouteInfo(routesResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.bus.passenger.bean;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.och.data.bean.BusRoutesResult;
|
||||
|
||||
/**
|
||||
* 网约车小巴路线接口请求响应结果 返回的是对应司机屏的线路信息
|
||||
@@ -8,13 +9,13 @@ import com.mogo.eagle.core.data.BaseData;
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class PM2RoutesResponse extends BaseData {
|
||||
private PM2RoutesResult data;
|
||||
private BusRoutesResult data;
|
||||
|
||||
public PM2RoutesResult getResult() {
|
||||
public BusRoutesResult getResult() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setResult(PM2RoutesResult data) {
|
||||
public void setResult(BusRoutesResult data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mogo.och.bus.passenger.callback
|
||||
|
||||
import com.mogo.och.bus.passenger.bean.PM2Station
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -13,6 +13,6 @@ interface DrivingInfoCallback {
|
||||
fun updateRemainMT(meters : Long, timeInSecond : Long) // 米,秒
|
||||
fun changeOperationStatus(loginStatus : Boolean)
|
||||
fun showNoTaskView(isTrue : Boolean)
|
||||
fun updateLineStations(stations: MutableList<PM2Station>)
|
||||
fun updateStationsInfo(stations: MutableList<PM2Station>, i: Int, isArrived: Boolean)
|
||||
fun updateLineStations(stations: MutableList<BusStationBean>)
|
||||
fun updateStationsInfo(stations: MutableList<BusStationBean>, i: Int, isArrived: Boolean)
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.mogo.och.bus.passenger.model
|
||||
|
||||
import android.content.Context
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.och.bus.passenger.bean.PM2Station
|
||||
import com.mogo.och.bus.passenger.callback.ADASCallback
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -29,7 +28,7 @@ class PM2ADASModel private constructor() {
|
||||
this.mAdasCallback = adasCallback
|
||||
}
|
||||
|
||||
fun updateHDMapStations(stations: MutableList<PM2Station>){
|
||||
fun updateHDMapStations(stations: MutableList<BusStationBean>){
|
||||
var stationsList = mutableListOf<MutableList<Double>>()
|
||||
for (i in stations.indices){
|
||||
var listLatLng = mutableListOf<Double>() // 0: long 1:lat
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.sendMsgToServer
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
@@ -33,18 +34,19 @@ import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.PM2OperationStatusResponse
|
||||
import com.mogo.och.bus.passenger.bean.PM2RoutesResponse
|
||||
import com.mogo.och.bus.passenger.bean.PM2RoutesResult
|
||||
import com.mogo.och.bus.passenger.bean.PM2Station
|
||||
import com.mogo.och.bus.passenger.callback.AutoPilotStatusCallback
|
||||
import com.mogo.och.bus.passenger.callback.DrivingInfoCallback
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst
|
||||
import com.mogo.och.bus.passenger.network.PM2ModelLoopManager
|
||||
import com.mogo.och.common.module.bean.AppConnectMsg
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.bean.dpmsg.*
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager.pushAppOperationalMsgBox
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.data.bean.BusRoutesResult
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
import com.mogo.och.data.bean.BusTransferData
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import kotlin.math.abs
|
||||
|
||||
@@ -58,11 +60,11 @@ class PM2DrivingModel private constructor() {
|
||||
private var mLocation: MogoLocation? = null
|
||||
|
||||
private var mRoutePoints = mutableListOf<MogoLocation>()
|
||||
private var routesResult: PM2RoutesResult? = null
|
||||
private var routesResult: BusRoutesResult? = null
|
||||
|
||||
private var mCurrentAutoStatus = -1
|
||||
|
||||
var mStations = mutableListOf<PM2Station>()
|
||||
var mStations = mutableListOf<BusStationBean>()
|
||||
private var mNextStationIndex = 0 // A-B要到达站的index
|
||||
private var isGoingToNextStation = false //是否前往下一站过程中
|
||||
|
||||
@@ -94,11 +96,17 @@ class PM2DrivingModel private constructor() {
|
||||
fun init(context : Context){
|
||||
mContext = context
|
||||
initListener()
|
||||
// TODO: 2022/3/31
|
||||
queryDriverByLocalDriver()
|
||||
queryDriverOperationStatus()
|
||||
startOrStopOrderLoop(true)
|
||||
}
|
||||
|
||||
private fun queryDriverByLocalDriver() {
|
||||
//本地去请求司机端
|
||||
val msg = TaskDetailsMsg("")
|
||||
sendMsgToServer(GsonUtils.toJson(msg))
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
//自动驾驶状态监听
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, mAutoPilotStatusListener)
|
||||
@@ -118,6 +126,13 @@ class PM2DrivingModel private constructor() {
|
||||
|
||||
}
|
||||
|
||||
private fun sendMsgToServer(msg: String) {
|
||||
sendMsgToServer(
|
||||
OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(msg).toByteArray()
|
||||
)
|
||||
}
|
||||
|
||||
fun releaseListener(){
|
||||
//自动驾驶状态监听
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
@@ -152,14 +167,43 @@ class PM2DrivingModel private constructor() {
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {//接收司机端发来的信息
|
||||
if (OchCommonConst.BUSINESS_STRING == type){
|
||||
val msg = GsonUtils.fromJson(String(byteArray),AppConnectMsg::class.java) as AppConnectMsg
|
||||
Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedMsg = "+GsonUtils.toJson(msg))
|
||||
if (msg.isPlay){ //播报
|
||||
speakTTS(msg.msg)
|
||||
}
|
||||
if (msg.isViewShow){ //消息盒子显示内容
|
||||
OCHSocketMessageManager.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),msg.msg)
|
||||
val baseMsg = GsonUtils.fromJson(String(byteArray), BaseDPMsg::class.java)
|
||||
Logger.d(
|
||||
SceneConstant.M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(baseMsg)
|
||||
)
|
||||
|
||||
if (baseMsg != null && baseMsg.type == DPMsgType.TYPE_COMMON.type) {
|
||||
val msg = GsonUtils.fromJson(String(byteArray), AppConnectMsg::class.java)
|
||||
|
||||
if (msg != null && msg.isPlay){ //播报
|
||||
speakTTS(msg.msg)
|
||||
}
|
||||
|
||||
if (msg != null && msg.isViewShow) { //消息盒子显示内容
|
||||
pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),msg.msg)
|
||||
}
|
||||
}else if (baseMsg != null && baseMsg.type == DPMsgType.TYPE_TASK_DETAILS.type) {
|
||||
val msg = GsonUtils.fromJson(String(byteArray), TaskDetailsMsg::class.java)
|
||||
Logger.d(
|
||||
SceneConstant.M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(msg)
|
||||
)
|
||||
if (msg == null || msg.msg.isEmpty()) {
|
||||
updateLocalOrder()
|
||||
return
|
||||
}
|
||||
val result = GsonUtils.fromJson(msg.msg, BusTransferData::class.java)
|
||||
mDrivingInfoCallback?.changeOperationStatus(result.loginStatus == 1)
|
||||
if (result != null && result.routesResult == null){
|
||||
updateLocalOrder()
|
||||
}
|
||||
|
||||
if (routesResult == null ||
|
||||
(result != null && result.routesResult.writeVersion > routesResult!!.writeVersion)) {
|
||||
routesResult = result.routesResult
|
||||
updatePassengerRouteInfo(routesResult!!)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,7 +332,8 @@ class PM2DrivingModel private constructor() {
|
||||
} else {
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip))
|
||||
}
|
||||
queryDriverOperationDelay()
|
||||
// queryDriverOperationDelay()
|
||||
queryDriverByLocalDriver()
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
@@ -319,7 +364,15 @@ class PM2DrivingModel private constructor() {
|
||||
return
|
||||
}
|
||||
|
||||
routesResult = data.result
|
||||
if (routesResult != null &&
|
||||
routesResult!!.writeVersion < data.result.writeVersion
|
||||
) {
|
||||
routesResult = data.result
|
||||
}
|
||||
|
||||
if (routesResult == null) {
|
||||
routesResult = data.result
|
||||
}
|
||||
updatePassengerRouteInfo(data.result)
|
||||
}
|
||||
|
||||
@@ -351,19 +404,19 @@ class PM2DrivingModel private constructor() {
|
||||
mDrivingInfoCallback?.showNoTaskView(true)
|
||||
}
|
||||
|
||||
private fun updatePassengerRouteInfo(result: PM2RoutesResult) {
|
||||
private fun updatePassengerRouteInfo(result: BusRoutesResult) {
|
||||
mDrivingInfoCallback?.updateLine(result.name, result.runningDur)
|
||||
if (result.sites != null) {
|
||||
mDrivingInfoCallback?.showNoTaskView(false)
|
||||
val stations: List<PM2Station> = result.sites
|
||||
val stations: List<BusStationBean> = result.sites
|
||||
mStations.clear()
|
||||
mStations.addAll(stations)
|
||||
mDrivingInfoCallback?.updateLineStations(mStations)
|
||||
for (i in stations.indices) {
|
||||
val station: PM2Station = stations[i]
|
||||
val station: BusStationBean = stations[i]
|
||||
if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED
|
||||
&& station.isLeaving && i + 1 < stations.size) {
|
||||
mDrivingInfoCallback?.updateStationsInfo(stations as MutableList<PM2Station>, i + 1, false)
|
||||
mDrivingInfoCallback?.updateStationsInfo(stations as MutableList<BusStationBean>, i + 1, false)
|
||||
if (mNextStationIndex != i + 1) {
|
||||
d(SceneConstant.M_BUS_P+TAG,"och-rotting--start ")
|
||||
mTwoStationsRouts.clear()
|
||||
@@ -376,7 +429,7 @@ class PM2DrivingModel private constructor() {
|
||||
mPreRouteIndex = 0
|
||||
isGoingToNextStation = false
|
||||
startOrStopCalculateRouteInfo(false)
|
||||
mDrivingInfoCallback?.updateStationsInfo(stations as MutableList<PM2Station>, i, true)
|
||||
mDrivingInfoCallback?.updateStationsInfo(stations as MutableList<BusStationBean>, i, true)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -431,7 +484,7 @@ class PM2DrivingModel private constructor() {
|
||||
var lastSumLength = 0f
|
||||
lastSumLength = if (lastPoints.size == 1) { //只是最后一个点,计算当前位置和最后一个点的距离
|
||||
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex >= 0) {
|
||||
val stationNext: PM2Station = mStations[mNextStationIndex]
|
||||
val stationNext: BusStationBean = mStations[mNextStationIndex]
|
||||
CoordinateUtils.calculateLineDistance(
|
||||
stationNext.gcjLon, stationNext.gcjLat,
|
||||
mLocation!!.longitude, mLocation!!.latitude
|
||||
@@ -462,8 +515,8 @@ class PM2DrivingModel private constructor() {
|
||||
if (mStations.size > 1) { //两个站点及以上要计算两个站点间的轨迹路线
|
||||
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex - 1 >= 0) {
|
||||
mTwoStationsRouts.clear()
|
||||
val stationNext: PM2Station = mStations[mNextStationIndex]
|
||||
val stationCur: PM2Station = mStations[mNextStationIndex - 1]
|
||||
val stationNext: BusStationBean = mStations[mNextStationIndex]
|
||||
val stationCur: BusStationBean = mStations[mNextStationIndex - 1]
|
||||
//当前站在轨迹中对应的点
|
||||
val currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(
|
||||
0, mRoutePoints, stationCur.gcjLon, stationCur.gcjLat
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.mogo.och.bus.passenger.callback.DrivingInfoCallback
|
||||
import com.mogo.och.bus.passenger.model.PM2ADASModel
|
||||
import com.mogo.och.bus.passenger.model.PM2DrivingModel
|
||||
import com.mogo.och.bus.passenger.ui.PM2DrivingInfoFragment
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
|
||||
class PM2DrivingPresenter(view: PM2DrivingInfoFragment?) :
|
||||
Presenter<PM2DrivingInfoFragment?>(view), DrivingInfoCallback, AutoPilotStatusCallback {
|
||||
@@ -80,14 +81,14 @@ class PM2DrivingPresenter(view: PM2DrivingInfoFragment?) :
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateLineStations(stations: MutableList<PM2Station>) {
|
||||
override fun updateLineStations(stations: MutableList<BusStationBean>) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
mView?.updateLineStations(stations)
|
||||
}
|
||||
PM2ADASModel.INSTANCE.updateHDMapStations(stations)
|
||||
}
|
||||
|
||||
override fun updateStationsInfo(stations: MutableList<PM2Station>, i: Int, isArrived: Boolean) {
|
||||
override fun updateStationsInfo(stations: MutableList<BusStationBean>, i: Int, isArrived: Boolean) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
mView?.updateStationsInfo(stations,i,isArrived)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.mogo.och.bus.passenger.bean.PM2Station
|
||||
import com.mogo.och.bus.passenger.presenter.PM2DrivingPresenter
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil.*
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
import kotlinx.android.synthetic.m2.p_m2_driving_info_fragment.*
|
||||
import java.lang.ref.WeakReference
|
||||
import kotlin.math.ceil
|
||||
@@ -191,7 +192,7 @@ class PM2DrivingInfoFragment :
|
||||
}
|
||||
}
|
||||
|
||||
fun updateLineStations(stations: MutableList<PM2Station>){
|
||||
fun updateLineStations(stations: MutableList<BusStationBean>){
|
||||
var stationsList = mutableListOf<LatLng>()
|
||||
for (i in stations.indices){
|
||||
val station = stations[i]
|
||||
@@ -204,7 +205,7 @@ class PM2DrivingInfoFragment :
|
||||
}
|
||||
}
|
||||
|
||||
fun updateStationsInfo(stations: MutableList<PM2Station>, i: Int, isArrived: Boolean){
|
||||
fun updateStationsInfo(stations: MutableList<BusStationBean>, i: Int, isArrived: Boolean){
|
||||
if (stations.size == 0) return
|
||||
if (0<= i && i<stations.size){
|
||||
station_name_tv.setTextColor(resources.getColor(R.color.m2_next_tv_color))
|
||||
|
||||
@@ -77,6 +77,7 @@ import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
import com.mogo.och.common.module.voice.VoiceManager;
|
||||
import com.mogo.och.common.module.voice.VoiceNotice;
|
||||
import com.mogo.och.common.module.bean.dpmsg.BusCacheKey;
|
||||
import com.mogo.och.data.bean.BusTransferData;
|
||||
import com.mogo.och.data.manager.cache.CacheDataManager;
|
||||
import com.zhidao.socket.utils.LoginStatusUtil;
|
||||
|
||||
@@ -232,13 +233,7 @@ public class OrderModel {
|
||||
if (OchCommonConst.BUSINESS_STRING == type){
|
||||
BaseDPMsg msg = GsonUtils.fromJson(new String(byteArray),BaseDPMsg.class);
|
||||
if (msg!=null && msg.getType() == DPMsgType.TYPE_TASK_DETAILS.getType()){
|
||||
if (LoginStatusUtil.isLogin()){
|
||||
sendTaskDetailsToClients();
|
||||
}else {// 未登陆
|
||||
sendLoginStatusToClient();
|
||||
}
|
||||
}else if (msg != null && msg.getType() == DPMsgType.TYPE_LOGIN_STATUS.getType()){
|
||||
sendLoginStatusToClient();
|
||||
sendTaskDetailsToClients();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -436,15 +431,29 @@ public class OrderModel {
|
||||
}
|
||||
|
||||
public void queryBusCacheRoutes(){
|
||||
String cacheData = CacheDataManager.Companion.getInstance().getCacheData(mContext,
|
||||
BusCacheKey.BUS_LINE_CACHE);
|
||||
if (cacheData == null || cacheData.isEmpty()){
|
||||
queryBusRoutes();
|
||||
}else {
|
||||
BusRoutesResult data = GsonUtils.fromJson(cacheData,BusRoutesResult.class);
|
||||
getCacheRouteSuccess(data);
|
||||
}
|
||||
|
||||
String loginStr = CacheDataManager.Companion.getInstance().getCacheData(
|
||||
mContext, BusCacheKey.BUS_LOGIN_STATUS_CACHE);
|
||||
if (!loginStr.isEmpty()){
|
||||
LoginCacheStatus status = GsonUtils.fromJson(loginStr,LoginCacheStatus.class);
|
||||
LoginStatusManager.setLoginStatus(status.getLoginStatus());
|
||||
if (status.getUpdateTime() > DateTimeUtil.getTodayStartTime() &&
|
||||
status.getLoginStatus() == 1){//登陆
|
||||
|
||||
String cacheData = CacheDataManager.Companion.getInstance().getCacheData(mContext,
|
||||
BusCacheKey.BUS_LINE_CACHE);
|
||||
|
||||
if (cacheData == null || cacheData.isEmpty()){
|
||||
queryBusRoutes();
|
||||
}else {
|
||||
BusTransferData data = GsonUtils.fromJson(cacheData,BusTransferData.class);
|
||||
getCacheRouteSuccess(data.getRoutesResult());
|
||||
}
|
||||
}else{ // 未登陆
|
||||
CacheDataManager.Companion.getInstance().clearCacheData(mContext,BusCacheKey.BUS_LOGIN_STATUS_CACHE);
|
||||
sendTaskDetailsToClients();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getCacheRouteSuccess(BusRoutesResult data){
|
||||
@@ -485,18 +494,10 @@ public class OrderModel {
|
||||
return;
|
||||
}
|
||||
|
||||
if (busRoutesResult != null && busRoutesResult.getWriteVersion() < data.getResult().getWriteVersion()){
|
||||
if (busRoutesResult == null || busRoutesResult.getWriteVersion() < data.getResult().getWriteVersion()){
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "更新小巴路线数据: " + data);
|
||||
// updateBusStatus(data.getResult());
|
||||
CacheDataManager.Companion.getInstance().putCacheData(mContext,
|
||||
BusCacheKey.BUS_LINE_CACHE,
|
||||
GsonUtils.toJson(data.getResult()));
|
||||
}
|
||||
if (busRoutesResult == null){
|
||||
CacheDataManager.Companion.getInstance().putCacheData(mContext,
|
||||
BusCacheKey.BUS_LINE_CACHE,
|
||||
GsonUtils.toJson(data.getResult()));
|
||||
updateBusStatus(data.getResult());
|
||||
pushCacheTransferData(data.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,10 +683,8 @@ public class OrderModel {
|
||||
sites.set(currentIndex -1,beanPre);
|
||||
}
|
||||
busRoutesResult.setSite(sites);
|
||||
CacheDataManager.Companion.getInstance().putCacheData(mContext, BusCacheKey.BUS_LINE_CACHE,
|
||||
GsonUtils.toJson(busRoutesResult));
|
||||
|
||||
sendTaskDetailsToClients();
|
||||
pushCacheTransferData(busRoutesResult);
|
||||
|
||||
updateBusStatus(busRoutesResult);
|
||||
}
|
||||
@@ -820,23 +819,18 @@ public class OrderModel {
|
||||
}
|
||||
|
||||
private void sendTaskDetailsToClients() {
|
||||
TaskDetailsMsg arrivedMsg = new TaskDetailsMsg(GsonUtils.toJson(busRoutesResult));
|
||||
|
||||
BusTransferData data = new BusTransferData(LoginStatusManager.getLoginStatus().getCode(),busRoutesResult);
|
||||
TaskDetailsMsg msg = new TaskDetailsMsg(GsonUtils.toJson(data));
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg));
|
||||
CallerTelematicManager.INSTANCE.sendMsgToAllClients(OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(arrivedMsg).getBytes());
|
||||
GsonUtils.toJson(msg).getBytes());
|
||||
}
|
||||
|
||||
private void sendLoginStatusToClient() {
|
||||
int status = 0;
|
||||
if (LoginStatusManager.isLogin()){
|
||||
status = 1;
|
||||
}else {
|
||||
status = 0;
|
||||
}
|
||||
LoginCacheStatus arrivedMsg = new LoginCacheStatus(status, DateTimeUtil.getCurrentTimeStamp());
|
||||
|
||||
CallerTelematicManager.INSTANCE.sendMsgToAllClients(OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(arrivedMsg).getBytes());
|
||||
private void pushCacheTransferData(BusRoutesResult result) {
|
||||
BusTransferData data = new BusTransferData(LoginStatusManager.getLoginStatus().getCode(),result);
|
||||
CacheDataManager.Companion.getInstance().putCacheData(mContext,
|
||||
BusCacheKey.BUS_LINE_CACHE,
|
||||
GsonUtils.toJson(data));
|
||||
}
|
||||
|
||||
private void sendArrivedStationToClient(String arriveStation) {
|
||||
@@ -1042,6 +1036,8 @@ public class OrderModel {
|
||||
slidePanelHideCallback.hideSlidePanel();
|
||||
}
|
||||
|
||||
sendTaskDetailsToClients();
|
||||
|
||||
//更新bus路线面板
|
||||
updateBusTaskStatus(stationList);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.mogo.och.common.module.biz.callback.ILoginCallback;
|
||||
import com.mogo.och.common.module.biz.constant.LoginStatusManager;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.voice.VoiceNotice;
|
||||
import com.mogo.och.data.manager.cache.CacheDataManager;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -70,6 +71,8 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
public void onCreate(@NonNull LifecycleOwner owner) {
|
||||
super.onCreate(owner);
|
||||
initModelListener();
|
||||
|
||||
OrderModel.getInstance().queryBusCacheRoutes();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user