diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt index 90322cd39c..a2c8aae031 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt @@ -12,7 +12,7 @@ import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager.step import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.och.bus.passenger.constant.BusPassengerConst -import com.mogo.och.bus.passenger.ui.BusPM2BaseFragment +import com.mogo.och.bus.passenger.ui.PM2BaseFragment /** * 网约车-Bus-乘客端 @@ -23,7 +23,7 @@ import com.mogo.och.bus.passenger.ui.BusPM2BaseFragment class MogoOCHBusPassenger : IMogoOCH, IMogoStatusChangedListener { private var mActivity: FragmentActivity? = null private var mContainerId = 0 - private var mPM2Fragment: BusPM2BaseFragment? = null + private var mPM2Fragment: PM2BaseFragment? = null override fun createCoverage(activity: FragmentActivity, containerId: Int) {} override fun createCoverage(activity: FragmentActivity?, containerId: Int?): Fragment? { mActivity = activity @@ -66,20 +66,19 @@ class MogoOCHBusPassenger : IMogoOCH, IMogoStatusChangedListener { private fun showFragment() { if (mPM2Fragment == null) { d(SceneConstant.M_TAXI_P + TAG, "准备add fragment======") - mPM2Fragment = BusPM2BaseFragment() - mActivity!!.supportFragmentManager.beginTransaction() - .add(mContainerId, mPM2Fragment!!).commitAllowingStateLoss() - return + mPM2Fragment = PM2BaseFragment() + mActivity?.supportFragmentManager?.beginTransaction() + ?.add(mContainerId, mPM2Fragment!!)?.commitAllowingStateLoss() } d(SceneConstant.M_TAXI_P + TAG, "准备show fragment") - mActivity!!.supportFragmentManager.beginTransaction().show(mPM2Fragment!!) - .commitAllowingStateLoss() + mActivity?.supportFragmentManager?.beginTransaction()?.show(mPM2Fragment!!) + ?.commitAllowingStateLoss() } private fun hideFragment() { if (mPM2Fragment != null) { - mActivity!!.supportFragmentManager.beginTransaction().hide(mPM2Fragment!!) - .commitAllowingStateLoss() + mActivity?.supportFragmentManager?.beginTransaction()?.hide(mPM2Fragment!!) + ?.commitAllowingStateLoss() } } diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2OperationStatusResponse.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2OperationStatusResponse.java new file mode 100644 index 0000000000..9869a9e135 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2OperationStatusResponse.java @@ -0,0 +1,21 @@ +package com.mogo.och.bus.passenger.bean; + +import com.mogo.eagle.core.data.BaseData; + +/** + * @author congtaowang + * @since 2021/3/22 + * + * 小巴车运营状态返回参数 + */ +public class PM2OperationStatusResponse extends BaseData { + + public Result data; + + public static class Result { + private String sn; //司机屏sn + private String phone; //司机手机号 + public String plateNumber; //车牌号 + public int driverStatus;//0:已收车,1:已出车 + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2QueryLineRequest.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2QueryLineRequest.java new file mode 100644 index 0000000000..5569730773 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2QueryLineRequest.java @@ -0,0 +1,16 @@ +package com.mogo.och.bus.passenger.bean; + +public +/** + * @author congtaowang + * @since 2021/3/22 + * + * 根据车机行驶线路站点信息 + */ +class PM2QueryLineRequest { + + private String sn; + public PM2QueryLineRequest(String sn) { + this.sn = sn; + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResponse.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResponse.java new file mode 100644 index 0000000000..207b2d7e7d --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResponse.java @@ -0,0 +1,28 @@ +package com.mogo.och.bus.passenger.bean; + +import com.mogo.eagle.core.data.BaseData; + +/** + * 网约车小巴路线接口请求响应结果 返回的是对应司机屏的线路信息 + * + * @author tongchenfei + */ +public class PM2RoutesResponse extends BaseData { + private PM2RoutesResult data; + + public PM2RoutesResult getResult() { + return data; + } + + public void setResult(PM2RoutesResult data) { + this.data = data; + } + + @Override + public String toString() { + return "OchBusRoutesResponse{" + + "data=" + data + + '}'; + } + +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResult.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResult.java new file mode 100644 index 0000000000..1f26b5346d --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResult.java @@ -0,0 +1,79 @@ +package com.mogo.och.bus.passenger.bean; + +import java.util.List; +import java.util.Objects; + +/** + * 网约车小巴路线接口返回接口数据封装 + * + * @author tongchenfei + */ +public class PM2RoutesResult { + private List sites; + private int lineId; + private String name; //线路名称 + private int lineType; //线路类型,0:环形 + private String description; + private int status; + private String runningDur; //运营时间 + private long taskTime; //线路时间班次 + + public List getSites() { + return sites; + } + + public int getLineId() { + return lineId; + } + + public String getName() { + return name; + } + + public int getLineType() { + return lineType; + } + + public String getDescription() { + return description; + } + + public int getStatus() { + return status; + } + + public String getRunningDur() { + return runningDur; + } + + @Override + public String toString() { + return "BusPassengerRoutesResult{" + + "sites=" + sites + + ", lineId=" + lineId + + ", name='" + name + '\'' + + ", lineType=" + lineType + + ", description='" + description + '\'' + + ", status=" + status + + ", runningDur='" + runningDur + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PM2RoutesResult that = (PM2RoutesResult) o; + return lineId == that.lineId + && lineType == that.lineType + && status == that.status + && sites.equals(that.sites) + && name.equals(that.name) + && runningDur.equals(that.runningDur); + } + + @Override + public int hashCode() { + return Objects.hash(sites, lineId, name, lineType, description, status, runningDur); + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2Station.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2Station.java new file mode 100644 index 0000000000..ec903b7e93 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2Station.java @@ -0,0 +1,173 @@ +package com.mogo.och.bus.passenger.bean; + +import java.util.Objects; + +/** + * 单个网约车小巴车站信息 + * + * @author wangmingjun + */ +public class PM2Station { + + private String name; + private String description; + private String cityCode; + private double lon; //高精坐标 + private double lat; //高精坐标 + private double gcjLon; //高德坐标 + private double gcjLat; //高德坐标 + private int businessType; //站点类型,9:taxi,10:bus + private int status; + private int siteId; + private int seq; + private int drivingStatus;//行驶信息,0初始值;1已经过;2当前站;3未到站 + private int ifStop = 1; // 是否需要停靠、1需要、0不需要 // TODO: 2021/10/19 原来站点里有设计是否需要停靠字段,现设计暂无,默认都需要停靠 + private boolean leaving; + + public void setName(String name) { + this.name = name; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public void setBusinessType(int businessType) { + this.businessType = businessType; + } + + public void setStatus(int status) { + this.status = status; + } + + public void setSiteId(int siteId) { + this.siteId = siteId; + } + + public void setSeq(int seq) { + this.seq = seq; + } + + public void setDrivingStatus(int drivingStatus) { + this.drivingStatus = drivingStatus; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String getCityCode() { + return cityCode; + } + + public double getGcjLon() { + return gcjLon; + } + + public double getGcjLat() { + return gcjLat; + } + + public int getBusinessType() { + return businessType; + } + + public int getStatus() { + return status; + } + + public int getSiteId() { + return siteId; + } + + public int getSeq() { + return seq; + } + + public int getDrivingStatus() { + return drivingStatus; + } + + public double getLon() { + return lon; + } + + public double getLat() { + return lat; + } + + public void setIfStop(int ifStop) { + this.ifStop = ifStop; + } + + public int getIfStop() { + return ifStop; + } + + public void setLeaving(boolean leaving) { + this.leaving = leaving; + } + + public boolean isLeaving() { + return leaving; + } + + @Override + public String toString() { + return "OchBusStation{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", cityCode='" + cityCode + '\'' + + ", lon=" + lon + + ", lat=" + lat + + ", businessType=" + businessType + + ", status=" + status + + ", siteId=" + siteId + + ", seq=" + seq + + ", drivingStatus=" + drivingStatus + + ", ifStop=" + ifStop + + ", leaving=" + leaving + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PM2Station that = (PM2Station) o; + return Double.compare(that.lon, lon) == 0 + && Double.compare(that.lat, lat) == 0 + && Double.compare(that.gcjLon, gcjLon) == 0 + && Double.compare(that.gcjLat, gcjLat) == 0 + && businessType == that.businessType + && status == that.status + && siteId == that.siteId + && seq == that.seq + && drivingStatus == that.drivingStatus + && ifStop == that.ifStop + && leaving == that.leaving + && Objects.equals(name, that.name) + && Objects.equals(cityCode, that.cityCode); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, cityCode, lon, lat, gcjLon, gcjLat, businessType, status, siteId, seq, drivingStatus, ifStop, leaving); + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/DrivingInfoCallback.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/DrivingInfoCallback.kt new file mode 100644 index 0000000000..fdd3966fe8 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/DrivingInfoCallback.kt @@ -0,0 +1,14 @@ +package com.mogo.och.bus.passenger.callback + +/** + * @author: wangmingjun + * @date: 2023/2/2 + */ +interface DrivingInfoCallback { + fun updateSpeed(speed: Int) + fun updatePlateNumber(carNum: String) + fun updateLine(lineName: String, lineDuring: String) + fun updateRemainMT(meters : Long, timeInSecond : Long) // 米,秒 + fun changeOperationStatus(loginStatus : Boolean) + fun showNoTaskView(isTrue : Boolean) +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/constant/URLConst.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/constant/URLConst.kt new file mode 100644 index 0000000000..a6a50f6c37 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/constant/URLConst.kt @@ -0,0 +1,42 @@ +package com.mogo.och.bus.passenger.constant + +import com.mogo.commons.debug.DebugConfig +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils + +/** + * Created on 2021/12/6 + */ +class URLConst { + companion object { + // shettle 接驳车域名 + private const val Shettle_BASE_URL_OCH_DEV = "https://och-driver-dev.zhidaozhixing.com" + private const val Shettle_BASE_URL_OCH_QA = "https://och-driver-qa.zhidaozhixing.com" + private const val Shettle_BASE_URL_OCH_RELEASE = "https://och-driver.zhidaozhixing.com" + + private const val BASE_URL_OCH_DEV = "http://tech-dev.zhidaohulian.com" + private const val BASE_URL_OCH_QA = "https://tech-qa.zhidaohulian.com" + private const val BASE_URL_OCH_RELEASE = "https://tech.zhidaohulian.com" + + + @JvmStatic + fun getBaseUrl(): String { + return if(AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)){ + when (DebugConfig.getNetMode()) { + DebugConfig.NET_MODE_DEV, DebugConfig.NET_MODE_DEMO -> Shettle_BASE_URL_OCH_DEV + DebugConfig.NET_MODE_QA -> Shettle_BASE_URL_OCH_QA + DebugConfig.NET_MODE_RELEASE -> Shettle_BASE_URL_OCH_RELEASE + else -> Shettle_BASE_URL_OCH_RELEASE + } + }else{ + when (DebugConfig.getNetMode()) { + DebugConfig.NET_MODE_DEV, DebugConfig.NET_MODE_DEMO -> BASE_URL_OCH_DEV + DebugConfig.NET_MODE_QA -> BASE_URL_OCH_QA + DebugConfig.NET_MODE_RELEASE -> BASE_URL_OCH_RELEASE + else -> BASE_URL_OCH_RELEASE + } + } + + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/BusPM2Model.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/BusPM2Model.kt deleted file mode 100644 index c0c5c1dcc1..0000000000 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/BusPM2Model.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.mogo.och.bus.passenger.model - -import com.mogo.commons.module.status.IMogoStatusChangedListener -import com.mogo.commons.module.status.StatusDescriptor -import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager -import mogo.telematics.pad.MessagePad - -/** - * @author: wangmingjun - * @date: 2023/1/31 - */ -class BusPM2Model private constructor() { - companion object { - val TAG = BusPM2Model::class.java.simpleName - val instance: BusPM2Model by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - BusPM2Model() - } - } - - init { - initListener() - } - - - private fun initListener(){ - CallerAutoPilotStatusListenerManager.addListener(TAG,mAutoPilotStatusListener) - } - - private val mAutoPilotStatusListener : IMoGoAutopilotStatusListener = - object : IMoGoAutopilotStatusListener { - - override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) { - super.onAutopilotArriveAtStation(arrivalNotification) - //todo 自动驾驶到站接口 - } - - override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { - super.onAutopilotStatusResponse(autoPilotStatusInfo) - //todo 自动驾驶状态展示, 注意美化模式下的处理 - } - - } -} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ADASModel.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ADASModel.kt new file mode 100644 index 0000000000..995bcc324f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ADASModel.kt @@ -0,0 +1,8 @@ +package com.mogo.och.bus.passenger.model + +/** + * @author: wangmingjun + * @date: 2023/2/2 + */ +class PM2ADASModel { +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt new file mode 100644 index 0000000000..00f84ecbd1 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt @@ -0,0 +1,358 @@ +package com.mogo.och.bus.passenger.model + +import android.content.Context +import android.os.Handler +import com.mogo.cloud.commons.utils.CoordinateUtils +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr +import com.mogo.eagle.core.utilcode.util.NetworkUtils +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.DrivingInfoCallback +import com.mogo.och.bus.passenger.constant.BusPassengerConst +import com.mogo.och.bus.passenger.network.PM2ModelLoopManager +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil +import mogo.telematics.pad.MessagePad + +/** + * @author: wangmingjun + * @date: 2023/1/31 + */ +class PM2DrivingModel private constructor() { + + private var mContext: Context? = null + private var mLocation: MessagePad.GnssInfo? = null + + private var mRoutePoints = mutableListOf() + private var routesResult: PM2RoutesResult? = null + + var mStations = mutableListOf() + private var mNextStationIndex = 0 // 要到达站的index + + private var mTwoStationsRouts = mutableListOf() + private var mPreRouteIndex = 0 + private var mWipePreIndex = 0 + + private var mDrivingInfoCallback : DrivingInfoCallback? = null //行程信息 + + private val handler = Handler(Handler.Callback { msg -> + if (msg.what == MSG_QUERY_BUS_P_STATION) { + queryDriverOperationStatus() + return@Callback true + } + false + }) + + companion object { + val TAG = PM2DrivingModel::class.java.simpleName + const val MSG_QUERY_BUS_P_STATION = 1001 + val INSTANCE: PM2DrivingModel by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + PM2DrivingModel() + } + } + + fun init(context : Context){ + mContext = context + initListener() + } + + private fun initListener() { + //自动驾驶状态监听 + CallerAutoPilotStatusListenerManager.addListener(TAG, mAutoPilotStatusListener) + + // 定位监听 + CallerChassisLocationGCJ20ListenerManager.addListener(TAG, + mMapLocationListener + ) + } + + fun setDrivingInfoCallback(drivingInfoCallback : DrivingInfoCallback){ + mDrivingInfoCallback = drivingInfoCallback + } + + private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener = + object : IMoGoChassisLocationGCJ02Listener { + override fun onChassisLocationGCJ02(gnssInfo: MessagePad.GnssInfo?) { + if (null == gnssInfo) return + mLocation = gnssInfo + updateSpeed() + } + } + + private fun updateSpeed() { + //todo 传入速度 + mDrivingInfoCallback?.updateSpeed(0) + } + + private val mAutoPilotStatusListener: IMoGoAutopilotStatusListener = + object : IMoGoAutopilotStatusListener { + + override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) { + super.onAutopilotArriveAtStation(arrivalNotification) + //todo 自动驾驶到站接口 + } + + override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { + super.onAutopilotStatusResponse(autoPilotStatusInfo) + //todo 自动驾驶状态展示, 注意美化模式下的处理 + } + + } + + private fun queryDriverOperationDelay() { + handler.sendEmptyMessageDelayed(MSG_QUERY_BUS_P_STATION, + BusPassengerConst.QUERY_BUS_P_STATION_DELAY + ) + } + + private fun queryDriverOperationStatus() { + mContext?.let { + PM2ServiceManager.queryDriverOperationStatus( + it, + object : OchCommonServiceCallback { + override fun onSuccess(data: PM2OperationStatusResponse?) { + if (data?.data == null) return + mDrivingInfoCallback?.changeOperationStatus(data.data.driverStatus === 1) + mDrivingInfoCallback?.updatePlateNumber(data.data.plateNumber) + } + + override fun onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext!!.getString(R.string.network_error_tip)) + } else { + ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip)) + } + queryDriverOperationDelay() + } + + override fun onFail(code: Int, msg: String) { + //延迟3s再次查询 + queryDriverOperationDelay() + } + }) + } + } + + fun queryDriverSiteByCoordinate(){ + mContext?.let { + PM2ServiceManager.queryDriverSiteByCoordinate(it, + object : OchCommonServiceCallback{ + override fun onSuccess(data: PM2RoutesResponse?) { + if (data?.result == null || data.result.sites == null) { + routesResult = null + mNextStationIndex = 0 + startOrStopCalculateRouteInfo(false) + mDrivingInfoCallback?.showNoTaskView(true) + return + } + if (data.result === routesResult) { + return + } + routesResult = data.result + updatePassengerRouteInfo(data.result) + } + + override fun onFail(code: Int, msg: String?) { + if (code == 1003) { + routesResult = null + startOrStopCalculateRouteInfo(false) + queryDriverOperationDelay() + return + } + d(TAG, "queryDriverSiteByCoordinate = %s", msg) + } + + }) + } + } + + private fun updatePassengerRouteInfo(result: PM2RoutesResult) { + mDrivingInfoCallback?.updateLine(result.name, result.runningDur) + mDrivingInfoCallback?.showNoTaskView(false) + if (result.sites != null) { + val stations: List = result.sites + mStations.clear() + mStations.addAll(stations) + for (i in stations.indices) { + val station: PM2Station = stations[i] + if (station.drivingStatus === BusPassengerConst.STATION_STATUS_STOPPED + && station.isLeaving && i + 1 < stations.size) { +// mRouteLineInfoCallback.updateStationsInfo(stations, i + 1, false) + if (mNextStationIndex != i + 1) { + mTwoStationsRouts.clear() + startRemainRouteInfo() + } + mNextStationIndex = i + 1 + return + } else if (station.drivingStatus === BusPassengerConst.STATION_STATUS_STOPPED && !station.isLeaving) { + if (i == 0) { + startOrStopRouteAndWipe(false) + } + mPreRouteIndex = 0 + startOrStopCalculateRouteInfo(false) +// mRouteLineInfoCallback.updateStationsInfo(stations, i, true) + return + } + } + } + + } + + fun loopRouteAndWipe(){ + if (mRoutePoints != null && mRoutePoints.size > 0 && mLocation != null) { + val haveArrivedIndex = CoordinateCalculateRouteUtil + .getArrivedPointIndexNew( + mWipePreIndex, + mRoutePoints, + mLocation + ) + mWipePreIndex = haveArrivedIndex + d(SceneConstant.M_BUS_P + TAG, + "thread = " + Thread.currentThread().name + " haveArrivedIndex== " + haveArrivedIndex + ) +// if (mAutopilotPlanningCallback != null) { +// val routePoints = CoordinateCalculateRouteUtil +// .coordinateConverterLocationToLatLng(mContext, mRoutePoints) +// mAutopilotPlanningCallback.routeResult(routePoints, haveArrivedIndex) +// } + } + } + + private fun startRemainRouteInfo() { + //开启实时计算剩余距离,剩余时间,预计时间 + startOrStopCalculateRouteInfo(true) + } + + fun dynamicCalculateRouteInfo(){ + //计算当前位置和下一站的剩余点集合 + //计算剩余点总里程和时间 + + //计算当前位置和下一站的剩余点集合 + //计算剩余点总里程和时间 + if (mTwoStationsRouts.size == 0) { + calculateTwoStationsRoute() + } + + if (mTwoStationsRouts.size > 0 && mLocation != null) { + val lastPointsMap = CoordinateCalculateRouteUtil + .getRemainPointListByCompareNew(mPreRouteIndex, mTwoStationsRouts, mLocation) + for (index in lastPointsMap.keys) { + mPreRouteIndex = index + break + } + for (lastPoints in lastPointsMap.values) { + d(SceneConstant.M_BUS_P + TAG, "轨迹排查==lastPoints.size() = " + lastPoints.size) + var lastSumLength = 0f + lastSumLength = if (lastPoints.size == 1) { //只是最后一个点,计算当前位置和最后一个点的距离 + if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex >= 0) { + val stationNext: PM2Station = mStations[mNextStationIndex] + CoordinateUtils.calculateLineDistance( + stationNext.gcjLon, stationNext.gcjLat, + mLocation!!.longitude, mLocation!!.latitude + ) + } else { + CoordinateUtils.calculateLineDistance( + lastPoints[0].longitude, lastPoints[0].latitude, + mLocation!!.longitude, mLocation!!.latitude + ) + } + } else { + CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints) + } + val lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 //秒 + d(SceneConstant.M_BUS_P + TAG, "轨迹排查==lastSumLength = $lastSumLength") + mDrivingInfoCallback?.updateRemainMT( + lastSumLength.toLong(), + lastTime.toLong() + ) + } + } + } + + private fun calculateTwoStationsRoute() { + //找出前往站对应的轨迹点,拿出两站点的集合 + d(SceneConstant.M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size) + if (mRoutePoints.size > 0) { + 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 currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew( + 0, mRoutePoints, stationCur.gcjLon, stationCur.gcjLat + ) + //要前往的站在轨迹中对应的点 + val nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew( + currentRouteIndex, + mRoutePoints, + stationNext.gcjLon, + stationNext.gcjLat + ) + + d(SceneConstant.M_BUS_P + TAG, "轨迹排查==currentRouteIndex = " + currentRouteIndex + + ", nextRouteIndex = " + nextRouteIndex) + + if (currentRouteIndex < nextRouteIndex) { //如果找到的next在起点的轨迹前面,直接舍弃这个轨迹,不显示 + mTwoStationsRouts.addAll( + mRoutePoints.subList( + currentRouteIndex, + nextRouteIndex + 1 + ) + ) + } + } + } + if (mTwoStationsRouts.size > 0) { + val sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength( + mTwoStationsRouts + ) + mContext?.let { + SharedPrefsMgr.getInstance(it).putInt( + BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS, + sumLength.toInt() + ) + } + } + } + } + + /** + * 开始轮询计算剩余里程和时间 + * @param isStart + */ + fun startOrStopCalculateRouteInfo(isStart: Boolean) { + d(TAG, "startOrStopCalculateRouteInfo() $isStart") + if (isStart) { + PM2ModelLoopManager.startCalculateRouteInfoLoop() + } else { + mTwoStationsRouts.clear() + PM2ModelLoopManager.stopCalculateRouteInfLoop() + } + } + + /** + * 实时轨迹擦除 + * @param isStart + */ + private fun startOrStopRouteAndWipe(isStart: Boolean) { + if (isStart) { + PM2ModelLoopManager.startOrStopRouteAndWipe() + } else { + mWipePreIndex = 0 + PM2ModelLoopManager.stopOrStopRouteAndWipe() + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ServiceManager.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ServiceManager.kt new file mode 100644 index 0000000000..9195d8b19f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ServiceManager.kt @@ -0,0 +1,70 @@ +package com.mogo.och.bus.passenger.model + +import android.content.Context +import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.bus.passenger.bean.PM2OperationStatusResponse +import com.mogo.och.bus.passenger.bean.PM2QueryLineRequest +import com.mogo.och.bus.passenger.bean.PM2RoutesResponse +import com.mogo.och.bus.passenger.constant.URLConst.Companion.getBaseUrl +import com.mogo.och.bus.passenger.network.PM2ServiceApi +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback +import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl +import com.mogo.och.common.module.biz.network.interceptor.transformTry + +/** + * Created on 2022/3/31 + */ +object PM2ServiceManager { + + private var mBusPassengerServiceApi = + MoGoRetrofitFactory.getInstance(getBaseUrl()).create(PM2ServiceApi::class.java) + + /** + * 获取Bus司机端的sn + * @return + */ + private val driverAppSn: String + get() = getServerToken() + + /** + * 查询绑定行驶的小巴车路线 + * @param context + * @param callback + */ + @JvmStatic + fun queryDriverSiteByCoordinate( + context: Context, callback: OchCommonServiceCallback? + ) { + mBusPassengerServiceApi.queryDriverSiteByCoordinate( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + PM2QueryLineRequest( + driverAppSn + ) + ).transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate")) + + } + + /** + * 查询司机端出车收车状态,以及车牌号 + * @param context + * @param callback + */ + @JvmStatic + fun queryDriverOperationStatus( + context: Context, + callback: OchCommonServiceCallback? + ) { + mBusPassengerServiceApi.queryDriverOperationStatus( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + driverAppSn + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus")) + + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ModelLoopManager.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ModelLoopManager.kt new file mode 100644 index 0000000000..b430a966a1 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ModelLoopManager.kt @@ -0,0 +1,127 @@ +package com.mogo.och.bus.passenger.network + +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.och.bus.passenger.constant.BusPassengerConst +import com.mogo.och.bus.passenger.model.PM2DrivingModel +import io.reactivex.Observable +import io.reactivex.ObservableOnSubscribe +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.CompositeDisposable +import io.reactivex.disposables.Disposable +import io.reactivex.schedulers.Schedulers +import java.util.concurrent.TimeUnit + +/** + * @author: wangmingjun + * @date: 2023/2/1 + */ +object PM2ModelLoopManager { + + private val TAG: String = PM2ModelLoopManager::class.java.getSimpleName() + + private var mQueryLineDisposable: Disposable? = null //心跳轮询 + private var mRouteWipeDisposable: CompositeDisposable? = null //估计擦除 + private var mCalculateRouteDisposable: CompositeDisposable? = null //每隔2s计算一次剩余里程和时间 + + + fun startOrStopRouteAndWipe() { + i(SceneConstant.M_BUS_P + TAG, "startOrStopRouteWipe()") + if (mRouteWipeDisposable != null) return + if (mRouteWipeDisposable == null) { + mRouteWipeDisposable = CompositeDisposable() + } + val disposable = startLoopRouteAndWipe() + .doOnSubscribe { } + .doOnError { } + .delay( + BusPassengerConst.LOOP_LINE_1S, + TimeUnit.MILLISECONDS, + true + ) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。 + .subscribeOn(Schedulers.io()) + .repeat() // repeat保证请求成功后能够重新订阅。 + .retry() // retry保证请求失败后能重新订阅 + .observeOn(AndroidSchedulers.mainThread()) + .subscribe { } + mRouteWipeDisposable!!.add(disposable) + } + + fun stopOrStopRouteAndWipe() { + if (mRouteWipeDisposable != null) { + mRouteWipeDisposable!!.dispose() + mRouteWipeDisposable = null + } + } + + fun startQueryDriverLineLoop() { + if (mQueryLineDisposable != null && !mQueryLineDisposable!!.isDisposed) { + return + } + i(SceneConstant.M_BUS_P + TAG, "startQueryDriverLineLoop()") + mQueryLineDisposable = Observable.interval( + BusPassengerConst.LOOP_DELAY, + BusPassengerConst.LOOP_LINE_2S, TimeUnit.MILLISECONDS + ) + .map { aLong: Long -> aLong + 1 } + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe { aLong: Long? -> + PM2DrivingModel.INSTANCE.queryDriverSiteByCoordinate() + } + } + + fun stopQueryDriverLineLoop() { + if (mQueryLineDisposable != null) { + i(SceneConstant.M_BUS_P + TAG, "stopQueryDriverLineLoop()") + mQueryLineDisposable!!.dispose() + mQueryLineDisposable = null + } + } + + fun startCalculateRouteInfoLoop() { + i(SceneConstant.M_BUS_P + TAG, "startCalculateRouteInfoLoop()") + if (mCalculateRouteDisposable != null) return + if (mCalculateRouteDisposable == null) { + mCalculateRouteDisposable = CompositeDisposable() + } + val disposable = startLoopCalculateRouteInfo() + .doOnSubscribe { } + .doOnError { } + .delay( + BusPassengerConst.LOOP_LINE_2S, + TimeUnit.MILLISECONDS, + true + ) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。 + .subscribeOn(Schedulers.io()) + .repeat() // repeat保证请求成功后能够重新订阅。 + .retry() // retry保证请求失败后能重新订阅 + .observeOn(AndroidSchedulers.mainThread()) + .subscribe { } + mCalculateRouteDisposable!!.add(disposable) + } + + fun stopCalculateRouteInfLoop() { + if (mCalculateRouteDisposable != null) { + i(SceneConstant.M_BUS_P + TAG, "stopCalculateRouteInfLoop()") + mCalculateRouteDisposable!!.dispose() + mCalculateRouteDisposable = null + } + } + + private fun startLoopRouteAndWipe(): Observable { + return Observable.create(ObservableOnSubscribe { emitter -> + if (emitter.isDisposed) return@ObservableOnSubscribe + PM2DrivingModel.INSTANCE.loopRouteAndWipe() + emitter.onComplete() + }) + } + + private fun startLoopCalculateRouteInfo(): Observable { + return Observable.create(ObservableOnSubscribe { emitter -> + if (emitter.isDisposed) return@ObservableOnSubscribe + PM2DrivingModel.INSTANCE.dynamicCalculateRouteInfo() + emitter.onComplete() + }) + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ServiceApi.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ServiceApi.java new file mode 100644 index 0000000000..70866f3d48 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ServiceApi.java @@ -0,0 +1,40 @@ +package com.mogo.och.bus.passenger.network; + +import com.mogo.och.bus.passenger.bean.PM2OperationStatusResponse; +import com.mogo.och.bus.passenger.bean.PM2QueryLineRequest; +import com.mogo.och.bus.passenger.bean.PM2RoutesResponse; + +import io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * Created on 2022/3/31 + * + * Bus乘客端接口定义 + */ +public interface PM2ServiceApi { + /** + * 查询bus司机端绑定路线 + * @return 接口返回数据 + */ + @Headers( {"Content-Type:application/json;charset=UTF-8"} ) + @POST( "/autopilot-car-hailing/line/v2/driver/bus/passenger/lineDataWithDriver/query" ) + Observable queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Body PM2QueryLineRequest request); + + /** + * 查询司机端的登陆状态 + * @param sn + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) +// @GET("/autopilot-car-hailing/car/v2/driver/bus/passenger/takeOrderStatus/query") + @GET("/autopilot-car-hailing/operation/v1/driver/bus/passenger/loginStatus") + Observable queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2DrivingPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2DrivingPresenter.kt deleted file mode 100644 index 08f558571f..0000000000 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2DrivingPresenter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mogo.och.bus.passenger.presenter - -import com.mogo.commons.mvp.Presenter -import com.mogo.och.bus.passenger.ui.BusPM2DrivingInfoFragment - -class BusPM2DrivingPresenter(view: BusPM2DrivingInfoFragment?) : - Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2MapPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2MapPresenter.kt deleted file mode 100644 index aa642b9a76..0000000000 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2MapPresenter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mogo.och.bus.passenger.presenter - -import com.mogo.commons.mvp.Presenter -import com.mogo.och.bus.passenger.ui.BusPM2MapFragment - -class BusPM2MapPresenter(view: BusPM2MapFragment?) : - Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2Presenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2Presenter.kt deleted file mode 100644 index 079421aff5..0000000000 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2Presenter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mogo.och.bus.passenger.presenter - -import com.mogo.commons.mvp.Presenter -import com.mogo.och.bus.passenger.ui.BusPM2BaseFragment - -class BusPM2Presenter(view: BusPM2BaseFragment?) : - Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2VideoPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2VideoPresenter.kt deleted file mode 100644 index 8265ce093f..0000000000 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/BusPM2VideoPresenter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mogo.och.bus.passenger.presenter - -import com.mogo.commons.mvp.Presenter -import com.mogo.och.bus.passenger.ui.video.BusPM2VideoFragment - -class BusPM2VideoPresenter(view: BusPM2VideoFragment?) : - Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2ADASPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2ADASPresenter.kt new file mode 100644 index 0000000000..11f0df02ad --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2ADASPresenter.kt @@ -0,0 +1,7 @@ +package com.mogo.och.bus.passenger.presenter + +import com.mogo.commons.mvp.Presenter +import com.mogo.och.bus.passenger.ui.PM2HPMapFragment + +class PM2ADASPresenter(view: PM2HPMapFragment?) : + Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt new file mode 100644 index 0000000000..617813db9b --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt @@ -0,0 +1,7 @@ +package com.mogo.och.bus.passenger.presenter + +import com.mogo.commons.mvp.Presenter +import com.mogo.och.bus.passenger.ui.PM2DrivingInfoFragment + +class PM2DrivingPresenter(view: PM2DrivingInfoFragment?) : + Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2Presenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2Presenter.kt new file mode 100644 index 0000000000..e55cc469d1 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2Presenter.kt @@ -0,0 +1,7 @@ +package com.mogo.och.bus.passenger.presenter + +import com.mogo.commons.mvp.Presenter +import com.mogo.och.bus.passenger.ui.PM2BaseFragment + +class PM2Presenter(view: PM2BaseFragment?) : + Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt new file mode 100644 index 0000000000..b62879bf4b --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt @@ -0,0 +1,7 @@ +package com.mogo.och.bus.passenger.presenter + +import com.mogo.commons.mvp.Presenter +import com.mogo.och.bus.passenger.ui.video.PM2VideoFragment + +class PM2VideoPresenter(view: PM2VideoFragment?) : + Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2BaseFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2BaseFragment.kt deleted file mode 100644 index b5c3f79b59..0000000000 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2BaseFragment.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.mogo.och.bus.passenger.ui - -import com.mogo.commons.mvp.MvpFragment -import com.mogo.eagle.core.function.call.map.CallerSmpManager.hidePanel -import com.mogo.och.bus.passenger.R -import com.mogo.och.bus.passenger.presenter.BusPM2Presenter - -/** - * @author: wangmingjun - * @date: 2022/4/12 - */ -class BusPM2BaseFragment : - MvpFragment() { - /** - * 改变自动驾驶状态 - * - * @param status 2 - running 1 - enable 2 - disable - */ - override fun getLayoutId(): Int { - return R.layout.bus_p_m2_fragment - } - - override fun getTagName(): String { - return TAG - } - - override fun initViews() { - //隐藏小地图 - hidePanel() - } - - override fun createPresenter(): BusPM2Presenter { - return BusPM2Presenter(this) - } - - companion object { - private val TAG = BusPM2BaseFragment::class.java.simpleName - } -} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2DrivingInfoFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2DrivingInfoFragment.kt deleted file mode 100644 index 452f8f9e29..0000000000 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2DrivingInfoFragment.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.mogo.och.bus.passenger.ui - -import com.mogo.commons.mvp.MvpFragment -import com.mogo.och.bus.passenger.R -import com.mogo.och.bus.passenger.presenter.BusPM2DrivingPresenter - -/** - * @author: wangmingjun - * @date: 2022/4/12 - */ -class BusPM2DrivingInfoFragment : - MvpFragment() { - /** - * 改变自动驾驶状态 - * - * @param status 2 - running 1 - enable 2 - disable - */ - override fun getLayoutId(): Int { - return R.layout.bus_p_m2_driving_info_fragment - } - - override fun getTagName(): String { - return TAG - } - - override fun initViews() { - - } - - override fun createPresenter(): BusPM2DrivingPresenter { - return BusPM2DrivingPresenter(this) - } - - companion object { - private val TAG = BusPM2DrivingInfoFragment::class.java.simpleName - } -} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt new file mode 100644 index 0000000000..c3ab36e417 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt @@ -0,0 +1,60 @@ +package com.mogo.och.bus.passenger.ui + +import com.mogo.commons.mvp.MvpFragment +import com.mogo.eagle.core.function.call.map.CallerSmpManager.hidePanel +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.presenter.PM2Presenter +import com.mogo.och.bus.passenger.ui.video.PM2VideoFragment + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +class PM2BaseFragment : + MvpFragment() { + + private var drivingFragment : PM2DrivingInfoFragment? = null + private var hdMapFragment : PM2HPMapFragment? = null + private var videoFragment : PM2VideoFragment? = null + + override fun getLayoutId(): Int { + return R.layout.p_m2_fragment + } + + override fun getTagName(): String { + return TAG + } + + override fun initViews() { + //隐藏小地图 + hidePanel() + + initFragment(); + } + + /** + * 初始化行程信息,高静地图,宣传 三个fragment + */ + private fun initFragment() { + + if (drivingFragment == null) drivingFragment = PM2DrivingInfoFragment() + childFragmentManager.beginTransaction().add(R.id.driving_fragment, drivingFragment!!) + .show(drivingFragment!!).commitAllowingStateLoss() + + if (hdMapFragment == null) hdMapFragment = PM2HPMapFragment() + childFragmentManager.beginTransaction().add(R.id.hd_map_fragment, hdMapFragment!!) + .show(hdMapFragment!!).commitAllowingStateLoss() + + if (videoFragment == null) videoFragment = PM2VideoFragment() + childFragmentManager.beginTransaction().add(R.id.video_fragment, videoFragment!!) + .show(videoFragment!!).commitAllowingStateLoss() + } + + override fun createPresenter(): PM2Presenter { + return PM2Presenter(this) + } + + companion object { + private val TAG = PM2BaseFragment::class.java.simpleName + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt new file mode 100644 index 0000000000..2718a68851 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt @@ -0,0 +1,61 @@ +package com.mogo.och.bus.passenger.ui + +import android.os.Bundle +import com.mogo.commons.mvp.MvpFragment +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.presenter.PM2DrivingPresenter +import kotlinx.android.synthetic.m2.p_m2_driving_info_fragment.* + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +class PM2DrivingInfoFragment : + MvpFragment() { + /** + * 改变自动驾驶状态 + * + * @param status 2 - running 1 - enable 2 - disable + */ + override fun getLayoutId(): Int { + return R.layout.p_m2_driving_info_fragment + } + + override fun getTagName(): String { + return TAG + } + + override fun initViews() { + //设置红绿灯代理 + // CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView); + } + + override fun initViews(savedInstanceState: Bundle?) { + super.initViews(savedInstanceState) + overMapView.onCreateView(savedInstanceState) + } + + override fun onResume() { + super.onResume() + overMapView.onResume() + } + + override fun onPause() { + super.onPause() + overMapView.onPause() + } + + override fun onDestroy() { + super.onDestroy() + overMapView.onDestroy() + } + + override fun createPresenter(): PM2DrivingPresenter { + return PM2DrivingPresenter(this) + } + + companion object { + private val TAG = PM2DrivingInfoFragment::class.java.simpleName + } + +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2MapFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2HPMapFragment.kt similarity index 55% rename from OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2MapFragment.kt rename to OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2HPMapFragment.kt index e0080f53be..4d5d444963 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/BusPM2MapFragment.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2HPMapFragment.kt @@ -2,21 +2,21 @@ package com.mogo.och.bus.passenger.ui import com.mogo.commons.mvp.MvpFragment import com.mogo.och.bus.passenger.R -import com.mogo.och.bus.passenger.presenter.BusPM2MapPresenter +import com.mogo.och.bus.passenger.presenter.PM2ADASPresenter /** * @author: wangmingjun * @date: 2022/4/12 */ -class BusPM2MapFragment : - MvpFragment() { +class PM2HPMapFragment : + MvpFragment() { /** * 改变自动驾驶状态 * * @param status 2 - running 1 - enable 2 - disable */ override fun getLayoutId(): Int { - return R.layout.bus_p_m2_driving_info_fragment + return R.layout.p_m2_hpmap_fragment } override fun getTagName(): String { @@ -27,11 +27,11 @@ class BusPM2MapFragment : } - override fun createPresenter(): BusPM2MapPresenter { - return BusPM2MapPresenter(this) + override fun createPresenter(): PM2ADASPresenter { + return PM2ADASPresenter(this) } companion object { - private val TAG = BusPM2MapFragment::class.java.simpleName + private val TAG = PM2HPMapFragment::class.java.simpleName } } \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/BusPM2VideoFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt similarity index 55% rename from OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/BusPM2VideoFragment.kt rename to OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt index 52a29724f9..5dc013080d 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/BusPM2VideoFragment.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt @@ -2,21 +2,21 @@ package com.mogo.och.bus.passenger.ui.video import com.mogo.commons.mvp.MvpFragment import com.mogo.och.bus.passenger.R -import com.mogo.och.bus.passenger.presenter.BusPM2VideoPresenter +import com.mogo.och.bus.passenger.presenter.PM2VideoPresenter /** * @author: wangmingjun * @date: 2022/4/12 */ -class BusPM2VideoFragment : - MvpFragment() { +class PM2VideoFragment : + MvpFragment() { /** * 改变自动驾驶状态 * * @param status 2 - running 1 - enable 2 - disable */ override fun getLayoutId(): Int { - return R.layout.bus_p_m2_video_fragment + return R.layout.p_m2_video_fragment } override fun getTagName(): String { @@ -26,11 +26,11 @@ class BusPM2VideoFragment : override fun initViews() { } - override fun createPresenter(): BusPM2VideoPresenter { - return BusPM2VideoPresenter(this) + override fun createPresenter(): PM2VideoPresenter { + return PM2VideoPresenter(this) } companion object { - private val TAG = BusPM2VideoFragment::class.java.simpleName + private val TAG = PM2VideoFragment::class.java.simpleName } } \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2TrafficLightView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2TrafficLightView.kt new file mode 100644 index 0000000000..1eff6c781f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2TrafficLightView.kt @@ -0,0 +1,148 @@ +package com.mogo.och.bus.passenger.ui.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.ImageView +import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bus.passenger.R +import com.mogo.och.common.module.wigets.OCHGradientTextView + +/** + * @author: wangmingjun + * @date: 2023/2/2 + */ +class M2TrafficLightView(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) + : IViewTrafficLight(context, + attrs, defStyleAttr){ + + private var mLightIconIV: ImageView? = null + private var mLightTimeTV: OCHGradientTextView? = null + private var mCurrentLightId = 0 + + private fun init(context: Context) { + LayoutInflater.from(context).inflate(R.layout.p_m2_traffic_light_view, this, true) + mLightIconIV = findViewById(R.id.bus_traffic_light_iv) + mLightTimeTV = findViewById(R.id.bus_traffic_light_time_tv) + } + + /** + * 展示红绿灯预警 + * + * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 + * @param lightSource 1:云端下发;2:自车感知 + */ + override fun showWarningTrafficLight(checkLightId: Int, lightSource: Int) { + super.showWarningTrafficLight(checkLightId, lightSource) + mCurrentLightId = checkLightId + updateTrafficLightIcon(checkLightId) + } + + /** + * 关闭红绿灯预警展示,并重制灯态 + */ + override fun disableWarningTrafficLight() { + super.disableWarningTrafficLight() + UiThreadHandler.post { + mCurrentLightId = 0 + visibility = GONE + } + } + + /** + * @param redNum 红灯倒计时 + * @param yellowNum 黄灯倒计时 + * @param greenNum 绿灯倒计时 + */ + override fun changeCountdownTrafficLightNum(redNum: Int, yellowNum: Int, greenNum: Int) { + super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum) + when (mCurrentLightId) { + 1 -> changeCountdownRed(redNum) + 2 -> changeCountdownYellow(yellowNum) + 3 -> changeCountdownGreen(greenNum) + else -> UiThreadHandler.post { + mLightTimeTV!!.text = "" + } + } + } + + override fun changeCountdownRed(redNum: Int) { + super.changeCountdownRed(redNum) + UiThreadHandler.post { + if (redNum > 0) { + mLightTimeTV!!.setVertrial(true) + mLightTimeTV!!.setmColorList( + intArrayOf( + resources.getColor(R.color.bus_traffic_light_red_color_up), + resources.getColor(R.color.bus_traffic_light_red_color_down) + ) + ) + mLightTimeTV!!.text = redNum.toString() + } else { + mLightTimeTV!!.text = "" + } + } + } + + override fun changeCountdownGreen(greenNum: Int) { + super.changeCountdownGreen(greenNum) + UiThreadHandler.post { + if (greenNum > 0) { + mLightTimeTV!!.setVertrial(true) + mLightTimeTV!!.setmColorList( + intArrayOf( + resources.getColor(R.color.bus_traffic_light_green_color_up), + resources.getColor(R.color.bus_traffic_light_green_color_down) + ) + ) + mLightTimeTV!!.text = greenNum.toString() + } else { + mLightTimeTV!!.text = "" + } + } + } + + override fun changeCountdownYellow(yellowNum: Int) { + super.changeCountdownYellow(yellowNum) + UiThreadHandler.post { + if (yellowNum > 0) { + mLightTimeTV!!.setVertrial(true) + mLightTimeTV!!.setmColorList( + intArrayOf( + resources.getColor(R.color.bus_traffic_light_yellow_color_up), + resources.getColor(R.color.bus_traffic_light_yellow_color_down) + ) + ) + mLightTimeTV!!.text = yellowNum.toString() + } else { + mLightTimeTV!!.text = "" + } + } + } + + /** + * 更新红绿灯icon + * + * @param lightId 0-都是默认,1-红,2-黄,3-绿 + */ + private fun updateTrafficLightIcon(lightId: Int) { + UiThreadHandler.post { + when (lightId) { + 1 -> { + mLightIconIV!!.setBackgroundResource(R.drawable.bus_light_red_nor) + visibility = VISIBLE + } + 2 -> { + mLightIconIV!!.setBackgroundResource(R.drawable.bus_lightyellow_nor) + visibility = VISIBLE + } + 3 -> { + mLightIconIV!!.setBackgroundResource(R.drawable.bus_light_green_nor) + visibility = VISIBLE + } + else -> visibility = GONE + } + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_green_nor.png new file mode 100644 index 0000000000..bc9fed952d Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_green_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_red_nor.png new file mode 100644 index 0000000000..8732508ded Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_red_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_lightyellow_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_lightyellow_nor.png new file mode 100644 index 0000000000..bae01408fd Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_lightyellow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_traffic_light_background.xml b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_traffic_light_background.xml new file mode 100644 index 0000000000..5a27da20e0 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_traffic_light_background.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_green_nor.png new file mode 100644 index 0000000000..bc9fed952d Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_green_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_red_nor.png new file mode 100644 index 0000000000..8732508ded Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_red_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_lightyellow_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_lightyellow_nor.png new file mode 100644 index 0000000000..bae01408fd Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_lightyellow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_map_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_map_fragment.xml deleted file mode 100644 index ebfc0c2abe..0000000000 --- a/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_map_fragment.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_driving_info_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml similarity index 55% rename from OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_driving_info_fragment.xml rename to OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml index 5228bfe171..50ef28ea18 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_driving_info_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml @@ -4,21 +4,19 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + app:layout_constraintTop_toTopOf="parent" + android:text="这是driving" + android:textSize="@dimen/dp_60"/> + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_fragment.xml new file mode 100644 index 0000000000..a1869bd98d --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_fragment.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_video_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml similarity index 57% rename from OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_video_fragment.xml rename to OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml index ebfc0c2abe..5ae8b78566 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_video_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml @@ -5,5 +5,12 @@ android:layout_height="match_parent"> + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_traffic_light_view.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_traffic_light_view.xml new file mode 100644 index 0000000000..fee055a60f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_traffic_light_view.xml @@ -0,0 +1,35 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_fragment.xml similarity index 57% rename from OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_fragment.xml rename to OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_fragment.xml index 1a343bea16..9cbde67745 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/res/layout/bus_p_m2_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_fragment.xml @@ -4,11 +4,14 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml b/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml index 8e63faf83d..141bde1f54 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml +++ b/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml @@ -27,4 +27,12 @@ #33394C63 #2D3E5F #33394C63 + + #FFFFA28B + #FFDA1100 + #FF60FFD3 + #FF006D43 + #FFFFE198 + #FFFF9B00 + #59FFFFFF \ No newline at end of file