[M2] M2 opt

This commit is contained in:
wangmingjun
2023-02-02 19:57:28 +08:00
parent 8814f5947d
commit 94c45440e2
43 changed files with 1404 additions and 199 deletions

View File

@@ -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()
}
}

View File

@@ -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:已出车
}
}

View File

@@ -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;
}
}

View File

@@ -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 +
'}';
}
}

View File

@@ -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<PM2Station> 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<PM2Station> 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);
}
}

View File

@@ -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:taxi10: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);
}
}

View File

@@ -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)
}

View File

@@ -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
}
}
}
}
}

View File

@@ -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 自动驾驶状态展示, 注意美化模式下的处理
}
}
}

View File

@@ -0,0 +1,8 @@
package com.mogo.och.bus.passenger.model
/**
* @author: wangmingjun
* @date: 2023/2/2
*/
class PM2ADASModel {
}

View File

@@ -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<MogoLocation>()
private var routesResult: PM2RoutesResult? = null
var mStations = mutableListOf<PM2Station>()
private var mNextStationIndex = 0 // 要到达站的index
private var mTwoStationsRouts = mutableListOf<MogoLocation>()
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<PM2OperationStatusResponse> {
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<PM2RoutesResponse>{
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<PM2Station> = 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()
}
}
}

View File

@@ -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<PM2RoutesResponse>?
) {
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<PM2OperationStatusResponse>?
) {
mBusPassengerServiceApi.queryDriverOperationStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
driverAppSn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus"))
}
}

View File

@@ -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<Int?> {
return Observable.create(ObservableOnSubscribe { emitter ->
if (emitter.isDisposed) return@ObservableOnSubscribe
PM2DrivingModel.INSTANCE.loopRouteAndWipe()
emitter.onComplete()
})
}
private fun startLoopCalculateRouteInfo(): Observable<Int?> {
return Observable.create(ObservableOnSubscribe { emitter ->
if (emitter.isDisposed) return@ObservableOnSubscribe
PM2DrivingModel.INSTANCE.dynamicCalculateRouteInfo()
emitter.onComplete()
})
}
}

View File

@@ -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<PM2RoutesResponse> 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<PM2OperationStatusResponse> queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
}

View File

@@ -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<BusPM2DrivingInfoFragment?>(view)

View File

@@ -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<BusPM2MapFragment?>(view)

View File

@@ -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<BusPM2BaseFragment?>(view)

View File

@@ -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<BusPM2VideoFragment?>(view)

View File

@@ -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<PM2HPMapFragment?>(view)

View File

@@ -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<PM2DrivingInfoFragment?>(view)

View File

@@ -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<PM2BaseFragment?>(view)

View File

@@ -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<PM2VideoFragment?>(view)

View File

@@ -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<BusPM2BaseFragment?, BusPM2Presenter?>() {
/**
* 改变自动驾驶状态
*
* @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
}
}

View File

@@ -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<BusPM2DrivingInfoFragment?, BusPM2DrivingPresenter?>() {
/**
* 改变自动驾驶状态
*
* @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
}
}

View File

@@ -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<PM2BaseFragment?, PM2Presenter?>() {
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
}
}

View File

@@ -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<PM2DrivingInfoFragment?, PM2DrivingPresenter?>() {
/**
* 改变自动驾驶状态
*
* @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
}
}

View File

@@ -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<BusPM2MapFragment?, BusPM2MapPresenter?>() {
class PM2HPMapFragment :
MvpFragment<PM2HPMapFragment?, PM2ADASPresenter?>() {
/**
* 改变自动驾驶状态
*
* @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
}
}

View File

@@ -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<BusPM2VideoFragment?, BusPM2VideoPresenter?>() {
class PM2VideoFragment :
MvpFragment<PM2VideoFragment?, PM2VideoPresenter?>() {
/**
* 改变自动驾驶状态
*
* @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
}
}

View File

@@ -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
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ff000000"/>
<corners android:radius="@dimen/dp_60"/>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 图片或视频广告-->
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -4,21 +4,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 行车卡片--><!-- 全览地图带站点-->
<TextView
android:id="@+id/bus_p_speed_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_40"
android:includeFontPadding="false"
android:letterSpacing="-0.05"
android:text="0"
android:textColor="@color/bus_p_speed_txt_color"
android:textSize="@dimen/bus_p_speed_txt_size"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:text="这是driving"
android:textSize="@dimen/dp_60"/>
<!-- 行车卡片--><!-- 全览地图带站点-->
<com.mogo.eagle.core.function.overview.view.OverMapView
android:id="@+id/overMapView"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_400"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 行车卡片--><!-- 全览地图带站点-->
<FrameLayout
android:id="@+id/driving_fragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
<!-- 高精地图-->
<FrameLayout
android:id="@+id/hd_map_fragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/driving_fragment"
app:layout_constraintLeft_toLeftOf="parent"/>
<!-- 图片或视频广告-->
<FrameLayout
android:id="@+id/video_fragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/hd_map_fragment"
app:layout_constraintLeft_toLeftOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -5,5 +5,12 @@
android:layout_height="match_parent">
<!-- 图片或视频广告-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="这是hdMap"
android:textSize="@dimen/dp_60"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/dp_225"
android:layout_height="@dimen/dp_154"
android:visibility="visible">
<ImageView
android:layout_width="@dimen/dp_210"
android:layout_height="@dimen/dp_120"
android:background="@drawable/bg_p_m2_traffic_light_background"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_17"/>
<ImageView
android:id="@+id/bus_traffic_light_iv"
android:layout_width="@dimen/dp_154"
android:layout_height="@dimen/dp_154"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.mogo.och.common.module.wigets.OCHGradientTextView
android:id="@+id/bus_traffic_light_time_tv"
android:layout_width="@dimen/dp_130"
android:layout_height="match_parent"
android:textSize="@dimen/dp_60"
android:textStyle="bold"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -4,11 +4,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 行车卡片--><!-- 全览地图带站点-->
<!-- 高精地图-->
<!-- 图片或视频广告-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="这是video"
android:textSize="@dimen/dp_60"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -27,4 +27,12 @@
<color name="bus_p_route_view_left_edge_shadow">#33394C63</color>
<color name="bus_p_traffic_txt_color">#2D3E5F</color>
<color name="bus_p_panel_edge_shadow">#33394C63</color>
<color name="bus_traffic_light_red_color_up">#FFFFA28B</color>
<color name="bus_traffic_light_red_color_down">#FFDA1100</color>
<color name="bus_traffic_light_green_color_up">#FF60FFD3</color>
<color name="bus_traffic_light_green_color_down">#FF006D43</color>
<color name="bus_traffic_light_yellow_color_up">#FFFFE198</color>
<color name="bus_traffic_light_yellow_color_down">#FFFF9B00</color>
<color name="bus_arrived_btn_un_clickable_color">#59FFFFFF</color>
</resources>