Merge branch 'release_robotaxi-d-app-module_2100_220816_2.10.0.1' into 'master'

Release robotaxi d app module 2100 220816 2.10.0.1

See merge request zhjt/AndroidApp/MoGoEagleEye!183
This commit is contained in:
pangfan
2022-09-15 08:59:32 +00:00
294 changed files with 11371 additions and 858 deletions

View File

@@ -44,5 +44,7 @@ class BusPassengerConst {
// 订单总里程
const val BUS_SP_KEY_ORDER_SUM_DIS = "BUS_SP_KEY_ORDER_SUM_DIS"
const val QUERY_BUS_P_STATION_DELAY = 3 * 1000L
}
}

View File

@@ -4,6 +4,8 @@ import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.net.ConnectivityManager;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -56,6 +58,7 @@ import mogo_msg.MogoReportMsg;
import system_master.SystemStatusInfo;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.QUERY_BUS_P_STATION_DELAY;
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED;
/**
@@ -88,6 +91,18 @@ public class BusPassengerModel {
private int mNextStationIndex = 0;// 要到达站的index
private List<LatLng> mTwoStationsRouts = new ArrayList<>();
private static final int MSG_QUERY_BUS_P_STATION = 1001;
private final Handler handler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
if ( msg.what == MSG_QUERY_BUS_P_STATION ) {
queryDriverOperationStatus();
return true;
}
return false;
}
});
private BusPassengerModel() {
}
@@ -96,6 +111,7 @@ public class BusPassengerModel {
initListeners();
// TODO: 2022/3/31
queryDriverOperationStatus();
startOrStopOrderLoop(true);
}
public void setDriverStatusCallback(IBusPassegerDriverStatusCallback callback){
@@ -106,13 +122,16 @@ public class BusPassengerModel {
this.mRouteLineInfoCallback = callback;
}
private void queryDriverOperationDelay() {
handler.sendEmptyMessageDelayed( MSG_QUERY_BUS_P_STATION, QUERY_BUS_P_STATION_DELAY );
}
private void queryDriverOperationStatus() {
BusPassengerServiceManager.getInstance().queryDriverOperationStatus(mContext
, new BusPassengerServiceCallback<BusPassengerOperationStatusResponse>() {
@Override
public void onSuccess(BusPassengerOperationStatusResponse data) {
if (data == null || data.data == null) return;
startOrStopOrderLoop(data.data.serviceStatus == 1);
if(mDriverStatusCallback != null){
mDriverStatusCallback.changeOperationStatus(data.data.serviceStatus == 1);
mDriverStatusCallback.updatePlateNumber(data.data.plateNumber);
@@ -121,7 +140,8 @@ public class BusPassengerModel {
@Override
public void onFail(int code, String msg) {
queryDriverOperationStatus();
//延迟3s再次查询
queryDriverOperationDelay();
}
});
}
@@ -141,7 +161,10 @@ public class BusPassengerModel {
@Override
public void onFail(int code, String msg) {
//code = 1003; message = bus车辆已收车或未出车;
if (code == 1003){
queryDriverOperationDelay();
}
}
});
}
@@ -409,7 +432,9 @@ public class BusPassengerModel {
//要前往的站在轨迹中对应的点
int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndex(mRoutePoints
,stationNext.getGcjLon(),stationNext.getGcjLat());
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex));
if (currentRouteIndex < nextRouteIndex){ //如果找到的next在起点的轨迹前面直接舍弃这个轨迹不显示
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex));
}
}
}else { //只有两个站点的时候整个路线就是两个站点之间的轨迹
mTwoStationsRouts.clear();

View File

@@ -57,8 +57,8 @@ public class BusPassengerMapDirectionView
private int mCurrentIndex = -1;
private int zoomLevel = 13;
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
private List<LatLng> mLinePointsLatLng = new ArrayList<>();
private List<LatLng> mCoordinatesLatLng = new ArrayList<>(); //站点坐标数据
private List<LatLng> mLinePointsLatLng = new ArrayList<>(); //轨迹坐标数据
private Polyline mPolyline;
private CameraUpdate mCameraUpdate;
private Context mContext;
@@ -197,7 +197,7 @@ public class BusPassengerMapDirectionView
mCarMarker.setToTop();
}
if (mLinePointsLatLng.size() > 1){
if (mLinePointsLatLng.size() > 0){
//圈定地图显示范围
//存放经纬度
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
@@ -208,12 +208,13 @@ public class BusPassengerMapDirectionView
//第二个参数为四周留空宽度
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100));
}else {
//设置希望展示的地图缩放级别
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
// else {
// //设置希望展示的地图缩放级别
// CameraPosition cameraPosition = new CameraPosition.Builder()
// .target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
// mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
// }
}
@@ -368,7 +369,7 @@ public class BusPassengerMapDirectionView
mLinePointsLatLng.clear();
mLinePointsLatLng.addAll(routeLineLatLngs);
if (mCoordinatesLatLng.size() > 0 && mCurrentIndex != currentIndex) {
if (mLinePointsLatLng.size() > 0 && mCurrentIndex != currentIndex) {
if (mAMap != null && mLineMarkers.size() > 0) {
mCurrentIndex = currentIndex;
for (int i = 0; i < mLineMarkers.size(); i++) {

View File

@@ -0,0 +1,24 @@
package com.mogo.och.bus.bean;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
public
/**
* @author congtaowang
* @since 2021/3/22
*
* 小巴车重置路线状态请求参数
*/
class BusResetLineStatusRequest {
private String sn;
public BusResetLineStatusRequest() {
this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
}
public String getSn() {
return sn;
}
}

View File

@@ -10,4 +10,5 @@ import java.util.List;
*/
public interface IRefreshBusStationsCallback {
void refreshBusStations(String lineName,List<BusStationBean> stationList, int currentStation, int nextStation, boolean isArrived);
void clearBusStationsMarkers();
}

View File

@@ -5,8 +5,10 @@ import static com.mogo.och.bus.constant.BusConst.TIMER_START_AUTOPILOT_INTERVAL;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -49,6 +51,9 @@ import com.mogo.och.bus.model.BusOrderModel;
import com.mogo.och.bus.util.BDRouteDataTestUtils;
import com.mogo.och.bus.view.SlidePanelView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;
import mogo.telematics.pad.MessagePad;
import record_cache.RecordPanelOuterClass;
@@ -67,7 +72,8 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
private RelativeLayout ctvAutopilotStatus;
private ImageView ctvAutopilotStatusIv;
private TextView ctvAutopilotStatusTv;
protected TextView tvOperationStatus;
protected TextView tvArrived;
// protected TextView tvOperationStatus;
protected RelativeLayout mSettingBtn;
protected RelativeLayout mBadcaseBtn;
protected RelativeLayout mAICollectBtn;
@@ -119,7 +125,8 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
// mTrafficLightView = findViewById(R.id.bus_traffic_light_view);
// CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView);
tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status);
// tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status);
tvArrived = findViewById(R.id.module_mogo_och_arrived_tv);
flSpeed = (FrameLayout) findViewById(R.id.fl_speed);
mTrafficDataView = (TrafficDataView) findViewById(R.id.bus_arc);
@@ -145,6 +152,10 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
.inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS, BusConst.TYPE_MARKER_BUS_ORDER);
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null);
mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long);
} else {
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).visibleAllMarkers();
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium);
}
}
});
@@ -160,19 +171,15 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
});
}
initListener();
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener(){
@Override
public void onClickImpl(View v) {
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
restartAutopilot();
}else {
ToastUtils.showShort(getResources().getString(R.string.bus_auto_disable_tip));
}
restartAutopilot();
}
});
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
// 模拟 不可自动驾驶目前场景是刚开机adas还未和工控机连接
findViewById(R.id.btnAutopilotDisable).setOnClickListener(view ->
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE)
@@ -195,8 +202,12 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
findViewById(R.id.btnAutopilotRoute).setOnClickListener(view -> debugArrivedRoute());
tvOperationStatus.setOnClickListener(view -> {
onChangeOperationStatus();
// tvOperationStatus.setOnClickListener(view -> {
// onChangeOperationStatus();
// });
tvArrived.setOnClickListener(view -> {
onArriveStation();
});
mSettingBtn = findViewById(R.id.module_mogo_och_setting_layout);
@@ -207,11 +218,6 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
// mBadcaseBtn的visible显示逻辑在showBadcaseEntrance内处理
mBadcaseBtn = findViewById(R.id.module_mogo_och_badcase_rl);
// CallerHmiManager.INSTANCE.registerBadCaseCallback(
// () -> { // onShow()
// return mBadcaseBtn; },
// () -> { // onHide()
// return null; });
if (mBadcaseBtn != null) {
CallerDevaToolsManager.INSTANCE.initBadCase(mBadcaseBtn);
@@ -226,6 +232,16 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container
, @Nullable Bundle savedInstanceState) {
EventBus.getDefault().register(this);
return super.onCreateView(inflater, container, savedInstanceState);
}
protected abstract void onArriveStation();
private void updateSwitchMapIcon(){
if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight()) {
mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long);
@@ -246,6 +262,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
if (!HmiBuildConfig.isShowBadCaseView) {
CallerAutopilotRecordListenerManager.INSTANCE.removeListener(TAG);
}
EventBus.getDefault().unregister(this);
}
@@ -285,9 +302,25 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
slidePanelView.setText(text);
slidePanelView.setVisibility(View.VISIBLE);
});
setArrivedClikable(false);
}
}
/**
* 设置进站按钮状态
* @param isClickable
*/
public void setArrivedClikable(boolean isClickable){
getActivity().runOnUiThread(() -> {
tvArrived.setEnabled(isClickable);
if (isClickable){
tvArrived.setTextColor(getResources().getColor(R.color.bus_white));
}else {
tvArrived.setTextColor(getResources().getColor(R.color.bus_arrived_btn_un_clickable_color));
}
});
}
/**
* 隐藏滑动按钮
*/
@@ -321,13 +354,13 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv));
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon);
ctvAutopilotStatus.setSelected(false);
ctvAutopilotStatus.setFocusableInTouchMode(true);
ctvAutopilotStatus.setClickable(true);
} else {
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv));
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot);
ctvAutopilotStatus.setFocusableInTouchMode(true);
ctvAutopilotStatus.setClickable(true);
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) {//1可用
ctvAutopilotStatus.setSelected(false);
}else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus){
@@ -343,12 +376,12 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_success_tv));
ctvAutopilotStatus.setSelected(false);
ctvAutopilotStatus.setFocusableInTouchMode(false);
ctvAutopilotStatus.setClickable(false);
}else {
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon);
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv));
ctvAutopilotStatus.setFocusableInTouchMode(false);
ctvAutopilotStatus.setClickable(false);
ctvAutopilotStatus.setSelected(false);
}
UiThreadHandler.postDelayed(new Runnable() {
@@ -442,7 +475,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_tv));
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatus.setSelected(false);
ctvAutopilotStatus.setFocusableInTouchMode(true);
ctvAutopilotStatus.setClickable(true);
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_loading_autopilot_icon);
if (autopilotLoadingAnimator == null) {
autopilotLoadingAnimator = ObjectAnimator.ofFloat(ctvAutopilotStatusIv, "rotation", 0f, 360f);

View File

@@ -9,11 +9,12 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.eagle.core.data.map.CenterLine;
import com.mogo.eagle.core.data.temp.EventBusOperation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
@@ -28,6 +29,9 @@ import com.mogo.och.bus.ui.BusSwitchLineActivity;
import com.mogo.och.bus.view.SlidePanelView;
import com.mogo.och.common.module.utils.OCHThreadPoolManager;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.List;
import mogo.telematics.pad.MessagePad;
@@ -50,7 +54,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
private TextView mLineName;
private int mCurrentStation = 0;
private View mBus;
// private View mBus;
private BusStationBean startStation = null;
private BusStationBean endStation = null;
@@ -63,48 +67,45 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
@Override
protected void initViews() {
super.initViews();
mBus = findViewById(R.id.module_och_bus_tag);
// mBus = findViewById(R.id.module_och_bus_tag);
mCurrentStationName = findViewById(R.id.module_och_bus_current_station);
mCurrentTag = findViewById(R.id.module_och_bus_current_station_anchor);
mNextStationName = findViewById(R.id.module_och_bus_order_end_station);
mNextTag = findViewById(R.id.module_och_bus_next_station_anchor);
mSwitchLine = findViewById(R.id.switch_line_btn);
mSwitchLine.setTag(0);
mLineName = findViewById(R.id.module_och_bus_line_name);
if (DebugConfig.isDebug()) {
mBus.setOnClickListener(view -> {
ToastUtils.showShort("重置了车站状态");
mPresenter.queryBusRoutes();
});
//debug下调用测试面板
mCurrentStationName.setOnLongClickListener(v -> {
//调用测试面板
mCurrentStationName.setOnLongClickListener(v -> {
debugTestBar();
showHideTestBar();
return true;
});
}
// }
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
// 初始化的时候设置 UI 按钮状态
switch (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()) {
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
hideAutopilotBiz();
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE:
showAutopilotBiz();
onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE);
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
showAutopilotBiz();
onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
break;
default:
break;
}
showAutopilotBiz();
mSwitchLine.setOnClickListener(this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onClickChangeOperationStatus(EventBusOperation eventBusOperation){
if (eventBusOperation.getId() == 0){ // 查询
mPresenter.queryOperationStatus();
}else if (eventBusOperation.getId() == 1){ // 出车/收车切换
CallerLogger.INSTANCE.d(M_BUS + TAG,"bus出车/收车");
onChangeOperationStatus();
}
}
@Override
protected void onArriveStation() {
mPresenter.onAutopilotArriveAtStation(null);
}
@Override
protected void debugArrivedStation() {
mPresenter.onAutopilotArriveAtStation(null);
@@ -235,10 +236,14 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
}
private void showOrHideSwitchLineBtn(boolean isShow) {
if (isShow){
mSwitchLine.setVisibility(View.VISIBLE);
}else {
mSwitchLine.setVisibility(View.GONE);
if (isShow){//显示切换路线
// mSwitchLine.setVisibility(View.VISIBLE);
mSwitchLine.setTag(0);
mSwitchLine.setText(getResources().getString(R.string.bus_switch_line_btn));
}else {//显示结束路线
// mSwitchLine.setVisibility(View.GONE);
mSwitchLine.setTag(1);
mSwitchLine.setText(getResources().getString(R.string.bus_close_line_btn));
}
}
@@ -296,26 +301,35 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
*/
public void changeOperationStatus(boolean launch) {
isOperationStatus = launch;
CallerHmiManager.INSTANCE.changeBusOperationStatus(launch);
if (launch) {
// 出车的时候重制站点状态
mPresenter.queryBusRoutes();
tvOperationStatus.setText("收车");
// tvOperationStatus.setText("收车");
tvArrived.setVisibility(View.VISIBLE);
showPanel();
} else {
AIAssist.getInstance(getContext()).speakTTSVoice("已收车");
tvOperationStatus.setText("出车");
// tvOperationStatus.setText("出车");
tvArrived.setVisibility(View.GONE);
hideSlidePanel();
hidPanel();
//移除起点终点
if (null != startStation) {
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
, startStation.getLon(),R.raw.star_marker);
}
if (null != endStation) {
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
, endStation.getLon(),R.raw.end_marker);
}
clearBusStationsMarkers();
}
}
public void clearBusStationsMarkers(){
CallerLogger.INSTANCE.d(M_BUS + TAG,"clearBusStationsMarkers()");
if (null != startStation) {
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
, startStation.getLon(),R.raw.star_marker);
}
if (null != endStation) {
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
, endStation.getLon(),R.raw.end_marker);
}
}
@@ -392,12 +406,12 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning1));
return;
}
if (mCurrentStation > 0) {
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning2));
return;
if ((int)mSwitchLine.getTag() == 0){//切换路线
Intent intent = new Intent(getContext(), BusSwitchLineActivity.class);
startActivity(intent);
}else {//结束路线
mPresenter.resetCurrentLineStatus();
}
Intent intent = new Intent(getContext(), BusSwitchLineActivity.class);
startActivity(intent);
}
}
}

View File

@@ -64,7 +64,7 @@ public class BusLineModel {
}
public void commitSwitchLineId(int lineId){
BusServiceManager.getInstance().resetStationStatus(mContext,lineId, new IBusServiceCallback<BusRoutesResponse>() {
BusServiceManager.getInstance().switchLine(mContext,lineId, new IBusServiceCallback<BusRoutesResponse>() {
@Override
public void onSuccess(BusRoutesResponse o) {
if (mBusLinesCallback != null){

View File

@@ -11,7 +11,6 @@ import android.location.Location;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -25,6 +24,7 @@ import com.mogo.eagle.core.data.BaseData;
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
@@ -444,26 +444,24 @@ public class BusOrderModel {
}
/**
* 测试、重置站点状态
* 重置路线站点状态--结束路线,当前路线恢复到始发站
*/
public void debugResetStationStatus() {
CallerLogger.INSTANCE.d( M_BUS + TAG, "测试、重置站点状态");
BusServiceManager.getInstance().resetStationStatus(mContext, currentLineId
public void resetCurrentLineStatus() {
CallerLogger.INSTANCE.d( M_BUS + TAG, "结束当前路线");
BusServiceManager.getInstance().resetCurrentLineStatus(mContext, currentLineId
, new IBusServiceCallback<BusRoutesResponse>() {
@Override
public void onSuccess(BusRoutesResponse o) {
CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据: " + o);
CallerLogger.INSTANCE.d(M_BUS + TAG, "结束当前路线成功: " + o);
isGoingToNextStation = false;
if (o.getResult() == null || o.getResult().getSites() == null || o.getResult().getSites().isEmpty()) {
return;
if (o.code == 0){ // 重置成功
queryBusRoutes();
}
renderBusStationsStatus(o.getResult());
}
@Override
public void onFail(String failMsg) {
// 重复请求小巴路线,直至成功
queryBusStationDelay();
ToastUtils.showShort(failMsg);
}
});
@@ -520,11 +518,14 @@ public class BusOrderModel {
)
private void leaveStationSuccess(BusRoutesResult result, boolean isRestart) {
renderBusStationsStatus(result);
if (slidePannelHideCallback != null) {
slidePannelHideCallback.hideSlidePanel();
// if (slidePannelHideCallback != null) {
// slidePannelHideCallback.hideSlidePanel();
// }
//开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启
if (isRestart || CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
startAutopilot(isRestart);
}
//开启自动驾驶
startAutopilot(isRestart);
if (isGoingToNextStation) {
// 为了避免恢复自动驾驶时重复的接口请求
return;
@@ -682,6 +683,7 @@ public class BusOrderModel {
private void closeBeautificationMode() {
if (FunctionBuildConfig.isDemoMode) {//收车结束美化
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false;
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(false);
CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false);
CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore置为false收车");
}
@@ -801,6 +803,7 @@ public class BusOrderModel {
&& backgroundCurrentStationIndex <= stationList.size()-1)
&& stationList.get(backgroundCurrentStationIndex).isLeaving()){//行驶过程中设置美化
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true;
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(true);
CallerAutoPilotManager.INSTANCE.setIPCDemoMode(true);
CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore置为true每次滑动出发");
}
@@ -818,6 +821,12 @@ public class BusOrderModel {
BusTrajectoryManager.getInstance().syncTrajectoryInfo();
}
public void clearBusStationDatas(){
if (refreshBusStationsCallback != null){
refreshBusStationsCallback.clearBusStationsMarkers();
}
}
/**
* 根据订单状态、获取下一站靠站的的站点
*
@@ -941,6 +950,7 @@ public class BusOrderModel {
if (FunctionBuildConfig.isDemoMode && backgroundCurrentStationIndex <= stationList.size() - 1) {//到达一站结束美化
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false;
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(false);
CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false);
CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore置为false到最后一站");
}

View File

@@ -11,6 +11,7 @@ import com.mogo.eagle.core.network.RequestOptions;
import com.mogo.eagle.core.network.SubscribeImpl;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.och.bus.bean.BusQueryLinesResponse;
import com.mogo.och.bus.bean.BusResetLineStatusRequest;
import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean;
import com.mogo.och.bus.bean.BusRoutesResponse;
import com.mogo.och.bus.bean.CarHeartbeatReqBean;
@@ -74,13 +75,27 @@ public class BusServiceManager {
* @param lineId
* @param callback
*/
public void resetStationStatus(Context context, int lineId, IBusServiceCallback<BusRoutesResponse> callback){
mService.resetStationStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
public void switchLine(Context context, int lineId, IBusServiceCallback<BusRoutesResponse> callback){
mService.switchLine(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken(),new BusResetDrivingLineRequest(lineId))
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"debugResetStationStatus"));
}
/**
* 结束当前路线,当前路线状态重置到始发站
* @param context
* @param lineId
* @param callback
*/
public void resetCurrentLineStatus(Context context, int lineId, IBusServiceCallback<BusRoutesResponse> callback){
mService.resetCurrentLineStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new BusResetLineStatusRequest())
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"resetCurrentLineStatus"));
}
/**
* 离站上报
* @param context
@@ -189,7 +204,8 @@ public class BusServiceManager {
public void queryBusLines(Context context, IBusServiceCallback<BusQueryLinesResponse> callback){
mService.queryBusLines(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken(),MoGoAiCloudClientConfig.getInstance().getSn())
,MoGoAiCloudClientConfig.getInstance().getToken()
,MoGoAiCloudClientConfig.getInstance().getSn())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"queryBusLines"));

View File

@@ -3,6 +3,7 @@ import com.mogo.eagle.core.data.BaseData;
import com.mogo.och.bus.bean.BusOperationStatusRequest;
import com.mogo.och.bus.bean.BusOrdersResponse;
import com.mogo.och.bus.bean.BusQueryLinesResponse;
import com.mogo.och.bus.bean.BusResetLineStatusRequest;
import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean;
import com.mogo.och.bus.bean.BusRoutesResponse;
import com.mogo.och.bus.bean.CarHeartbeatReqBean;
@@ -42,8 +43,6 @@ public interface IBusApiService {
Observable<BusRoutesResponse> querySiteByCoordinate(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request);
/**
* 重置巴士路线: 点击小巴车tab 或者出车后会使用
*
* @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的 不是重置线路中站点的
* @return 返回值是重置后的车站列表
*/
@@ -51,7 +50,7 @@ public interface IBusApiService {
// @POST( "/autopilot-car-hailing/car/v2/bus/drivingLine/reset" )
@POST( "/autopilot-car-hailing/car/v2/driver/bus/drivingLine/reset" )
// @POST( "/mock/268/autopilot-car-hailing/bus/api/drivingLine/reset" )
Observable<BusRoutesResponse> resetStationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request);
Observable<BusRoutesResponse> switchLine(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request);
/**
* 离站,通知服务器
@@ -150,5 +149,9 @@ public interface IBusApiService {
@Headers( {"Content-type:application/json;charset=UTF-8"} )
@POST( "/autopilot-car-hailing/location/v2/driver/bus/saveLineCoordinate" )
Observable<BaseData> updateOrderRoute(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusRoutePlanningUpdateReqBean data);
@Headers( {"Content-type:application/json;charset=UTF-8"} )
@POST("/autopilot-car-hailing/operation/v1/driver/bus/line/resetStart")
Observable<BusRoutesResponse> resetCurrentLineStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetLineStatusRequest data);
}

View File

@@ -53,6 +53,7 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
@Override
public void onChangeLineIdSuccess() {
BusOrderModel.getInstance().clearBusStationDatas();
runOnUIThread(() -> mView.onChangeLineIdSuccess());
}

View File

@@ -60,7 +60,7 @@ public class BusPresenter extends Presenter<BusFragment>
@Override
public void onCreate(@NonNull LifecycleOwner owner) {
super.onCreate(owner);
BusOrderModel.getInstance().queryOperationStatus();
queryOperationStatus();
BusOrderModel.getInstance().queryBusRoutes();
initModelListener();
}
@@ -90,8 +90,12 @@ public class BusPresenter extends Presenter<BusFragment>
BusOrderModel.getInstance().queryBusRoutes();
}
public void debugResetStationStatus() {
BusOrderModel.getInstance().debugResetStationStatus();
public void queryOperationStatus(){
BusOrderModel.getInstance().queryOperationStatus();
}
public void resetCurrentLineStatus() {
BusOrderModel.getInstance().resetCurrentLineStatus();
}
public void autoDriveToNextStation(boolean isRestart) {
@@ -133,6 +137,11 @@ public class BusPresenter extends Presenter<BusFragment>
}
}
@Override
public void clearBusStationsMarkers() {
runOnUIThread(() -> mView.clearBusStationsMarkers());
}
private void functionDemoModeChange() {
// CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel ="," functionDemoModeChange ="+mCurrentStation);
if (FunctionBuildConfig.isDemoMode
@@ -148,6 +157,7 @@ public class BusPresenter extends Presenter<BusFragment>
public void hideSlidePanel() {
if (mView != null) {
runOnUIThread(() -> mView.hideSlidePanel());
runOnUIThread(()-> mView.setArrivedClikable(true));
}
}
@@ -175,9 +185,9 @@ public class BusPresenter extends Presenter<BusFragment>
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE;
// 设置UI【自动驾驶】按钮是否展示
runOnUIThread(() -> mView.onAutopilotEnableChange(true));
if (BusOrderModel.getInstance().isGoingToNextStation()) {
runOnUIThread(() -> mView.hideSlidePanel());
}
// if (BusOrderModel.getInstance().isGoingToNextStation()) {
// runOnUIThread(() -> mView.hideSlidePanel());
// }
if (FunctionBuildConfig.isDemoMode
&& (
(mCurrentStation > 0 && mCurrentStation < mStationList.size() - 1)

View File

@@ -61,7 +61,7 @@
android:layout_marginLeft="@dimen/dp_13"
app:layout_constraintTop_toBottomOf="@id/module_mogo_och_autopilot_status"
app:layout_goneMarginTop="@dimen/module_mogo_och_station_panel_container_margin_top_no_call"
tools:visibility="visible" />
android:visibility="gone"/>
<include
android:id="@+id/module_mogo_och_bus_test_bar"
@@ -79,11 +79,13 @@
android:layout_width="@dimen/module_mogo_och_operation_status_bg_width"
android:layout_height="@dimen/module_mogo_och_operation_status_bg_height"
android:layout_marginLeft="@dimen/module_mogo_och_margin_left"
app:layout_goneMarginBottom="@dimen/module_mogo_och_margin_bottom"
app:layout_goneMarginLeft="@dimen/module_mogo_och_margin_left"
android:background="@drawable/bus_switch_map_bg"
android:elevation="@dimen/bus_dp_10"
android:padding="@dimen/bus_dp_20"
app:layout_constraintBottom_toBottomOf="@+id/module_mogo_och_operation_status"
app:layout_constraintLeft_toRightOf="@+id/module_mogo_och_operation_status"
app:layout_constraintBottom_toBottomOf="@+id/module_mogo_och_arrived_tv"
app:layout_constraintLeft_toRightOf="@+id/module_mogo_och_arrived_tv"
android:gravity="center"
android:orientation="horizontal">
@@ -92,17 +94,33 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<CheckedTextView
android:id="@+id/module_mogo_och_operation_status"
<!-- <CheckedTextView-->
<!-- android:id="@+id/module_mogo_och_operation_status"-->
<!-- android:layout_width="@dimen/module_mogo_och_operation_status_bg_width"-->
<!-- android:layout_height="@dimen/module_mogo_och_operation_status_bg_height"-->
<!-- android:background="@drawable/bus_operation_status_bg"-->
<!-- android:elevation="@dimen/dp_10"-->
<!-- android:gravity="center"-->
<!-- android:text="出车"-->
<!-- android:textAlignment="center"-->
<!-- android:textColor="@color/bus_autopilot_text_color_selector"-->
<!-- android:textSize="@dimen/module_mogo_och_autopilot_status_text_size"-->
<!-- android:textStyle="bold"-->
<!-- android:layout_marginLeft="@dimen/module_mogo_och_margin_left"-->
<!-- android:layout_marginBottom="@dimen/module_mogo_och_margin_bottom"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"/>-->
<TextView
android:id="@+id/module_mogo_och_arrived_tv"
android:layout_width="@dimen/module_mogo_och_operation_status_bg_width"
android:layout_height="@dimen/module_mogo_och_operation_status_bg_height"
android:background="@drawable/bus_operation_status_bg"
android:background="@drawable/bus_operation_status_bg_selector"
android:elevation="@dimen/dp_10"
android:text="@string/bus_arrived_str"
android:gravity="center"
android:text="出车"
android:textAlignment="center"
android:textColor="@color/bus_autopilot_text_color_selector"
android:textSize="@dimen/module_mogo_och_autopilot_status_text_size"
android:textSize="@dimen/module_mogo_och_arrived_text_size"
android:textStyle="bold"
android:layout_marginLeft="@dimen/module_mogo_och_margin_left"
android:layout_marginBottom="@dimen/module_mogo_och_margin_bottom"
@@ -137,12 +155,13 @@
android:elevation="@dimen/dp_10"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/module_mogo_och_setting_layout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:src="@drawable/bad_case_selector"/>
android:src="@drawable/bad_case_selector" />
</RelativeLayout>
<RelativeLayout

View File

@@ -12,7 +12,7 @@
<TextView
android:id="@+id/module_och_bus_line_name"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_68"
android:layout_marginRight="@dimen/dp_20"
@@ -23,26 +23,25 @@
android:textColor="#FFF"
android:textSize="38px"
android:textStyle="bold"
app:layout_constraintRight_toLeftOf="@+id/module_och_bus_tag"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/module_och_bus_tag"
android:layout_width="@dimen/dp_109"
android:layout_height="@dimen/dp_42"
android:layout_gravity="right"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_60"
android:background="@drawable/bus_panel_anchor_bkg"
android:gravity="center"
android:text="小巴车"
android:textColor="#FFF"
android:textSize="@dimen/module_mogo_och_autopilot_order_tag_height"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/module_och_bus_line_name"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/module_och_bus_line_name" />
<!-- <TextView-->
<!-- android:id="@+id/module_och_bus_tag"-->
<!-- android:layout_width="@dimen/dp_109"-->
<!-- android:layout_height="@dimen/dp_42"-->
<!-- android:layout_gravity="right"-->
<!-- android:layout_marginTop="@dimen/dp_10"-->
<!-- android:layout_marginRight="@dimen/dp_60"-->
<!-- android:background="@drawable/bus_panel_anchor_bkg"-->
<!-- android:gravity="center"-->
<!-- android:text="小巴车"-->
<!-- android:textColor="#FFF"-->
<!-- android:textSize="@dimen/module_mogo_och_autopilot_order_tag_height"-->
<!-- android:textStyle="bold"-->
<!-- app:layout_constraintBottom_toBottomOf="@+id/module_och_bus_line_name"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="@id/module_och_bus_line_name" />-->
<View
android:id="@+id/line1"
@@ -53,7 +52,7 @@
android:layout_marginRight="@dimen/dp_30"
android:background="@drawable/bus_line_dividing_line1_selector"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/module_och_bus_tag" />
app:layout_constraintTop_toBottomOf="@+id/module_och_bus_line_name" />
<View
android:id="@+id/line2"

View File

@@ -91,6 +91,7 @@
<dimen name="module_mogo_och_autopilot_status_text_size">40px</dimen>
<dimen name="module_mogo_och_arrived_text_size">32px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_padding_top">13px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_drawable_padding">12px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_m_l">350px</dimen>

View File

@@ -91,6 +91,7 @@
<dimen name="module_mogo_och_autopilot_status_text_size">40px</dimen>
<dimen name="module_mogo_och_arrived_text_size">32px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_padding_top">13px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_drawable_padding">12px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_m_l">350px</dimen>

View File

@@ -44,4 +44,5 @@
<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>

View File

@@ -89,6 +89,7 @@
<dimen name="module_mogo_och_autopilot_order_bg_height">270px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_size">30px</dimen>
<dimen name="module_mogo_och_arrived_text_size">30px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_padding_top">13px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_drawable_padding">12px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_m_l">288px</dimen>

View File

@@ -11,7 +11,8 @@
<string name="bus_switch_line_end">终点:</string>
<string name="bus_switch_line_btn_txt">确认</string>
<string name="bus_switch_line_btn">切换路线</string>
<string name="bus_switch_line_btn_warning1">自动驾驶中,不可切换路线</string>
<string name="bus_close_line_btn">结束路线</string>
<string name="bus_switch_line_btn_warning1">自动驾驶状态中,不可切换或结束路线</string>
<string name="bus_switch_line_btn_warning2">当前行程未完成,不可切换路线</string>
<string name="bus_no_line_tip">当前车辆无路线\n请联系运营人员绑定</string>
<string name="bus_line_start">起点: </string>
@@ -24,4 +25,5 @@
<string name="bus_arrive_to_current_tag">当前站点:</string>
<string name="bus_arrive_to_next_tag">下一站:</string>
<string name="bus_auto_disable_tip">自动驾驶状态为0不可用</string>
<string name="bus_arrived_str">进站</string>
</resources>

View File

@@ -35,7 +35,7 @@ public class AnimatorDrawableUtil {
//图片资源的ID列表
private List<Integer> mResourceIdList = null;
//定时任务器
private Timer mTimer = null;
private final Timer mTimer = new Timer();
//定时任务
private AnimTimerTask mTimeTask = null;
//记录播放位置
@@ -44,7 +44,7 @@ public class AnimatorDrawableUtil {
private boolean isLooping = false;
public AnimatorDrawableUtil() {
mTimer = new Timer();
// mTimer = new Timer();
}
/**
@@ -139,18 +139,25 @@ public class AnimatorDrawableUtil {
*/
public void start(boolean loop, int duration, AnimationLisenter lisenter) {
this.lisenter = lisenter;
stop();
// stop();
if (mResourceIdList == null || mResourceIdList.size() == 0) {
return;
}
if (mTimer == null) {
mTimer = new Timer();
// if (mTimer == null) {
// mTimer = new Timer();
// }
try {
isLooping = loop;
mFrameIndex = 0;
mState = STATE_RUNNING;
if (mTimeTask != null){
return;
}
mTimeTask = new AnimTimerTask();
mTimer.schedule(mTimeTask, 0, duration);
}catch (Exception e){
e.printStackTrace();
}
isLooping = loop;
mFrameIndex = 0;
mState = STATE_RUNNING;
mTimeTask = new AnimTimerTask();
mTimer.schedule(mTimeTask, 0, duration);
if (lisenter != null){
lisenter.startAnimation();
}
@@ -163,7 +170,7 @@ public class AnimatorDrawableUtil {
if (mTimer != null) {
mTimer.purge();
mTimer.cancel();
mTimer = null;
// mTimer = null;
}
if (mTimeTask != null) {
mFrameIndex = 0;

View File

@@ -0,0 +1,17 @@
package com.mogo.och.common.module.utils;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
public class ToastUtilsOch {
public static void showWithCodeMessage(int code,String message){
if(message==null){
return;
}
if (DebugConfig.isDebug()) {
ToastUtils.showShort(code+","+message);
}else {
ToastUtils.showShort(message);
}
}
}

View File

@@ -67,7 +67,10 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.UndeliverableException;
import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins;
@@ -108,6 +111,9 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
private ITaxiPassengerVeloctityCallback mVeloctityCallback;//道路限速返回
private Disposable subscribe;
private int delayTime = 2;
private double mLongitude, mLatitude;
private List<LatLng> mLocationsModels = new ArrayList<>();
@@ -209,6 +215,9 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
startOrStopOrderLoop(false);
startOrStopQueryOrderRemaining(false);
releaseListeners();
if(subscribe!=null&&!subscribe.isDisposed()){
subscribe.dispose();
}
}
private void initListeners() {
@@ -720,13 +729,17 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
startOrStopRouteAndWipe(true);
}
}else {
queryOrderRouteList();
subscribe = Observable.timer(delayTime, TimeUnit.SECONDS).subscribe(aLong -> {
queryOrderRouteList();
});
}
}
@Override
public void onFail(int code, String msg) {
queryOrderRouteList();
subscribe = Observable.timer(delayTime, TimeUnit.SECONDS).subscribe(aLong -> {
queryOrderRouteList();
});
}
});
}

View File

@@ -24,11 +24,8 @@ import com.mogo.och.taxi.passenger.model.TaxiPassengerGeocodeSearchModel;
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel;
import com.mogo.och.taxi.passenger.ui.TaxiPassengerServingOrderFragment;
import java.util.ArrayList;
import java.util.List;
import mogo.telematics.pad.MessagePad;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
/**
@@ -54,9 +51,11 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
}
private void initListener() {
// 设置起点和终点marker和实时车辆位置
TaxiPassengerModel.getInstance().setMoGoAutopilotPlanningListener(this);
TaxiPassengerModel.getInstance().setOrderStatusCallback("TaxiPassengerServingOrderPresenter",this);
TaxiPassengerModel.getInstance().setControllerStatusCallback("TaxiPassengerServingOrderPresenter",this);
// 获取道路限速
TaxiPassengerModel.getInstance().setVeloctityCallback(this);
}
@@ -132,10 +131,19 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
}
private long startTime = 0;
private static final long TIMEINTERVAL = 4000;
@Override
public void onCarLocationChanged(Location location) {
if (location != null){
runOnUIThread(() -> mView.onCarLocationChanged(location));
long currentTimeMillis = System.currentTimeMillis();
if(currentTimeMillis-startTime<TIMEINTERVAL){
return;
}
CallerLogger.INSTANCE.d(M_TAXI_P + TAG,"onCarLocationChanged 获取当前路的信息");
startTime = currentTimeMillis;
TaxiPassengerGeocodeSearchModel.getInstance(getContext()).searchLocationInfo(location.getLatitude(),location.getLongitude());
}
}

View File

@@ -139,17 +139,14 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS);
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null);
mMapswitchBtn.setImageResource(R.drawable.taxi_p_switch_map_long);
} else {
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).visibleAllMarkers();
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
mMapswitchBtn.setImageResource(R.drawable.taxi_p_switch_map_medium);
}
//OverlayLeftViewUtils.INSTANCE.dismissOverlayView();
}
});
findViewById(R.id.iv_temp).setOnClickListener(view -> {
OverlayLeftViewUtils.INSTANCE.showOverlayView(getActivity(),0,true,-1,true);
//showOrHideArrivedEndLayout(true, "北京北京北京", "1527481606997577728");
//showOrHidePressengerCheckPager(true, "开始站点开", "开始站点开始站点开始", "2", "京A888888", "18811539480");
//OCHFloatWindowManager.getInstance().ShowFloatWindow(getContext());
});
}
private void initArrivedView(){

View File

@@ -101,9 +101,9 @@ public class TaxiPassengerStartAutopilotView extends RelativeLayout implements V
mAutopilotBtnBg = view.findViewById(R.id.taxi_p_autopilot_btn_bg);
mCarIv = view.findViewById(R.id.taxi_p_autopilot_starting);
initBtnAnimatonDrawable();
initCarStartingFrame();
// initBtnAnimatonDrawable();
//
// initCarStartingFrame();
}
private void initCarStartingFrame() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -5,13 +5,14 @@ import com.mogo.eagle.core.data.BaseData;
/**
* Created by pangfan on 2021/8/19
*
* 收车/出车状态查询返回数据结构
* 状态查询返回数据结构
*/
public class DriverStatusQueryRespBean extends BaseData {
public Result data;
public static class Result {
public int serviceStatus; //0收车1出车
public int servingStatus; //1接单1暂停接单
public int driverStatus; //1登录0登出
public String orderNo;
public int purpose; // 1 运营, 2 测试, 3演示
}

View File

@@ -3,14 +3,12 @@ package com.mogo.och.taxi.bean;
/**
* Created by pangfan on 2021/8/19
*
* 收车/出车状态更新请求数据结构
* 状态更新请求数据结构
*/
public class DriverStatusUpdateReqBean {
public String sn;
public int status; //0收车1出车
public DriverStatusUpdateReqBean(String sn, int status) {
public DriverStatusUpdateReqBean(String sn) {
this.sn = sn;
this.status = status;
}
}

View File

@@ -0,0 +1,30 @@
package com.mogo.och.taxi.bean;
/**
* Created by pangfan on 2021/8/19
* 司机端准备好或者乘客已验证上车请求参数
*/
public class TaxiLoginReqBean {
public String phone;
public String captcha;
public String sn;
public Location4Login loc;
public TaxiLoginReqBean(String phone, String code, String sn,Location4Login location4Login) {
this.phone = phone;
this.captcha = code;
this.sn = sn;
this.loc = location4Login;
}
public static class Location4Login{
double lat;
double lon;
public Location4Login(double lat, double lon) {
this.lat = lat;
this.lon = lon;
}
}
}

View File

@@ -0,0 +1,18 @@
package com.mogo.och.taxi.bean;
import com.mogo.eagle.core.data.BaseData;
/**
* Created by pangfan on 2021/8/19
* 司机端准备好或者乘客已验证上车请求参数
*/
public class TaxiLoginRespBean extends BaseData {
public TaxiLoginRespBean.Result data;
public static class Result {
public Double lat;
public Double lon;
}
}

View File

@@ -0,0 +1,14 @@
package com.mogo.och.taxi.bean;
/**
* Created by pangfan on 2021/8/19
* 司机端准备好或者乘客已验证上车请求参数
*/
public class TaxiLoginSmsReqBean {
public String phone;
public TaxiLoginSmsReqBean(String phone) {
this.phone = phone;
}
}

View File

@@ -0,0 +1,25 @@
package com.mogo.och.taxi.bean;
/**
* Created by pangfan on 2021/8/19
* 司机端准备好或者乘客已验证上车请求参数
*/
public class TaxiLogoutReqBean {
public String sn;
public Location4Login loc;
public TaxiLogoutReqBean(String sn, Location4Login location4Login) {
this.sn = sn;
this.loc = location4Login;
}
public static class Location4Login{
double lat;
double lon;
public Location4Login(double lat, double lon) {
this.lat = lat;
this.lon = lon;
}
}
}

View File

@@ -3,10 +3,12 @@ package com.mogo.och.taxi.callback;
/**
* Created on 2021/9/8
*
* Model->Presenter回调出车/收车状态变更
* Model->Presenter回调接单车状态变更 登录状态变更
*/
public interface ITaxiCarStatusCallback {
void onCarStatusChanged(boolean inOperation,String role);
void onServiceDataUpdate(long dailyTimeDuration, long dailyOrderNum);
void onCarLoginStatusChange(boolean isLogin);
}

View File

@@ -0,0 +1,18 @@
package com.mogo.och.taxi.callback;
import androidx.annotation.NonNull;
import com.mogo.och.taxi.bean.OrderQueryRespBean;
import com.mogo.och.taxi.bean.OrderQueryRouteInfoRespBean;
import java.util.List;
/**
* Created on 2021/9/8
*
* Model->Presenter回调订单相关进行中/待服务单变更,当前进行单状态变更,新到预约单,抢单,抢单结果状态等等)
*/
public interface ITaxiLoginCallback {
void getPhoneCodeSuccess();
void loginSuccess();
}

View File

@@ -80,5 +80,7 @@ class TaxiConst {
const val TYPE_MARKER_TAXI_ORDER = "TYPE_MARKER_TAXI_ORDER"
const val TIMER_START_AUTOPILOT_INTERVAL = 20 * 1000L
const val WAIT_TAKEN = 100046
}
}

View File

@@ -0,0 +1,27 @@
package com.mogo.och.taxi.constant
/**
* Created on 2022/08/19
*
*
* 0 初始状态,
* 10 已登录,
* 20 已登出,
*/
enum class TaxiLoginStatusEnum(val code: Int) {
None( 0 ),
Login( 10),
Logout( 20),;
companion object {
@JvmStatic
fun valueOf(code: Int): TaxiLoginStatusEnum? {
for (value in values()) {
if (value.code == code) {
return value
}
}
return None
}
}
}

View File

@@ -0,0 +1,27 @@
package com.mogo.och.taxi.constant
/**
* Created on 2022/08/19
*
*
* 0 初始状态,
* 10 接单状态 可接单,
* 20 暂停接到哪 不可接单,
*/
enum class TaxiOpenOrderStatusEnum(val code: Int) {
None( 0 ),
Ordering( 10),
UnOrdering( 20),;
companion object {
@JvmStatic
fun valueOf(code: Int): TaxiOpenOrderStatusEnum? {
for (value in values()) {
if (value.code == code) {
return value
}
}
return None
}
}
}

View File

@@ -0,0 +1,135 @@
package com.mogo.och.taxi.model
import android.annotation.SuppressLint
import android.content.Context
import com.mogo.eagle.core.data.BaseData
import com.mogo.eagle.core.utilcode.util.NetworkUtils
import com.mogo.och.taxi.model.TaxiLoginModel
import com.mogo.och.taxi.callback.ITaxiLoginCallback
import com.mogo.module.common.MogoApisHandler
import com.mogo.map.navi.IMogoCarLocationChangedListener2
import com.mogo.och.taxi.network.TaxiServiceManager
import com.mogo.och.taxi.network.TaxiServiceCallback
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.taxi.R
import com.mogo.och.taxi.bean.TaxiLoginReqBean
import com.mogo.och.taxi.bean.TaxiLoginRespBean
import com.mogo.och.taxi.constant.TaxiLoginStatusEnum
import com.mogo.och.taxi.utils.StatusManager
/**
* Created by pangfan on 2021/8/19
*
*
* 网约车 - 出租车业务逻辑处理
*/
@SuppressLint("StaticFieldLeak")
object TaxiLoginModel{
private val TAG = "TaxiLoginModel"
private var mContext: Context? = null
var iTaxiLoginCallback: ITaxiLoginCallback? = null
private var mLongitude = 0.0
private var mLatitude = 0.0
fun init(context: Context) {
mContext = context.applicationContext
// 达到起始站围栏监听
MogoApisHandler.getInstance()
.apis
.registerCenterApi
.registerCarLocationChangedListener(TAG, mCarLocationChangedListener2)
}
fun hasInit():Boolean{
if(mContext==null&& iTaxiLoginCallback==null){
return false;
}
return true
}
// 自车定位
private val mCarLocationChangedListener2 = IMogoCarLocationChangedListener2 { location ->
mLongitude = location.longitude
mLatitude = location.latitude
}
fun getiTaxiLoginCallback(): ITaxiLoginCallback? {
return iTaxiLoginCallback
}
fun setiTaxiLoginCallback(iTaxiLoginCallback: ITaxiLoginCallback?) {
this.iTaxiLoginCallback = iTaxiLoginCallback
}
fun release() {
mContext = null
iTaxiLoginCallback = null
// 注销到达起始站围栏监听
MogoApisHandler.getInstance().apis.registerCenterApi
.unregisterCarLocationChangedListener(TAG, mCarLocationChangedListener2)
}
/**
* 获取手机验证码
*/
fun getPhoneCode(phone: String?) {
TaxiServiceManager.getInstance().getPhoneCode(mContext, phone,
object : TaxiServiceCallback<BaseData?> {
override fun onSuccess(data: BaseData?) {
if (null != data && 0 == data.code) {
// 获取验证码成功
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_get_code_success))
iTaxiLoginCallback?.getPhoneCodeSuccess()
} else {
if (data != null) {
ToastUtils.showShort(data.code)
}
}
}
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))
}
}
override fun onFail(code: Int, msg: String) {
ToastUtils.showShort("$code,$msg")
}
})
}
fun gotoLogin(phone: String, code: String) {
val location4Login = TaxiLoginReqBean.Location4Login(mLatitude, mLongitude)
TaxiServiceManager.getInstance().gotoLoginBycode(mContext, phone, code, location4Login,
object : TaxiServiceCallback<TaxiLoginRespBean?> {
override fun onSuccess(data: TaxiLoginRespBean?) {
if (null != data && 0 == data.code) {
// 获取验证码成功
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_login_success))
StatusManager.setLoginStatus(TaxiLoginStatusEnum.Login)
iTaxiLoginCallback?.loginSuccess()
} else {
if (data != null) {
ToastUtils.showShort(data.code)
}
}
}
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))
}
}
override fun onFail(code: Int, msg: String) {
ToastUtils.showShort("$code,$msg")
}
})
}
}

View File

@@ -36,6 +36,7 @@ import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
import com.mogo.och.common.module.utils.PinYinUtil;
import com.mogo.och.common.module.utils.ToastUtilsOch;
import com.mogo.och.taxi.R;
import com.mogo.och.taxi.bean.DriverServiceDataRespBean;
import com.mogo.och.taxi.bean.DriverStatusQueryRespBean;
@@ -49,6 +50,7 @@ import com.mogo.och.taxi.bean.OrdersListQueryRespBean;
import com.mogo.och.taxi.bean.OrdersNewBookingQueryRespBean;
import com.mogo.och.taxi.bean.QueryOrderRouteResp;
import com.mogo.och.taxi.bean.TaxiDataBaseRespBean;
import com.mogo.och.taxi.bean.TaxiLogoutReqBean;
import com.mogo.och.taxi.bean.TaxiOrPassengerReadyReqBean;
import com.mogo.och.taxi.callback.ITaxiADASStatusCallback;
import com.mogo.och.taxi.callback.ITaxiCarStatusCallback;
@@ -60,6 +62,7 @@ import com.mogo.och.taxi.constant.TaxiOrderStatusEnum;
import com.mogo.och.taxi.constant.TaxiOrderTypeEnum;
import com.mogo.och.taxi.network.TaxiServiceCallback;
import com.mogo.och.taxi.network.TaxiServiceManager;
import com.mogo.och.taxi.utils.StatusManager;
import com.mogo.och.taxi.utils.TaxiAnalyticsManager;
import com.mogo.och.taxi.utils.OrderUtil;
import com.mogo.aicloud.services.socket.IMogoLifecycleListener;
@@ -76,7 +79,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.UndeliverableException;
import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins;
@@ -103,7 +109,6 @@ public class TaxiModel {
private Context mContext;
private volatile int mPrevAPStatus = -1; //前一次自动驾驶状态值
private volatile int mOCHCarStatus = -1; //出车/收车状态1 出车0 收车
private volatile String mPrevOrderNo = ""; //前一次的新到单id当次和前一次orderId相同时本次不再弹出
private volatile OrderQueryRespBean.Result mNewBookingOrder; //新到待抢预约单
private volatile OrderQueryRespBean.Result mCurrentOCHOrder; //当前订单
@@ -111,9 +116,10 @@ public class TaxiModel {
private volatile List<OrderQueryRespBean.Result> mWaitServiceList = Collections.emptyList(); //待服务订单
private ITaxiADASStatusCallback mADASStatusCallback; //Model->Presenter自动驾驶状态相关
private ITaxiCarStatusCallback mCarStatusCallback; //Model->Presenter出车/收车状态
private ITaxiCarStatusCallback mCarStatusCallback; //Model->Presenter接单状态、登录状态和司机今日接单状态
private ITaxiControllerStatusCallback mControllerStatusCallback; //Model->PresenterVR mode等
private ITaxiOrderStatusCallback mOrderStatusCallback; //Model->Presenter订单变更
private Disposable subscribe;
private volatile boolean isRestartAutopilot = false;
@@ -187,16 +193,16 @@ public class TaxiModel {
CallerLogger.INSTANCE.d(M_TAXI + TAG, "Undeliverable exception");
}
});
if (NetworkUtils.isConnected(mContext)) {
queryCarStatus();
}
queryCarStatus();
}
public void release() {
startOrStopOrderLoop(false);
startOrStopCalculateRouteInfo(false);
releaseListeners();
if(subscribe!=null&&!subscribe.isDisposed()){
subscribe.dispose();
}
}
private void initListeners() {
@@ -255,17 +261,28 @@ public class TaxiModel {
}
}
//查询出车/收车状态
/**
* 接单状态和登录状态查询
* 1、初始化查下状态
* 2、点击更新接单状态 如果是初始化状态就查下状态
* 3、点击更新接单状态后 查询状态
* 4、网络状态波动时 查询状态
* 5、登出后更新状态
*/
public void queryCarStatus() {
TaxiServiceManager.getInstance().queryDriverServiceStatus(mContext,
new TaxiServiceCallback<DriverStatusQueryRespBean>() {
@Override
public void onSuccess(DriverStatusQueryRespBean data) {
if (null != data && 0 == data.code) {
mOCHCarStatus = data.data.serviceStatus == 1 ? 1 : 0;
StatusManager.setLoginStatus(data.data.driverStatus);
StatusManager.setOpenOrderStatus(data.data.servingStatus);
//更新view
CallerLogger.INSTANCE.d(M_TAXI + TAG, "changeCarStatus:" + mOCHCarStatus);
startOrStopOrderLoop(mOCHCarStatus == 1);
CallerLogger.INSTANCE.d(M_TAXI + TAG, "changeCarStatus:" + StatusManager.getLoginStatus());
startOrStopOrderLoop(StatusManager.isLogin()&&StatusManager.isOpeningOrderStatus());
if(mCarStatusCallback!=null) {
mCarStatusCallback.onCarLoginStatusChange(StatusManager.isLogin());
}
String role = "";
if (TaxiDriverRoleEnum.DEMO.getCode() == data.data.purpose) {
role = TaxiConst.DEMO_USER;
@@ -273,7 +290,7 @@ public class TaxiModel {
role = TaxiConst.TEST_USER;
}
if (mCarStatusCallback != null) {
mCarStatusCallback.onCarStatusChanged(mOCHCarStatus == 1, role);
mCarStatusCallback.onCarStatusChanged(StatusManager.isOpeningOrderStatus(), role);
}
}
@@ -286,30 +303,39 @@ public class TaxiModel {
} else {
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
}
// queryCarStatus();
subscribe = Observable.timer(5, TimeUnit.SECONDS).subscribe(aLong -> {
queryCarStatus();
});
}
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(code + "," + msg);
// queryCarStatus();
ToastUtilsOch.showWithCodeMessage(code,msg);
if(code==TaxiConst.WAIT_TAKEN){
subscribe = Observable.timer(3, TimeUnit.SECONDS).subscribe(aLong -> {
queryCarStatus();
});
}else {
if (mCarStatusCallback != null) {
mCarStatusCallback.onCarLoginStatusChange(StatusManager.isLogin());
}
}
}
});
}
//更新出车收车状态
//更新接单状态
public void updateCarStatus() {
if (mOCHCarStatus == -1) {
if(!StatusManager.isLogin()){
queryCarStatus();
return;
}
final int status = mOCHCarStatus == 1 ? 0 : 1;
TaxiServiceManager.getInstance().updateDriverServiceStatus(mContext, status,
TaxiServiceManager.getInstance().changeOrderServing(mContext,StatusManager.isOpeningOrderStatus(),
new TaxiServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
if (null != data && 0 == data.code) {
mOCHCarStatus = status;
//StatusManager.changeOrderStatus();
queryCarStatus();
}
}
@@ -325,9 +351,10 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(code + "," + msg);
ToastUtilsOch.showWithCodeMessage(code, msg);
}
});
}
/**
@@ -470,7 +497,7 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(code + "," + msg);
ToastUtilsOch.showWithCodeMessage(code,msg);
}
});
}
@@ -499,7 +526,7 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(code + "," + msg);
ToastUtilsOch.showWithCodeMessage(code,msg);
}
});
}
@@ -553,7 +580,7 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(code + "," + msg);
ToastUtilsOch.showWithCodeMessage(code,msg);
}
});
}
@@ -647,7 +674,7 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(code + "," + msg);
ToastUtilsOch.showWithCodeMessage(code,msg);
}
});
}
@@ -741,7 +768,7 @@ public class TaxiModel {
@Override
public void onFail(int code, String msg) {
ToastUtils.showShort(code + "," + msg);
ToastUtilsOch.showWithCodeMessage(code,msg);
}
});
}
@@ -832,6 +859,7 @@ public class TaxiModel {
&& mCurrentOCHOrder.orderStatus == TaxiOrderStatusEnum.OnTheWayToEnd.getCode()) {
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后置true
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true;
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(true);
CallerAutoPilotManager.INSTANCE.setIPCDemoMode(true);
CallerLogger.INSTANCE.d(M_TAXI + TAG, "美化模式-ignore置为true更新本地order信息");
}
@@ -839,6 +867,7 @@ public class TaxiModel {
//清除订单信息
public void clearCurrentOCHOrder() {
startOrStopCalculateRouteInfo(false);
mCurrentOCHOrder = null;
TaxiTrajectoryManager.getInstance().syncTrajectoryInfo();
SharedPrefsMgr.getInstance(mContext).remove(TaxiConst.SP_KEY_OCH_TAXI_ORDER);
@@ -846,6 +875,7 @@ public class TaxiModel {
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 取消或订单已完成时置false
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false;
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(false);
CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false);
CallerLogger.INSTANCE.d(M_TAXI + TAG, "美化模式-ignore置为false已完成or清除当前订单");
}
@@ -972,7 +1002,7 @@ public class TaxiModel {
CallerLogger.INSTANCE.d(M_TAXI + TAG, "onIntentReceived = %s", intentStr);
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intentStr)) {
if (NetworkUtils.isConnected(mContext)) {
startOrStopOrderLoop(mOCHCarStatus == 1);
startOrStopOrderLoop(StatusManager.isLogin()&&StatusManager.isOpeningOrderStatus());
queryCarStatus();
}
}
@@ -1135,6 +1165,7 @@ public class TaxiModel {
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后置true
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true;
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(true);
CallerAutoPilotManager.INSTANCE.setIPCDemoMode(true);
CallerLogger.INSTANCE.d(M_TAXI + TAG, "美化模式-ignore置为true到达出发点且已开启自动驾驶");
}
@@ -1166,11 +1197,16 @@ public class TaxiModel {
mPrevAPStatus = state;
}else if (state == IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING){
if (FunctionBuildConfig.isDemoMode
&& checkCurrentOCHOrder()
&& (getCurOrderStatus() == TaxiOrderStatusEnum.OnTheWayToEnd
|| getCurOrderStatus() == TaxiOrderStatusEnum.ArriveAtEnd)) {
// 当美化模式演示模式开启时且有订单、且为去往目的地状态维持自动驾驶icon开启状态
if (FunctionBuildConfig.isDemoMode){
if (checkCurrentOCHOrder()
&& (getCurOrderStatus() == TaxiOrderStatusEnum.OnTheWayToEnd
|| getCurOrderStatus() == TaxiOrderStatusEnum.ArriveAtEnd)){//订单中
// 当美化模式演示模式开启时且有订单、且为去往目的地状态维持自动驾驶icon开启状态
}else { //美化模式下没订单,显示人工驾驶
if (mADASStatusCallback != null){
mADASStatusCallback.onAutopilotDisable();
}
}
return;
}
if (state != mPrevAPStatus && mADASStatusCallback != null){
@@ -1198,6 +1234,7 @@ public class TaxiModel {
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 到达目的地置false
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false;
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(false);
CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false);
CallerLogger.INSTANCE.d(M_TAXI + TAG, "美化模式-ignore置为false到达目的地");
}
@@ -1292,14 +1329,30 @@ public class TaxiModel {
queryOrderRouteList(mCurrentOCHOrder.orderNo);
}
Logger.d(M_TAXI + TAG, "--------mRoutePoints.size---------- " + mRoutePoints.size());
if (mRoutePoints.size() > 0){
reportTotalDisAndTime();
}
//开启实时计算剩余距离,剩余时间,预计时间
startOrStopCalculateRouteInfo(true);
}
private void reportTotalDisAndTime() {
float lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mRoutePoints);
double lastTime = lastSumLength / TaxiConst.TAXI_AVERAGE_SPEED * 3.6; //秒
// if (mOrderStatusCallback != null) {
// mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long) lastTime);
// }
reportOrderRemain((long) lastSumLength, (long) lastTime);
}
/**
* 实时计算当前剩余里程和时间
*/
public void dynamicCalculateRouteInfo() {
if (mLatitude <= 0.0 || mLongitude <= 0.0){
return;
}
if (mRoutePoints.size() > 0){
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
.getRemainPointListByCompare(mRoutePoints, mLongitude, mLatitude);
@@ -1367,7 +1420,7 @@ public class TaxiModel {
TaxiModelLoopManager.getInstance().startCalculateRouteInfoLoop();
} else {
mRoutePoints.clear();
TaxiModelLoopManager.getInstance().stopCalculateRouteInfLoop();
TaxiModelLoopManager.getInstance().stopCalculateRouteInfoLoop();
}
}
@@ -1524,4 +1577,33 @@ public class TaxiModel {
mOrderStatusCallback.onCurrentOrderStatusChanged(mCurrentOCHOrder);
}
}
// 登出
public void logout() {
TaxiLogoutReqBean.Location4Login location4Login = new TaxiLogoutReqBean.Location4Login(mLatitude, mLongitude);
TaxiServiceManager.getInstance().logout(mContext,location4Login,
new TaxiServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
if (null != data && 0 == data.code) {
mCarStatusCallback.onCarLoginStatusChange(false);
queryCarStatus();
}
}
@Override
public void onError() {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
} else {
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
}
}
@Override
public void onFail(int code, String msg) {
ToastUtilsOch.showWithCodeMessage(code,msg);
}
});
}
}

View File

@@ -166,9 +166,9 @@ public class TaxiModelLoopManager {
});
}
public void stopCalculateRouteInfLoop() {
public void stopCalculateRouteInfoLoop() {
if (mCalculateRouteDisposable != null) {
CallerLogger.INSTANCE.i(M_TAXI + TAG, "stopCalculateRouteInfLoop()");
CallerLogger.INSTANCE.i(M_TAXI + TAG, "stopCalculateRouteInfoLoop()");
mCalculateRouteDisposable.dispose();
mCalculateRouteDisposable = null;
}

View File

@@ -20,6 +20,10 @@ import com.mogo.och.taxi.bean.OrdersListQueryRespBean;
import com.mogo.och.taxi.bean.OrdersNewBookingQueryRespBean;
import com.mogo.och.taxi.bean.QueryOrderRouteResp;
import com.mogo.och.taxi.bean.TaxiDataBaseRespBean;
import com.mogo.och.taxi.bean.TaxiLoginReqBean;
import com.mogo.och.taxi.bean.TaxiLoginRespBean;
import com.mogo.och.taxi.bean.TaxiLoginSmsReqBean;
import com.mogo.och.taxi.bean.TaxiLogoutReqBean;
import com.mogo.och.taxi.bean.TaxiOrPassengerReadyReqBean;
import com.mogo.och.taxi.bean.UpdateOrderDisAndTimeReqBean;
@@ -150,28 +154,6 @@ interface TaxiServiceApiNew {
Observable<BaseData> updateOrderStatus(@Header ("appId") String appId,@Header("ticket") String ticket
,@Body OrderStatusUpdateReqBean data);
/**
* 收车/出车状态更新
* @param data
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
// @POST( "/autopilot-car-hailing/api/v1/driver/serviceStatus/update" )
@POST( "/autopilot-car-hailing/car/v2/driver/taxi/serviceStatus/update" )
Observable<BaseData> updateDriverServiceStatus(@Header ("appId") String appId,@Header("ticket") String ticket
,@Body DriverStatusUpdateReqBean data);
/**
* 收车/出车状态查询
* @param sn
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
// @GET( "/autopilot-car-hailing/api/v1/driver/serviceStatus/query" )
@GET( "/autopilot-car-hailing/car/v2/driver/taxi/serviceStatus/query" )
Observable<DriverStatusQueryRespBean> queryDriverServiceStatus(@Header ("appId") String appId
,@Header("ticket") String ticket,@Query("sn") String sn);
/**
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
* @param data
@@ -307,4 +289,65 @@ interface TaxiServiceApiNew {
@POST( "/autopilot-car-hailing/cab/flow/v1/driver/taxi/orderCompleted" )
Observable<TaxiDataBaseRespBean> orderCompleted(@Header ("appId") String appId
, @Header("ticket") String ticket,@Body TaxiOrPassengerReadyReqBean data);
/**
* 获取手机验证码
*
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
// @GET( "/autopilot-car-hailing/api/v1/driver/serviceStatus/query" )
@POST( "/autopilot-car-hailing/driver/v2/driver/taxi/sendSms" )
Observable<DriverStatusQueryRespBean> getPhoneCode(@Header ("appId") String appId
,@Header("ticket") String ticket,@Body TaxiLoginSmsReqBean data);
/**
* 通过验证码登录
* @param appId
* @param ticket
* @param data
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
@POST( "/autopilot-car-hailing/cab/flow/v1/driver/taxi/startOperation" )
Observable<TaxiLoginRespBean> gotoLoginBycode(@Header ("appId") String appId
, @Header("ticket") String ticket, @Body TaxiLoginReqBean data);
/**
* 登出接口
*/
@Headers({"Content-type:application/json;charset=UTF-8"})
@POST("/autopilot-car-hailing/cab/flow/v1/driver/taxi/endOperation")
Observable<BaseData> logout(@Header ("appId") String appId,@Header("ticket") String ticket,
@Body TaxiLogoutReqBean data);
/**
* 暂停接单
* @param data
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
// @POST( "/autopilot-car-hailing/api/v1/driver/serviceStatus/update" )
@POST( "/autopilot-car-hailing/cab/flow/v1/driver/taxi/stopOrderServing" )
Observable<BaseData> stopOrderServing(@Header ("appId") String appId,@Header("ticket") String ticket
,@Body DriverStatusUpdateReqBean data);
/**
* 暂停接单
* @param data
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
// @POST( "/autopilot-car-hailing/api/v1/driver/serviceStatus/update" )
@POST( "/autopilot-car-hailing/cab/flow/v1/driver/taxi/resetOrderServing" )
Observable<BaseData> resetOrderServing(@Header ("appId") String appId,@Header("ticket") String ticket
,@Body DriverStatusUpdateReqBean data);
/**
* 接单状态和登录状态查询
* @param sn
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
// @GET( "/autopilot-car-hailing/api/v1/driver/serviceStatus/query" )
@GET( "/autopilot-car-hailing/operation/v1/driver/taxi/loginStatus" )
Observable<DriverStatusQueryRespBean> queryDriverServiceStatusAndLoginStatus(@Header ("appId") String appId
,@Header("ticket") String ticket,@Query("sn") String sn);
}

View File

@@ -4,6 +4,7 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAX
import android.content.Context;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.eagle.core.data.BaseData;
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
@@ -30,12 +31,17 @@ import com.mogo.och.taxi.bean.OrdersListQueryRespBean;
import com.mogo.och.taxi.bean.OrdersNewBookingQueryRespBean;
import com.mogo.och.taxi.bean.QueryOrderRouteResp;
import com.mogo.och.taxi.bean.TaxiDataBaseRespBean;
import com.mogo.och.taxi.bean.TaxiLoginReqBean;
import com.mogo.och.taxi.bean.TaxiLoginRespBean;
import com.mogo.och.taxi.bean.TaxiLoginSmsReqBean;
import com.mogo.och.taxi.bean.TaxiLogoutReqBean;
import com.mogo.och.taxi.bean.TaxiOrPassengerReadyReqBean;
import com.mogo.och.taxi.bean.UpdateOrderDisAndTimeReqBean;
import com.mogo.och.taxi.constant.TaxiConst;
import java.util.List;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
@@ -232,31 +238,44 @@ public class TaxiServiceManager {
.subscribe(getSubscribeImpl(context, callback, "updateOrderStatus"));
}
/**
* 收车/出车状态更新
* 暂停接单
* @param context
* @param status
* @param callback
*/
public void updateDriverServiceStatus(Context context, int status,
TaxiServiceCallback<BaseData> callback) {
mOCHTaxiServiceApi.updateDriverServiceStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new DriverStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().getSn(), status))
.subscribeOn(Schedulers.io())
public void changeOrderServing(Context context,boolean isOrdering,
TaxiServiceCallback<BaseData> callback) {
Observable<BaseData> baseDataObservable = null;
if(isOrdering) {// 正在接单去暂停
baseDataObservable = mOCHTaxiServiceApi.stopOrderServing(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new DriverStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().getSn()));
}else {// 没有接单去接单
baseDataObservable = mOCHTaxiServiceApi.resetOrderServing(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new DriverStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().getSn()));
}
baseDataObservable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "updateDriverServiceStatus"));
}
/**
* 收车/出车状态查询
* 接单状态和登录状态查询
* @param context
* @param callback
*/
public void queryDriverServiceStatus(Context context,
TaxiServiceCallback<DriverStatusQueryRespBean> callback) {
mOCHTaxiServiceApi.queryDriverServiceStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
if(MoGoAiCloudClientConfig.getInstance().getToken().isEmpty()){
callback.onFail(TaxiConst.WAIT_TAKEN,"等待令牌中请稍等");
MoGoAiCloudClient.getInstance().refreshToken();
return;
}
mOCHTaxiServiceApi.queryDriverServiceStatusAndLoginStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,MoGoAiCloudClientConfig.getInstance().getSn())
.subscribeOn(Schedulers.io())
@@ -436,6 +455,52 @@ public class TaxiServiceManager {
}
/**
* 获取手机验证码
* @param context
* @param callback
*/
public void getPhoneCode(Context context,String phone,
TaxiServiceCallback<BaseData> callback) {
mOCHTaxiServiceApi.getPhoneCode(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new TaxiLoginSmsReqBean(phone))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "getPhoneCode"));
}
/**
* 通过验证码登录
* @param context
* @param callback
*/
public void gotoLoginBycode(Context context, String phone, String code,
TaxiLoginReqBean.Location4Login location4Login,
TaxiServiceCallback<TaxiLoginRespBean> callback) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
mOCHTaxiServiceApi.gotoLoginBycode(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new TaxiLoginReqBean(phone, code, sn, location4Login))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "gotoLoginBycode"));
}
/**
* 登出
*/
public void logout(Context context, TaxiLogoutReqBean.Location4Login location4Login, TaxiServiceCallback<BaseData> callback) {
mOCHTaxiServiceApi.logout(
MoGoAiCloudClientConfig.getInstance().getServiceAppId(),
MoGoAiCloudClientConfig.getInstance().getToken(),
new TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().getSn(), location4Login))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "logout"));
}
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
Context context, TaxiServiceCallback<T> callback, String apiName) {
return new SubscribeImpl<T>(RequestOptions.create(context)) {

View File

@@ -0,0 +1,112 @@
package com.mogo.och.taxi.presenter
import androidx.lifecycle.LifecycleOwner
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.mvp.Presenter
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.RegexUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.taxi.R
import com.mogo.och.taxi.callback.ITaxiLoginCallback
import com.mogo.och.taxi.model.TaxiLoginModel
import com.mogo.och.taxi.ui.TaxiLoginDialogFragment
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import java.util.concurrent.TimeUnit
/**
* @author congtaowang
* @since 2021/1/18
*
* 描述
*/
class TaxiLoginPresenter(view: TaxiLoginDialogFragment?) :
Presenter<TaxiLoginDialogFragment?>(view), ITaxiLoginCallback {
private var countDownDisposable: Disposable? = null
init {
initListeners()
}
private fun initListeners() {
TaxiLoginModel.init(AbsMogoApplication.getApp())
TaxiLoginModel.setiTaxiLoginCallback(this)
}
fun getPhoneCode(phone:String){
if(!TaxiLoginModel.hasInit()){
initListeners()
}
if (!RegexUtils.isMobileExact(phone)) {
ToastUtils.showShort(R.string.module_och_taxi_login_phone_error)
mView?.inputPhoneError()
return
}
TaxiLoginModel.getPhoneCode(phone)
}
override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
CallerLogger.d(SceneConstant.M_TAXI + TAG, "网约车-出租车登陆")
}
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
TaxiLoginModel.release()
countDownDisposable?.let {
if (!it.isDisposed) {
it.dispose()
}
}
}
companion object {
private val TAG = TaxiLoginPresenter::class.java.simpleName
}
override fun getPhoneCodeSuccess() {
val countDownSeconds = 60L;
countDownDisposable = Observable.intervalRange(0, countDownSeconds, 0, 1, TimeUnit.SECONDS)
.map { aLong -> countDownSeconds - aLong }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
mView?.setCountDownText("${it}s",false)
CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "倒计时:$it")
}, {
CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "倒计时onError:${it}")
it.printStackTrace()
mView?.setCountDownText(context.getString(R.string.module_och_taxi_login_get_code),true)
}, {
CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "倒计时onComplete")
mView?.setCountDownText(context.getString(R.string.module_och_taxi_login_get_code),true)
})
}
override fun loginSuccess() {
mView?.loginSuccess()
}
fun gotoLogin(phone: String, code: String) {
if(!TaxiLoginModel.hasInit()){
initListeners()
}
if (!RegexUtils.isMobileExact(phone)) {
ToastUtils.showShort(R.string.module_och_taxi_login_phone_error)
mView?.inputPhoneError()
return
}
if(code.isBlank()||code.length<4){
ToastUtils.showShort(R.string.module_och_taxi_login_code_error)
return
}
mView?.closeSoftInput()
TaxiLoginModel.gotoLogin(phone,code)
}
}

View File

@@ -41,6 +41,9 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
private static final String TAG = TaxiPresenter.class.getSimpleName();
private boolean isFirstShow = true;
private int preAutopilotStatus = 0;
public TaxiPresenter(TaxiFragment view) {
super(view);
TaxiModel.getInstance().init(AbsMogoApplication.getApp());
@@ -61,6 +64,16 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
TaxiModel.getInstance().release();
}
@Override
public void onResume(@NonNull LifecycleOwner owner) {
super.onResume(owner);
if(isFirstShow){
isFirstShow = false;
}else {
TaxiModel.getInstance().queryCarStatus();
}
}
private void initListeners() {
TaxiModel.getInstance().setADASStatusCallback(this);
TaxiModel.getInstance().setCarStatusCallback(this);
@@ -100,6 +113,13 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
TaxiModel.getInstance().jumpPassengerCheckDone();
}
/**
* 登录成功后查询登录状态
*/
public void queryLoginStatus() {
TaxiModel.getInstance().queryCarStatus();
}
/**
* 司机确认车辆环境可开启自动驾驶
*/
@@ -107,7 +127,7 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
TaxiModel.getInstance().confirmAutopilotConditionByDriver();
}
// 更新出车/收车状态
// 更新接单状态
public void updateCarStatus() {
TaxiModel.getInstance().updateCarStatus();
}
@@ -158,6 +178,11 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
TaxiModel.getInstance().orderCompleted();
}
// 登出
public void logout() {
TaxiModel.getInstance().logout();
}
@Override
public void onAutopilotArriveEnd() {
@@ -167,24 +192,30 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
public void onAutopilotEnable() {
runOnUIThread(() -> mView.updateAutopilotStatus(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE));
preAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE;
}
@Override
public void onAutopilotDisable() {
runOnUIThread(() -> mView.updateAutopilotStatus(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE));
preAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE;
}
@Override
public void onAutopilotRunning() {
runOnUIThread(() -> mView.updateAutopilotStatus(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING));
if (preAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
runOnUIThread(() -> mView.updateAutopilotStatus(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING));
}
preAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING;
}
@Override
public void onManMachineCoDriving() {
runOnUIThread(() -> mView.onManMachineCoDriving(IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING));
preAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING;
}
@Override
@@ -197,6 +228,15 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
runOnUIThread(() -> mView.onServiceDataUpdate(dailyTimeDuration,dailyOrderNum));
}
@Override
public void onCarLoginStatusChange(boolean isLogin) {
if(isLogin){
mView.hideLoginDialogFragment();
}else {
mView.showLoginDialogFragment();
}
}
@Override
public void onOrdersInServiceChanged(@NonNull @NotNull List<OrderQueryRespBean.Result> inServiceList) {

View File

@@ -5,6 +5,8 @@ import static com.mogo.och.taxi.constant.TaxiConst.TIMER_START_AUTOPILOT_INTERVA
import android.animation.ObjectAnimator;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.LinearInterpolator;
@@ -19,6 +21,7 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction;
import com.mogo.cloud.httpdns.util.L;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.mvp.IView;
@@ -65,7 +68,6 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
private ImageView mAnimFlowIv;
protected TextView tvOperationStatus;
protected TextView mDriverRole;
public boolean isOperationStatus;//false-收车true-出车
protected FrameLayout flStationPanelContainer;
private FrameLayout flNaviPanelContainer;
private Group groupTestPanel;
@@ -165,8 +167,8 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
mSpeedView = findViewById(R.id.module_mogo_och_speed_tv);
mCloseNaviIcon = findViewById(R.id.taxi_close_navi_icon);
flNaviPanelContainer = findViewById(R.id.module_mogo_och_navi_panel_container);
if (DebugConfig.isDebug()) {
mSpeedView.setLongClickable(true);
// if (DebugConfig.isDebug()) {
mSpeedView.setLongClickable(true); //调试按钮任意模式下都开
// TODO: 2021/11/27 暂去除此调试功能
// mSpeedView.setOnClickListener(v -> {
// onAutopilotStatusChanged(false);
@@ -178,7 +180,7 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
// MogoApisHandler.getInstance().getApis().getIntentManagerApi().invoke("com.mogo.mock", intent);
// return true;
// });
}
// }
tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status);
mDriverRole = findViewById(R.id.taxi_driver_role_tv);
@@ -190,24 +192,30 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
@Override
public void onClick(View v) {
//视角切换
if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight()) {
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) .visibleAllMarkers();
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
mSwitchBtnIcon.setImageResource(R.drawable.taxi_switch_map_medium);
} else if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isMediumSight()) {
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
.inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS, TaxiConst.TYPE_MARKER_TAXI_ORDER);
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null);
mSwitchBtnIcon.setImageResource(R.drawable.taxi_switch_map_long);
long start = SystemClock.elapsedRealtime();
try {
if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight()) {
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) .visibleAllMarkers();
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
mSwitchBtnIcon.setImageResource(R.drawable.taxi_switch_map_medium);
} else if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isMediumSight()) {
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
.inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS, TaxiConst.TYPE_MARKER_TAXI_ORDER);
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null);
mSwitchBtnIcon.setImageResource(R.drawable.taxi_switch_map_long);
} else {
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) .visibleAllMarkers();
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
mSwitchBtnIcon.setImageResource(R.drawable.taxi_switch_map_medium);
}
} finally {
Log.d("XXXX", "cost:" + (SystemClock.elapsedRealtime() - start));
}
}
});
mPersonalBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onGoToTaxiOrders();
}
});
mPersonalBtn.setOnClickListener(v -> onGoToTaxiOrders());
mSettingBtn = findViewById(R.id.module_och_taxi_setting_layout);
mSettingBtn.setOnClickListener(v -> {
@@ -237,9 +245,6 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING){
return; //远程代驾状态下不可开启自动驾驶,只能等远程代驾主动退出
}else if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
ToastUtils.showShort(getResources().getString(R.string.module_och_taxi_auto_disable_tip));
}else if (!(boolean)ctvAutopilotStatusRL.getTag()){
ToastUtils.showShort(getResources().getString(R.string.module_och_taxi_auto_disable_tip1));
}else {
@@ -248,8 +253,8 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
}
});
// debug下调用测试面板 长按速度值
if (DebugConfig.isDebug()) {
// debug下调用测试面板 长按速度值 任意模式下调试都打开
// if (DebugConfig.isDebug()) {
mSpeedView.setOnLongClickListener(v -> {
if (groupTestPanel.getVisibility() == View.VISIBLE) {
groupTestPanel.setVisibility(View.GONE);
@@ -258,7 +263,7 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
}
return false;
});
}
// }
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());

View File

@@ -143,9 +143,9 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
isHaveBeingOrder(false);
if (DebugConfig.isDebug()) {
// if (DebugConfig.isDebug()) { //任意模式下调试信息都打开
initOrderTestBar(view);
}
// }
}
@Override
@@ -470,6 +470,7 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
showOrHideNavi(false);
setOrRemoveMapMaker(false, TaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.raw.star_marker);
setOrRemoveMapMaker(false, TaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.raw.end_marker);
clearSmallMapRouteLine();
break;
case JourneyCompleted:
mCurrentOrder = null;
@@ -497,6 +498,7 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
mNoDataView.setVisibility(View.GONE);
mBeingOrderLayout.setVisibility(View.VISIBLE);
mTaxiFragment.changeOperationViewVisible(View.GONE);
clearSmallMapRouteLine();
} else {
mNoDataView.setVisibility(View.VISIBLE);
mNoDatasTv.setText("暂无进行中订单");

View File

@@ -5,14 +5,21 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAX
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.temp.EventLogout;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.och.taxi.R;
@@ -23,6 +30,10 @@ import com.mogo.och.taxi.model.TaxiModel;
import com.mogo.och.taxi.presenter.TaxiPresenter;
import com.mogo.och.taxi.utils.TPRouteDataTestUtils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.lang.ref.WeakReference;
import java.util.List;
@@ -47,10 +58,18 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
private TaxiGrabOrderFragment grabOrderFragment;
private TaxiServerOrdersFragment serverOrdersFragment;
private WeakReference<TaxiLoginDialogFragment> taxiLoginDialogFragment = null;
private WeakReference<TaxiPersonalDialogFragment> personalDialogFragment = null;
protected double mCurLatitude = 0.0;
protected double mCurLongitude = 0.0;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
EventBus.getDefault().register(this);
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public int getStationPanelViewId() {
return R.layout.taxi_panel;
@@ -148,11 +167,16 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
@Override
public void onDestroyView() {
super.onDestroyView();
EventBus.getDefault().unregister(this);
}
/**
* 状态变更
* @param inOperation true 可以接单 false 暂停接单
* @param role 测试车辆:测试 演示车辆V 运营车辆: ""空
*/
public void updateOperationStatus(boolean inOperation,String role) {
CallerLogger.INSTANCE.e(M_TAXI + TAG, "onOperationChanged:" + inOperation);
isOperationStatus = inOperation;
if (inOperation) {
if (!TextUtils.isEmpty(role)){
mDriverRole.setVisibility(View.VISIBLE);
@@ -160,14 +184,14 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
}else {
mDriverRole.setVisibility(View.GONE);
}
tvOperationStatus.setText("收车");
tvOperationStatus.setText("暂停接单");
mPersonalBtn.setVisibility(View.VISIBLE);
tvOperationStatus.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.taxi_back_btn), null, null, null);
showPanel();
} else {
mDriverRole.setVisibility(View.GONE);
// AIAssist.getInstance(getContext()).speakTTSVoice("已收车");
tvOperationStatus.setText("出车");
// AIAssist.getInstance(getContext()).speakTTSVoice("已接单");
tvOperationStatus.setText("接单");
tvOperationStatus.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.taxi_out_btn), null, null, null);
mPersonalBtn.setVisibility(View.GONE);
hidPanel();
@@ -180,23 +204,6 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
personalDialogFragment.get().show(getActivity().getSupportFragmentManager(), "service_data");
}
// public void routeResult(List<AutopilotRouteInfo.RouteModels> routeList) {
// if (routeList == null ) return;
// double distance = calculateTravelDistance(mogoLocation,routeList);
// if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
// MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
// updateOrderBaseStatusInfo();
// }
// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","routeResult 剩余导航距离:"+distance);
// if (routeList != null && routeList.size() >0){
// CallerLogger.INSTANCE.d(M_TAXI + "lianglihui","routeResult:"+routeList.size());
// //adas回调导航路径 绘制引导线
// if ( ochTaxiOverlayManager == null){
// ochTaxiOverlayManager = new TaxiOverlayManager(this.getContext());
// }
// ochTaxiOverlayManager.draw(mogoLocation,routeList);
// }
// }
@Override
public void onMapLoaded() {
}
@@ -369,6 +376,48 @@ public class TaxiFragment extends BaseTaxiTabFragment<TaxiFragment, TaxiPresente
});
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void changeOverview(EventLogout eventLogout){
CallerLogger.INSTANCE.d(M_TAXI + TAG,"changeOverview Event消息去登出");
mPresenter.logout();
}
public void showLoginDialogFragment(){
CallerHmiManager.INSTANCE.hideToolsView();
Fragment fragmentByTag = getParentFragmentManager().findFragmentByTag(TaxiLoginDialogFragment.Companion.getTAG());
if(fragmentByTag instanceof DialogFragment){
DialogFragment dialogFragment = (DialogFragment)fragmentByTag;
if(dialogFragment.getDialog()!=null&&dialogFragment.getDialog().isShowing()){
return;
}
}
if(taxiLoginDialogFragment==null||taxiLoginDialogFragment.get()==null) {
taxiLoginDialogFragment = new WeakReference<>(TaxiLoginDialogFragment.newInstance());
}
TaxiLoginDialogFragment taxiLoginDialog = taxiLoginDialogFragment.get();
if(taxiLoginDialog!=null) {
if (taxiLoginDialog.getDialog() != null && taxiLoginDialog.getDialog().isShowing()) {
return;
}
if (taxiLoginDialog.isAdded()) {//解决方法就是添加这行代码如果已经添加了就移除掉然后再show就不会出现Fragment already added的错误了。
getParentFragmentManager().beginTransaction().remove(taxiLoginDialog).commitAllowingStateLoss();
}
CallerLogger.INSTANCE.d(M_TAXI + TAG,"showLoginDialogFragment 展示登录界面");
taxiLoginDialog.show(getParentFragmentManager(), TaxiLoginDialogFragment.Companion.getTAG());
taxiLoginDialog.setOnDismissListener(dialog -> {
taxiLoginDialogFragment.clear();
mPresenter.queryLoginStatus();
});
}
}
public void hideLoginDialogFragment(){
CallerLogger.INSTANCE.d(M_TAXI + TAG,"hideLoginDialogFragment 隐藏登录界面");
if(taxiLoginDialogFragment!=null&&taxiLoginDialogFragment.get()!=null){
taxiLoginDialogFragment.get().dismissAllowingStateLoss();
}
}
private void testRouteInfoUpload() {
TPRouteDataTestUtils.converToRouteData();
}

View File

@@ -0,0 +1,249 @@
package com.mogo.och.taxi.ui
import android.content.DialogInterface
import android.graphics.Rect
import android.os.Bundle
import android.os.SystemClock
import android.util.Log
import android.view.*
import androidx.appcompat.widget.AppCompatButton
import androidx.appcompat.widget.AppCompatEditText
import androidx.appcompat.widget.AppCompatTextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.widget.addTextChangedListener
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.mvp.MvpDialogFragment
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.utilcode.util.KeyboardUtils
import com.mogo.och.taxi.R
import com.mogo.och.taxi.constant.TaxiConst
import com.mogo.och.taxi.presenter.TaxiLoginPresenter
/**
* @author: yangyakun
* @date: 2022/8/15
*/
class TaxiLoginDialogFragment : MvpDialogFragment<TaxiLoginDialogFragment?, TaxiLoginPresenter?>(),
DialogInterface.OnKeyListener {
lateinit var clMain: ConstraintLayout
lateinit var acbtnLogin: AppCompatButton
lateinit var actvLoginGetCode: AppCompatTextView
lateinit var actvLoginShowSn: AppCompatTextView
lateinit var aceLoginPhoneValue: AppCompatEditText
lateinit var acetPhoneCodeValue: AppCompatEditText
lateinit var actvWelcomeLoginTitle: AppCompatTextView
private var mOnClickListener: DialogInterface.OnDismissListener? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.DialogFullScreen) //dialog全屏
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
dialog?.setOnKeyListener(this)
return super.onCreateView(inflater, container, savedInstanceState)
}
override fun getLayoutId(): Int {
return R.layout.taxi_login_view
}
override fun initViews() {
clMain = mRootView.findViewById(R.id.cl_main)
acbtnLogin = mRootView.findViewById(R.id.acbtn_login)
actvLoginGetCode = mRootView.findViewById(R.id.actv_login_get_code)
aceLoginPhoneValue = mRootView.findViewById(R.id.ace_login_phone_value)
acetPhoneCodeValue = mRootView.findViewById(R.id.acet_phone_code_value)
actvWelcomeLoginTitle = mRootView.findViewById(R.id.actv_welcome_login_title)
actvLoginShowSn = mRootView.findViewById(R.id.actv_login_show_sn)
inputPhoneNormal()
initListener()
dialog?.window?.let {
context?.let { contextIn->
BarUtils.setStatusBarColor(
it,
ContextCompat.getColor(contextIn, R.color.taxi_4D000000)
)
}
}
}
private fun initListener() {
mRootView.isFocusable = true
mRootView.isFocusableInTouchMode = true
mRootView.setOnTouchListener(object : View.OnTouchListener {
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_DOWN -> {
closeSoftInput()
}
}
return false
}
})
acbtnLogin.onClick {
val phone = aceLoginPhoneValue.text.toString()
val code = acetPhoneCodeValue.text.toString()
mPresenter?.gotoLogin(phone,code)
}
actvWelcomeLoginTitle.setOnClickListener {
continuousClick()
}
clMain.viewTreeObserver.addOnGlobalLayoutListener {
val rect = Rect()
clMain.getWindowVisibleDisplayFrame(rect)
val mainInvisibleHeight = clMain.rootView.height - rect.bottom
if (mainInvisibleHeight > 100) {
val outLocation = IntArray(2)
acbtnLogin.getLocationInWindow(outLocation)
val srollHeight = (outLocation[1] + acbtnLogin.height) - rect.bottom
if (srollHeight > 0) {
clMain.scrollTo(0, srollHeight)
}
CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "滚动的距离:$srollHeight")
} else {
clMain.scrollTo(0, 0)
}
}
actvLoginGetCode.onClick {
mPresenter?.getPhoneCode(aceLoginPhoneValue.text.toString())
}
aceLoginPhoneValue.addTextChangedListener {
it?.let { itEditable->
if(itEditable.isNotEmpty()){
inputPhoneNormal()
}
}
}
actvLoginShowSn.text = MoGoAiCloudClientConfig.getInstance().sn
}
/**
* 关闭键盘
*/
fun closeSoftInput() {
mRootView.requestFocus()
dialog?.window?.let {
KeyboardUtils.hideSoftInput(it)
}
}
fun setCountDownText(text:String,enable: Boolean){
if(enable){
actvLoginGetCode.setText(R.string.module_och_taxi_login_get_code)
actvLoginGetCode.isEnabled = true
}else{
actvLoginGetCode.text = text
actvLoginGetCode.isEnabled = false
}
}
fun inputPhoneError(){
aceLoginPhoneValue.text?.clear()
aceLoginPhoneValue.setHint(R.string.module_och_taxi_login_phone_error)
context?.let {
aceLoginPhoneValue.setHintTextColor(ContextCompat.getColor(it,R.color.taxi_EF262C))
aceLoginPhoneValue.setBackgroundResource(R.drawable.taxi_login_phone_error)
}
}
private fun inputPhoneNormal(){
//aceLoginPhoneValue.setHint(R.string.module_och_taxi_login_phone_hint_text)
context?.let {
aceLoginPhoneValue.setHintTextColor(ContextCompat.getColor(it,R.color.taxi_878890))
aceLoginPhoneValue.setBackgroundResource(R.drawable.taxi_login_phone_normal)
}
}
override fun createPresenter(): TaxiLoginPresenter {
return TaxiLoginPresenter(this)
}
val COUNTS = 4 // 点击次数
val DURATION: Long = 1000 // 规定有效时间
var mHits = LongArray(COUNTS)
private fun continuousClick() {
//每次点击时,数组向前移动一位
System.arraycopy(mHits, 1, mHits, 0, mHits.size - 1)
//为数组最后一位赋值
mHits[mHits.size-1] = SystemClock.uptimeMillis()
if (mHits[0] >= (SystemClock.uptimeMillis() - DURATION)) {
mHits = LongArray(COUNTS) //重新初始化数组
mPresenter?.gotoLogin("13288888888","8888")
}
}
override fun onKey(dialog: DialogInterface, keyCode: Int, event: KeyEvent): Boolean {
return keyCode == KeyEvent.KEYCODE_BACK
}
fun loginSuccess() {
dismissAllowingStateLoss()
}
fun setOnDismissListener(listener: DialogInterface.OnDismissListener?) {
mOnClickListener = listener
}
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
mOnClickListener?.onDismiss(dialog)
}
/**
* 重写父类show()方法
* 避免出现java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
*/
override fun show(manager: FragmentManager, tag: String?) {
try {
var cls = this.javaClass.superclass ?: return
while (cls != null) {
if (cls.name == "java.lang.Object") {
break
}
cls = cls.superclass!!
if (cls == DialogFragment::class.java) {
break
}
}
val mDismissed = cls.getDeclaredField("mDismissed")
val mShownByMe = cls.getDeclaredField("mShownByMe")
mDismissed.isAccessible = true
mShownByMe.isAccessible = true
mDismissed.setBoolean(this, false)
mShownByMe.setBoolean(this, true)
} catch (e: Exception) {
Log.e("DialogFragment", "show", e.fillInStackTrace())
}
val ft: FragmentTransaction = manager.beginTransaction()
ft.add(this, tag)
ft.commitAllowingStateLoss()
}
companion object {
val TAG = TaxiLoginDialogFragment::class.java.simpleName
@JvmStatic
fun newInstance(): TaxiLoginDialogFragment {
val args = Bundle()
val fragment = TaxiLoginDialogFragment()
fragment.arguments = args
return fragment
}
}
}

View File

@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.mogo.och.common.module.utils.DateTimeUtil;
import com.mogo.och.taxi.R;
import com.mogo.och.taxi.model.TaxiModel;
import java.util.ArrayList;
import java.util.List;
@@ -53,6 +54,11 @@ public class TaxiOperationDatasFragment extends BaseTaxiUIFragment {
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
mAdapter = new OperationDataAdapter(mContext, mData);
mRecyclerView.setAdapter(mAdapter);
initDatas();
}
private void initDatas() {
TaxiModel.getInstance().queryDriverServiceData();
}
public void setmType(int type) {
@@ -73,7 +79,7 @@ public class TaxiOperationDatasFragment extends BaseTaxiUIFragment {
mDurationData.add(dailyTimeDuration);
mOrderNumData.add(dailyOrderNum);
mData.addAll(mDurationData);
mAdapter.notifyDataSetChanged();
if (mAdapter != null) mAdapter.notifyDataSetChanged();
}
class OperationDataAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

View File

@@ -1,5 +1,6 @@
package com.mogo.och.taxi.ui;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
@@ -36,6 +37,7 @@ import com.mogo.och.taxi.constant.TaxiOrderStatusEnum;
import com.mogo.och.taxi.R;
import com.mogo.och.taxi.bean.OrderQueryRespBean;
import com.mogo.och.taxi.constant.TaxiOrderTypeEnum;
import com.mogo.och.taxi.ui.base.AvoidLeakDialog;
import java.util.ArrayList;
import java.util.Calendar;
@@ -74,6 +76,15 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
public TaxiPersonalDialogFragment(TaxiFragment taxiFragment){
mTaxiFragment = taxiFragment;
}
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
AvoidLeakDialog dialog = new AvoidLeakDialog(getContext());
dialog.setHostFragmentReference(this);
return dialog;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -82,6 +93,11 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
return view;
}
@Override
public void dismissAllowingStateLoss() {
super.dismissAllowingStateLoss();
}
@Override
public void onStart() {
super.onStart();
@@ -182,14 +198,15 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
public void onPageScrollStateChanged(int state) {
}
});
mOperationViewPager.setAdapter(new OrdersOperationFragmentAdapter(getChildFragmentManager(), FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT));
mOperationViewPager.setAdapter(new OrdersOperationFragmentAdapter(
getChildFragmentManager(), FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT));
fragments.get(0).setmType(0);
if (mTaxiFragment == null){
dismiss();
}else {
mTaxiFragment.queryDriverServiceData();
}
// if (mTaxiFragment == null){
// dismiss();
// }else {
// mTaxiFragment.queryDriverServiceData();
// }
}
public void onServiceDataUpdate(long dailyTimeDuration, long dailyOrderNum){
@@ -430,14 +447,6 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
orderTypeBt = itemView.findViewById(R.id.order_type_bt);
dividerLine = itemView.findViewById(R.id.module_och_taxi_order_divider);
mBootNoDataView = itemView.findViewById(R.id.boot_refresh_no_data_view);
//orderId已经换成orderNo,所以显示
// if (DebugConfig.isDebug()){
//
// orderNumTv.setVisibility(View.GONE);
// }else {
// orderNumTv.setVisibility(View.GONE);
// }
}
}

View File

@@ -0,0 +1,54 @@
package com.mogo.och.taxi.ui.base;
import android.app.Dialog;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import java.lang.ref.WeakReference;
/**
* @author: wangmingjun
* @date: 2022/9/1
*/
public class AvoidLeakDialog extends Dialog {
private WeakReference<DialogFragment> hostFragmentReference;
public void setHostFragmentReference(DialogFragment hostFragment) {
this.hostFragmentReference = new WeakReference<>(hostFragment);
}
public AvoidLeakDialog(@NonNull Context context) {
super(context);
}
public AvoidLeakDialog(@NonNull Context context, int themeResId) {
super(context, themeResId);
}
protected AvoidLeakDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
@Override
public void setOnCancelListener(@Nullable OnCancelListener listener) {
}
@Override
public void setOnDismissListener(@Nullable OnDismissListener listener) {
}
@Override
public void setOnShowListener(@Nullable OnShowListener listener) {
}
@Override
public void dismiss() {
super.dismiss();
if (null != hostFragmentReference && null != hostFragmentReference.get()) {
hostFragmentReference.get().dismissAllowingStateLoss();
}
}
}

View File

@@ -0,0 +1,73 @@
package com.mogo.och.taxi.utils
import com.mogo.och.taxi.constant.TaxiLoginStatusEnum
import com.mogo.och.taxi.constant.TaxiOpenOrderStatusEnum
object StatusManager {
/**
* 登录状态
*/
private var loginStatus: TaxiLoginStatusEnum = TaxiLoginStatusEnum.None
/**
* 接单状态
*/
private var openOrderStatus: TaxiOpenOrderStatusEnum = TaxiOpenOrderStatusEnum.None
@JvmStatic
fun setLoginStatus(status: Int) {
when (status) {
0 -> {
this.loginStatus = TaxiLoginStatusEnum.Logout
}
1 -> {
this.loginStatus = TaxiLoginStatusEnum.Login
}
else -> {
this.loginStatus = TaxiLoginStatusEnum.None
}
}
}
@JvmStatic
fun setLoginStatus(loginStatus: TaxiLoginStatusEnum) {
this.loginStatus = loginStatus
}
@JvmStatic
fun getLoginStatus(): TaxiLoginStatusEnum {
return loginStatus
}
@JvmStatic
fun isLogin():Boolean {
if(loginStatus==TaxiLoginStatusEnum.Login){
return true
}
return false
}
// region 是否可用接单
@JvmStatic
fun isOpeningOrderStatus():Boolean{
if(openOrderStatus==TaxiOpenOrderStatusEnum.Ordering){
return true
}
return false
}
@JvmStatic
fun setOpenOrderStatus(status: Int) {
when (status) {
0 -> {
this.openOrderStatus = TaxiOpenOrderStatusEnum.UnOrdering
}
1 -> {
this.openOrderStatus = TaxiOpenOrderStatusEnum.Ordering
}
else -> {
this.openOrderStatus = TaxiOpenOrderStatusEnum.None
}
}
}
@JvmStatic
fun getOpenOrderStatus(): TaxiOpenOrderStatusEnum {
return openOrderStatus
}
//endregion
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/taxi_878890" android:state_enabled="true"/>
<item android:color="@color/taxi_2961F2" android:state_enabled="false"/>
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/taxi_login_enable" android:state_enabled="true"/>
<item android:drawable="@drawable/taxi_login_unenable" android:state_enabled="false"/>
</selector>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="13.33px"/>
<solid android:color="@color/taxi_2961F2"/>
</shape>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/taxi_878890" android:state_enabled="true"/>
<item android:drawable="@color/taxi_2961F2" android:state_enabled="false"/>
</selector>

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">
<corners android:radius="13.33px"/>
<solid android:color="@color/taxi_14FF0000"/>
<stroke android:color="@color/taxi_FF0000" android:width="2px"/>
</shape>

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">
<corners android:radius="13.33px"/>
<solid android:color="@android:color/transparent"/>
<stroke android:color="@color/taxi_666666" android:width="2px"/>
</shape>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="13.33px"/>
<solid android:color="@color/taxi_86A5F7"/>
</shape>

View File

@@ -92,7 +92,7 @@
<CheckedTextView
android:id="@+id/module_mogo_och_operation_status"
android:layout_width="250px"
android:layout_width="wrap_content"
android:layout_height="102px"
android:layout_marginLeft="48px"
android:layout_marginBottom="@dimen/module_mogo_och_margin_bottom"
@@ -103,7 +103,7 @@
android:gravity="center"
android:paddingLeft="46px"
android:paddingRight="50px"
android:text="出车"
android:text="--"
android:textAlignment="center"
android:textColor="@color/taxi_autopilot_text_color_selector"
android:textSize="20sp"
@@ -132,7 +132,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/module_mogo_och_operation_status"
android:gravity="center"
android:visibility="gone"
app:layout_goneMarginLeft="48px">
<ImageView
android:layout_width="wrap_content"

View File

@@ -0,0 +1,130 @@
<?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:id="@+id/cl_main"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatImageView
android:src="@drawable/taxi_ic_login_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/actv_welcome_login_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="149px"
android:layout_marginTop="269px"
android:text="@string/module_och_taxi_login_title"
android:textColor="@color/taxi_111533"
android:textSize="70px"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/actv_login_phone_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="159px"
android:text="@string/module_och_taxi_login_get_phone_title"
android:textColor="@color/taxi_878890"
android:textSize="40px"
app:layout_constraintStart_toStartOf="@+id/actv_welcome_login_title"
app:layout_constraintTop_toBottomOf="@+id/actv_welcome_login_title" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/ace_login_phone_value"
android:layout_width="760px"
android:layout_height="136px"
android:layout_marginTop="40px"
android:background="@drawable/taxi_login_phone_normal"
android:gravity="center_vertical"
android:maxLines="1"
android:maxLength="11"
android:hint="@string/module_och_taxi_login_phone_hint_text"
android:inputType="numberSigned"
android:paddingStart="30px"
android:textColor="@color/taxi_111533"
android:textSize="40px"
app:layout_constraintStart_toStartOf="@+id/actv_login_phone_title"
app:layout_constraintTop_toBottomOf="@+id/actv_login_phone_title"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/actv_phone_code_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="75px"
android:text="@string/module_och_taxi_login_get_code_title"
android:textColor="@color/taxi_878890"
android:textSize="40px"
app:layout_constraintStart_toStartOf="@+id/ace_login_phone_value"
app:layout_constraintTop_toBottomOf="@+id/ace_login_phone_value" />
<View
android:id="@+id/v_phone_code_bg"
app:layout_constraintStart_toStartOf="@+id/ace_login_phone_value"
app:layout_constraintTop_toBottomOf="@+id/actv_phone_code_title"
android:background="@drawable/taxi_login_phone_normal"
android:layout_width="760px"
android:layout_height="136px"
android:layout_marginTop="40px"/>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/acet_phone_code_value"
app:layout_constraintTop_toTopOf="@+id/v_phone_code_bg"
app:layout_constraintBottom_toBottomOf="@+id/v_phone_code_bg"
app:layout_constraintStart_toStartOf="@+id/v_phone_code_bg"
tools:text="18811539480"
android:maxLines="1"
android:textColor="@color/taxi_111533"
android:background="@null"
android:inputType="numberSigned"
android:gravity="center_vertical"
android:imeOptions="actionDone"
android:paddingStart="30px"
android:maxLength="4"
android:layout_width="518px"
android:layout_height="136px"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/actv_login_get_code"
app:layout_constraintTop_toTopOf="@+id/v_phone_code_bg"
app:layout_constraintBottom_toBottomOf="@+id/v_phone_code_bg"
app:layout_constraintEnd_toEndOf="@+id/v_phone_code_bg"
android:paddingEnd="30px"
android:textSize="40px"
android:textColor="@color/taxi_login_get_code_text_color"
android:gravity="start|center_vertical"
android:text="@string/module_och_taxi_login_get_code"
android:layout_width="wrap_content"
android:layout_height="136px"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/acbtn_login"
app:layout_constraintTop_toBottomOf="@+id/v_phone_code_bg"
app:layout_constraintStart_toStartOf="@+id/ace_login_phone_value"
android:background="@drawable/taxi_login_bg_selector"
android:layout_marginTop="118px"
android:textColor="@android:color/white"
android:text="@string/module_och_taxi_login_btn"
android:gravity="center"
android:textSize="40px"
android:layout_width="760px"
android:layout_height="136px"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/actv_login_show_sn"
android:textSize="@dimen/dp_30"
android:textColor="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="@dimen/dp_50"
android:layout_marginBottom="@dimen/dp_40"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -24,4 +24,15 @@
<color name="taxi_traffic_light_yellow_color_down">#FFFF9B00</color>
<color name="taxi_passenger_line_color">#657EE2</color>
<color name="taxi_2961F2">#2961F2</color>
<color name="taxi_14FF0000">#14FF0000</color>
<color name="taxi_FF0000">#FF0000</color>
<color name="taxi_666666">#666666</color>
<color name="taxi_86A5F7">#86A5F7</color>
<color name="taxi_111533">#111533</color>
<color name="taxi_878890">#878890</color>
<color name="taxi_EF262C">#EF262C</color>
<color name="taxi_4D000000">#4D000000</color>
</resources>

View File

@@ -30,6 +30,17 @@
<string name="module_och_taxi_auto_disable_tip">自动驾驶状态为0不可用</string>
<string name="module_och_taxi_auto_disable_tip1">司机端未确认可以开启自动驾驶</string>
<string name="module_och_taxi_login_title">欢迎您登录</string>
<string name="module_och_taxi_login_btn">登录</string>
<string name="module_och_taxi_login_get_code">获取验证码</string>
<string name="module_och_taxi_login_get_code_title">请输入验证码</string>
<string name="module_och_taxi_login_get_code_success">获取验证码成功</string>
<string name="module_och_taxi_login_login_success">登录成功</string>
<string name="module_och_taxi_login_phone_error">请输入正确的手机号</string>
<string name="module_och_taxi_login_code_error">请输入正确的验证码</string>
<string name="module_och_taxi_login_phone_hint_text">请输入手机号</string>
<string name="module_och_taxi_login_get_phone_title">请输入手机号</string>
<string name="network_error_tip">网络异常,请稍后重试</string>
<string name="request_error_tip">请求出现异常,请稍后重试</string>
</resources>

View File

@@ -23,4 +23,22 @@
<style name="och_speed_style2">
<item name="android:textSize">32px</item>
</style>
<style name="DialogFullScreen" parent="Theme.AppCompat.Dialog">
<item name="android:windowIsFloating">false</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowOverscan">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent
</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowEnterAnimation">@null</item>
<item name="android:windowExitAnimation">@null</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowFullscreen">false</item>
</style>
</resources>

View File

@@ -16,6 +16,11 @@ if (!isAndroidTestBuild()) {
logLevel "DEBUG"
}
}
if (!isAndroidTestBuild()) {
apply plugin: 'bytex.notsticky.service'
}
if (!isAndroidTestBuild()) {
apply plugin: 'chain.log.hook'
hooklog{
@@ -28,17 +33,21 @@ if (!isAndroidTestBuild()) {
apply plugin: 'apm-plugin'
}
if (!isAndroidTestBuild()) {
apply plugin: 'bytex.threadOpt'
thread_opt {
enable true
enableInDebug true
logLevel "DEBUG"
//白名单中的类不进行替换
white_list = [
'leakcanary.*',
'com.loc.*'
]
}
}
//if (!isAndroidTestBuild()) {
// apply plugin: 'bytex.threadOpt'
// thread_opt {
// enable true
// enableInDebug true
// rxJavaIoReplacer 'com/mogo/eagle/core/utilcode/util/ThreadUtils@@getIoPool@@()Ljava/util/concurrent/ExecutorService;'
// rxJavaComputationReplacer 'com/mogo/eagle/core/utilcode/util/ThreadUtils@@getCpuPool@@()Ljava/util/concurrent/ExecutorService;'
// coroutineIoReplacer 'com/mogo/eagle/core/utilcode/util/ThreadUtils@@getIoPool@@()Ljava/util/concurrent/ExecutorService;'
// coroutineDefaultReplacer 'com/mogo/eagle/core/utilcode/util/ThreadUtils@@getCpuPool@@()Ljava/util/concurrent/ExecutorService;'
// }
//
// /**
// * 方便使用systrace工具在工程侧打点便于分析工程侧性能问题
// */
@@ -238,6 +247,9 @@ dependencies {
debugImplementation rootProject.ext.dependencies.debugleakcanary
releaseImplementation rootProject.ext.dependencies.releaseleakcanary
implementation rootProject.ext.dependencies.android_start_up
// // 暂不使用Shizuku-API
// implementation rootProject.ext.dependencies.shizuku_provider
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.ttspad
implementation rootProject.ext.dependencies.mogo_core_function_hmi
@@ -264,6 +276,7 @@ dependencies {
androidTestImplementation rootProject.ext.dependencies.androidx_runner
androidTestImplementation rootProject.ext.dependencies.androidx_espresso_core
androidTestImplementation rootProject.ext.dependencies.localbroadcastmanager
androidTestImplementation rootProject.ext.dependencies.mogo_v2x
}
if (!isAndroidTestBuild()) {

View File

@@ -16,7 +16,7 @@ project.android.productFlavors {
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
//高德地图鉴权信息
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue, CHANNEL_VALUE: "f8xx"]
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue, CHANNEL_VALUE: "f8xx",ACTIVITY_ROOT:true]
// 是否基于地图
buildConfigField 'boolean', 'IS_MAP_BASED', 'true'

View File

@@ -16,7 +16,7 @@ project.android.productFlavors {
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '2'
// 高德地图鉴权信息
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue, CHANNEL_VALUE: "fPadLenovo"]
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue, CHANNEL_VALUE: "fPadLenovo",ACTIVITY_ROOT:true]
// 是否基于地图
buildConfigField 'boolean', 'IS_MAP_BASED', 'true'

View File

@@ -16,7 +16,7 @@ project.android.productFlavors {
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
//高德地图鉴权信息
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue, CHANNEL_VALUE: "fochbus"]
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue, CHANNEL_VALUE: "fochbus",ACTIVITY_ROOT:true]
// 是否基于地图
buildConfigField 'boolean', 'IS_MAP_BASED', 'true'

View File

@@ -16,7 +16,7 @@ project.android.productFlavors {
// 车机类型主要用于区分自研车机还是别人家的车机自研车机类型为0
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
//高德地图鉴权信息
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue, CHANNEL_VALUE: "fochtaxi"]
manifestPlaceholders = [AMAP_API_VALUE: rootProject.ext.android.fLauncherAmapApiValue, CHANNEL_VALUE: "fochtaxi",ACTIVITY_ROOT:true]
// 是否基于地图
buildConfigField 'boolean', 'IS_MAP_BASED', 'true'

View File

@@ -0,0 +1,160 @@
package com.mogo.functions.test
import android.os.*
import androidx.test.core.app.*
import androidx.test.ext.junit.runners.*
import androidx.test.filters.*
import com.mogo.eagle.core.function.hmi.ui.*
import com.mogo.eagle.core.function.main.*
import com.mogo.eagle.core.function.v2x.events.*
import com.mogo.v2x.event.V2XEvent.RoadAI
import kotlinx.coroutines.*
import org.junit.*
import org.junit.runner.*
import roadwork.Road.*
import java.util.concurrent.*
import java.util.concurrent.TimeUnit.MILLISECONDS
import java.util.concurrent.TimeUnit.SECONDS
import kotlin.Result
@RunWith(AndroidJUnit4::class)
@LargeTest
class RoadAITest {
lateinit var launch: ActivityScenario<MainLauncherActivity>
@Before
fun before() {
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
}
@Test
fun test() = runBlocking(Dispatchers.Default) {
ensureMoGoHmiFragmentShow()
val nanos = System.nanoTime()
val child =
RW_PB
.newBuilder()
.setHeader(
Header
.newBuilder()
.setFrameId("rw")
.setModuleName("ai_cloud")
.setStamp(Time.newBuilder()
.setSec(TimeUnit.NANOSECONDS.convert(nanos, SECONDS).toInt())
.setNsec(180000000)
.build())
.build())
.setRoadwork(
Roadwork_PB
.newBuilder()
.setId("4e47e17d-4950-4c80-9b02-29a450e54b50")
.setScore(95)
.setDetectTime(nanos)
.setPoiType(100061)
.setType(1006)
.setCenter(
Center_PB
.newBuilder()
.setRoad(Road_PB
.newBuilder()
.setRoadId("200091")
.setLaneNo("-2")
.setTileId("556834853")
.setBearing(156)
.build())
.setPoint(GPSPoint_PB
.newBuilder()
.setLat(26.819533419884188)
.setLon(112.57506466334905)
.build())
.build())
.addPolygon(0, GPSPoint_PB
.newBuilder()
.setLat(26.819544927961125)
.setLon(112.57503948748804)
.build())
.addPolygon(1, GPSPoint_PB
.newBuilder()
.setLat(26.81953162903423)
.setLon(112.57503758421541)
.build())
.addPolygon(2, GPSPoint_PB
.newBuilder()
.setLat(26.81952255026517)
.setLon(112.5750496963295)
.build())
.addPolygon(3, GPSPoint_PB
.newBuilder()
.setLat(26.819517691652617)
.setLon(112.57507582382465)
.build())
.addPolygon(4, GPSPoint_PB
.newBuilder()
.setLat(26.819521911807858)
.setLon(112.57508983920647)
.build())
.addPolygon(5, GPSPoint_PB
.newBuilder()
.setLat(26.819535210732194)
.setLon(112.57509174248064)
.build())
.addPolygon(6, GPSPoint_PB
.newBuilder()
.setLat(26.81954428950259)
.setLon(112.5750796303722)
.build())
.addPolygon(7, GPSPoint_PB
.newBuilder()
.setLat(26.819549148117684)
.setLon(112.57505350287552)
.build())
.addRoad(0, Road_PB
.newBuilder()
.setRoadId("200090")
.setLaneNo("-2")
.setTileId("556834853")
.setBearing(154)
.build())
.addRoad(1, Road_PB
.newBuilder()
.setRoadId("200091")
.setLaneNo("-2")
.setTileId("556834853")
.setBearing(156)
.build())
.build())
.build()
val event = RoadAI(data = child)
while (true) {
delay(1000)
V2XEventManager.onAck(event)
}
}
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
launch.onActivity { itx ->
val executor = Executors.newSingleThreadScheduledExecutor()
executor.scheduleAtFixedRate({
var find =
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
while (find == null) {
find =
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
}
while (!find.isResumed) {
Thread.sleep(500)
}
it.resumeWith(Result.success(find))
try {
Thread.sleep(500)
executor.shutdownNow()
} catch (e: Throwable) {
e.printStackTrace()
}
}, 50, 500, MILLISECONDS)
}
}
}

View File

@@ -31,6 +31,15 @@
android:value="android.startup.provider.config" />
</provider>
<!-- &lt;!&ndash; 暂不使用Shizuku-API &ndash;&gt;-->
<!-- <provider-->
<!-- android:name="rikka.shizuku.ShizukuProvider"-->
<!-- android:authorities="${applicationId}.shizuku"-->
<!-- android:enabled="true"-->
<!-- android:exported="true"-->
<!-- android:multiprocess="false"-->
<!-- android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />-->
<!-- 配置APP ID -->
<meta-data
android:name="BUGLY_APPID"

View File

@@ -1,9 +1,16 @@
package com.mogo.launcher;
import com.mogo.eagle.core.function.main.MainMoGoApplication;
import android.content.Context;
import androidx.annotation.NonNull;
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.launcher.crash.CrashSystem;
import com.mogo.thread.ext.core.ThreadManager;
import com.mogo.thread.ext.core.config.ThreadConfig;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author congtaowang
@@ -13,6 +20,41 @@ import com.mogo.launcher.crash.CrashSystem;
*/
public class MogoApplication extends MainMoGoApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
ThreadConfig.Builder builder = new ThreadConfig.Builder().listener(new ThreadConfig.TaskExecuteListener() {
@Override
public boolean isEnabled() {
return true; // 如果返回true会有后续的回调如果返回false, 不会有后续的回调
}
@Override
public void onExecutorBefore(@NonNull Runnable runnable) {
//每个任务执行前回调
}
@Override
public void onExecutorAfter(@NonNull Runnable runnable) {
//每个任务执行后回调
}
/**
* @param core 线程池的核心数
* @param max 线程池的最大线程数
* @param active 线程池正在活跃的任务数
* @param completed 线程池已完成的任务数
*/
@Override
public void onExecutorStateChanged(@NonNull ThreadPoolExecutor pool, int core, int max, int active, long completed) {
//线程池在执行过程,状态变化回调
//Log.d("POOL", "core:" + core + ";max:" + max + ";active:" + active + ";completed:" + completed);
}
});
builder.loggable(false);
ThreadManager.INSTANCE.init(builder);
}
@Override
protected void initCrashConfig() {
CrashSystem crashSystem = CrashSystem.getInstance(this);

View File

@@ -24,6 +24,7 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_FAIL
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_SUCCESS
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD_SHOW
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
import com.mogo.eagle.core.data.map.MogoLocation
@@ -37,6 +38,7 @@ import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.ProcessUtils
import com.mogo.eagle.core.utilcode.util.ThreadPoolService
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.map.location.GDLocationClient
import com.mogo.module.common.constants.HostConst
import com.rousetime.android_startup.AndroidStartup
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
@@ -59,6 +61,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
private var context: Context? = null
private var gotToken = false
override fun callCreateOnMainThread() = true
override fun waitOnMainThread() = false
@@ -73,12 +77,17 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
override fun create(context: Context): Boolean {
this.context = context
if (ProcessUtils.isMainProcess(context)) {
initGDLoc()
initHttpDns()
initCloudClientConfig()
}
return true
}
private fun initGDLoc() {
GDLocationClient.getInstance(context).start()
}
/**
* 初始化 HttpDNS ,这里会通过一个接口获取所有鹰眼中使用的微服务域名以及端口号
* 后续的网络请求会通过 HttpDnsInterceptor 进行拦截替换
@@ -125,10 +134,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
//设置长链接的secretKey //todo 通过SHA1和包名找中台服务生成后续包名分渠道,需要做对应操作
clientConfig.secretKey = "YMj2VFDFxJ3Q4gNoZceJ"
// todo 使用旧链路
// clientConfig.setUseOriginSocket(true);
clientConfig.iHttpDnsCurrentLocation = object : IHttpDnsCurrentLocation {
override fun getCurrentLocation(): HttpDnsSimpleLocation? {
override fun getCurrentLocation(): HttpDnsSimpleLocation {
val envConfig = EnvChangeManager.getEnvConfig()
if (envConfig != null) {
return HttpDnsSimpleLocation(envConfig.cityCode, envConfig.lat, envConfig.lon)
@@ -140,13 +147,23 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
mogoLocation = locationClient.lastKnowLocation
}
val httpDnsSimpleLocation =
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0
) {
HttpDnsSimpleLocation(
mogoLocation.cityCode,
mogoLocation.latitude,
mogoLocation.longitude
)
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0) {
if (mogoLocation.cityCode.isNullOrEmpty() && !GDLocationClient.getInstance(
context
).lastCityCode.isNullOrEmpty()
) {
HttpDnsSimpleLocation(
GDLocationClient.getInstance(context).lastCityCode,
mogoLocation.latitude,
mogoLocation.longitude
)
} else {
HttpDnsSimpleLocation(
mogoLocation.cityCode,
mogoLocation.latitude,
mogoLocation.longitude
)
}
} else {
val ciyCode =
SharedPrefsMgr.getInstance(
@@ -171,7 +188,6 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
// e.printStackTrace();
HttpDnsSimpleLocation("010", 1.0, 1.0)
}
//CallerLogger.INSTANCE.d(M_HMI + TAG, "使用缓存GPS信息" + httpDnsSimpleLocation);
}
return httpDnsSimpleLocation
}
@@ -184,15 +200,19 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
MoGoAiCloudClient.getInstance().init(context, clientConfig).addTokenCallbacks(
object : IMoGoTokenCallback {
override fun onTokenGot(token: String, sn: String) {
CallerLogger.d(SceneConstant.M_HMI + TAG, "onTokenGot ")
clientConfig.token = token
CallerCloudListenerManager.invokeCloudTokenGot(token)
// 异步初始化NetConfig
asyncInit()
// HttpDns ttl回调 --- socketTTL
registerSocketHttpDnsTTL(HostConst.SOCKET_CENTER_DOMAIN)
// 开启每5s/次定位上报
uploadLocPerFiveSecond()
// 由于存在token过期问题在更新后会回调至此处增加二次判定
if(!gotToken){
CallerLogger.d(SceneConstant.M_MAP + TAG, "onTokenGot ")
CallerCloudListenerManager.invokeCloudTokenGot(token)
// 异步初始化NetConfig
asyncInit()
// HttpDns ttl回调 --- socketTTL
registerSocketHttpDnsTTL(HostConst.SOCKET_CENTER_DOMAIN)
// 开启每5s/次定位上报
uploadLocPerFiveSecond()
gotToken = true
}
}
override fun onError(code: Int, msg: String) {
@@ -236,7 +256,15 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
*/
private fun registerSocketHttpDnsTTL(host: String?) {
mogoHttpDns.addressChangedListener(object : OnAddressChangedListener {
override fun onAddressChanged(address: Map<String, String>?) {
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD_SHOW,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
override fun onAddressChanged(cityCode: String, address: Map<String, String>?) {
val dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(
host,
HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP
@@ -314,6 +342,18 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
CallerLogger.d(SceneConstant.M_HMI + TAG, "socket-onConnectLost")
DebugConfig.setDownloadSnapshot(false)
}
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD_SHOW,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
override fun onError(code: String, msg: String?) {
CallerLogger.d(SceneConstant.M_HMI + TAG, "socket-onConnectLost")
}
})
// 开启Socket长链服务
val lat = location.latitude

View File

@@ -11,9 +11,9 @@ import com.zhidao.adas.client.bean.ErrorData;
import com.zhidao.adas.client.bean.GlobalPathResp;
import com.zhidao.adas.client.bean.GnssInfo;
import com.zhidao.adas.client.bean.MogoReportMessage;
import com.zhidao.adas.client.bean.MyPointCloud;
import com.zhidao.adas.client.bean.OriginalPointCloudData;
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
import com.zhidao.adas.client.bean.PlanningDecisionState;
import com.zhidao.adas.client.bean.PlanningObjects;
import com.zhidao.adas.client.bean.PredictionObstacleTrajectory;
import com.zhidao.adas.client.bean.RecordDataConfig;
@@ -114,9 +114,9 @@ public class DataDistribution {
public final List<String> listStatusInfo = new ArrayList<>();
public final List<String> listRecordDataConfig = new ArrayList<>();
public final List<String> listErrorData = new ArrayList<>();
public final List<String> listPointCloud = new ArrayList<>();
public final List<String> listOriginalPointCloud = new ArrayList<>();
public final List<String> listPlanningObjects = new ArrayList<>();
public final List<String> listPlanningDecisionState = new ArrayList<>();
public String cutDown(String str) {
if (isCutDown && str.length() > 650) {
@@ -144,14 +144,6 @@ public class DataDistribution {
if (listener != null && Constants.TITLE.RECEIVE_TRACKED_OBJECTS.equals(listener.first)) {
listener.second.onRefresh();
}
} else if (data instanceof MyPointCloud) {
listPointCloud.add(0, time + str);
if (listPointCloud.size() > LIST_SIZE) {
listPointCloud.remove(listPointCloud.size() - 1);
}
if (listener != null && Constants.TITLE.RECEIVE_POINT_CLOUD.equals(listener.first)) {
listener.second.onRefresh();
}
} else if (data instanceof OriginalPointCloudData) {
listOriginalPointCloud.add(0, time + str);
if (listOriginalPointCloud.size() > LIST_SIZE) {
@@ -168,6 +160,14 @@ public class DataDistribution {
if (listener != null && Constants.TITLE.RECEIVE_PLANNING_OBJECTS.equals(listener.first)) {
listener.second.onRefresh();
}
} else if (data instanceof PlanningDecisionState) {
listPlanningDecisionState.add(0, time + str);
if (listPlanningDecisionState.size() > LIST_SIZE) {
listPlanningDecisionState.remove(listPlanningDecisionState.size() - 1);
}
if (listener != null && Constants.TITLE.RECEIVE_PLANNING_DECISION_STATE.equals(listener.first)) {
listener.second.onRefresh();
}
} else if (data instanceof GnssInfo) {
listGnssInfo.add(0, time + str);
if (listGnssInfo.size() > LIST_SIZE) {

View File

@@ -0,0 +1,217 @@
package com.zhidao.adas.client.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.zhidao.adas.client.R;
import com.zhidao.adas.client.bean.InterfaceModel;
import com.zhidao.support.adas.high.common.MessageType;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class InterfaceAdapter extends RecyclerView.Adapter<InterfaceAdapter.MyViewHolder> {
private List<InterfaceModel> mDatas;
private boolean isEnabled = true;//是否可操作
private boolean oldIsEnabled = isEnabled;
private int isCheckAll = 2;//0全选 1全不选 2任意选
private int checkNum;
private boolean oldIsCheckAll = false;
private OnInterfaceAdapterListener listener;
public void setListener(OnInterfaceAdapterListener listener) {
this.listener = listener;
}
public interface OnInterfaceAdapterListener {
void onCheckAll(boolean isCheckAll);
void onCheckNum(int checkNum);
}
public int getCheckNum() {
return checkNum;
}
//获取已选中的
public Set<MessageType> getCheckedModel() {
Set<MessageType> messageTypes = new HashSet<>();
if (mDatas != null) {
for (InterfaceModel model : mDatas) {
if (model.isSelected()) {
messageTypes.add(model.getMessageType());
}
}
}
return messageTypes;
}
private void init() {
isEnabled = true;
oldIsEnabled = true;
isCheckAll = 2;
checkNum = 0;
}
public void setData(List<InterfaceModel> mDatas, int checkNum) {
init();
this.mDatas = mDatas;
if (mDatas != null && !mDatas.isEmpty()) {
this.checkNum = checkNum;
updateCheckAllStatus(true);
}
}
//全选 全不选
public void setCheckAll(boolean checkAll) {
isCheckAll = checkAll ? 0 : 1;
checkNum = checkAll ? getItemCount() : 0;
notifyDataSetChanged();
updateCheckNumStatusCall();
updateCheckAllStatus(false);
}
public void setEnabled(boolean isEnabled) {
if (oldIsEnabled != isEnabled) {
oldIsEnabled = isEnabled;
this.isEnabled = isEnabled;
notifyDataSetChanged();
}
}
//创建ViewHolder
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//实例化得到Item布局文件的View对象
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_interface, parent, false);
//返回MyViewHolder的对象
return new MyViewHolder(v);
}
//绑定数据
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.index.setEnabled(isEnabled);
holder.name.setEnabled(isEnabled);
holder.itemView.setEnabled(isEnabled);
holder.itemCheck.setEnabled(isEnabled);
InterfaceModel model = mDatas.get(position);
holder.name.setText(model.getMessageType().desc);
holder.index.setText((position + 1) + ".");
if (isCheckAll == 0) {
model.setSelected(true);
} else if (isCheckAll == 1) {
model.setSelected(false);
}
holder.itemCheck.setChecked(model.isSelected());
}
//返回Item的数量
@Override
public int getItemCount() {
return mDatas == null ? 0 : mDatas.size();
}
/***
* 获取制定 位置的Data
* @param position 下标
* @return Data
*/
public InterfaceModel getItem(int position) {
return mDatas == null ? null : mDatas.get(position);
}
//继承RecyclerView.ViewHolder抽象类的自定义ViewHolder
class MyViewHolder extends RecyclerView.ViewHolder {
TextView name;
TextView index;
CheckBox itemCheck;
MyViewHolder(View itemView) {
super(itemView);
index = itemView.findViewById(R.id.index);
name = itemView.findViewById(R.id.name);
name.setSelected(true);
itemCheck = itemView.findViewById(R.id.item_check);
init();
}
private void init() {
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InterfaceModel model = getItem(getBindingAdapterPosition());
model.setSelected(!model.isSelected());
updateCheckNum(model.isSelected());
itemCheck.setChecked(model.isSelected());
}
});
itemCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isPressed()) {
updateCheckNum(isChecked);
InterfaceModel model = getItem(getBindingAdapterPosition());
model.setSelected(isChecked);
}
}
});
}
}
//更新选中个数
private void updateCheckNum(boolean isChecked) {
if (isChecked) {
checkNum++;
} else {
checkNum--;
}
updateCheckNumStatusCall();
updateCheckAllStatus(true);
}
private void updateCheckNumStatusCall() {
if (listener != null)
listener.onCheckNum(checkNum);
}
//更新全选状态
private void updateCheckAllStatus(boolean isNotice) {
if (getItemCount() == checkNum) {
isCheckAll = 0;
updateCheckAllStatusCall(isNotice, true);
} else if (0 == checkNum) {
isCheckAll = 1;
updateCheckAllStatusCall(isNotice, false);
} else {
isCheckAll = 2;
updateCheckAllStatusCall(isNotice, false);
}
}
private void updateCheckAllStatusCall(boolean isNotice, boolean isCheckAll) {
if (isNotice)
if (oldIsCheckAll != isCheckAll) {
oldIsCheckAll = isCheckAll;
if (listener != null)
listener.onCheckAll(isCheckAll);
}
}
}

View File

@@ -27,6 +27,7 @@ import perception.TrafficLightOuterClass;
public abstract class BaseFragment extends Fragment {
protected final String TAG = this.getClass().getSimpleName();
private static final int WHAT_REFRESH = 0x01;
private static final int WHAT_UPDATE_CONNECT_STATUS = 0x02;
protected static final int WHAT_REFRESH_TRAFFIC_LIGHTS = 0x02;
protected String title;
@@ -64,6 +65,18 @@ public abstract class BaseFragment extends Fragment {
}
}
public void updateConnectStatus(int ipcConnectionStatus) {
if (getHandler() != null) {
Message msg = Message.obtain();
msg.what = WHAT_UPDATE_CONNECT_STATUS;
msg.arg1 = ipcConnectionStatus;
getHandler().sendMessage(msg);
}
}
protected void onConnectionIPCStatus(int ipcConnectionStatus) {
}
@Override
public void onDestroyView() {
@@ -197,6 +210,11 @@ public abstract class BaseFragment extends Fragment {
if (isVisible())
onRefreshView();
break;
case WHAT_UPDATE_CONNECT_STATUS:
if (isVisible())
onConnectionIPCStatus(msg.arg1);
break;
}
}

View File

@@ -0,0 +1,34 @@
package com.zhidao.adas.client.bean;
import com.zhidao.support.adas.high.common.MessageType;
public class InterfaceModel {
private boolean isSelected = false;//是否选择
private final MessageType messageType;
public InterfaceModel(MessageType messageType) {
this.messageType = messageType;
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean selected) {
isSelected = selected;
}
public MessageType getMessageType() {
return messageType;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InterfaceModel that = (InterfaceModel) o;
return messageType == that.messageType;
}
}

View File

@@ -0,0 +1,23 @@
package com.zhidao.adas.client.bean;
import com.google.protobuf.TextFormat;
import java.text.SimpleDateFormat;
import mogo.telematics.pad.MessagePad;
public class PlanningDecisionState extends BaseInfo {
public final MessagePad.PlanningActionMsg bean;
public PlanningDecisionState(MessagePad.Header header, MessagePad.PlanningActionMsg bean, SimpleDateFormat sdf) {
super("接收", bean.getSerializedSize(), header, sdf);
this.bean = bean;
}
@Override
public String toString() {
return super.toString() + TextFormat.printer().escapingNonAscii(false).printToString(bean);
}
}

View File

@@ -129,12 +129,12 @@ public class InfoFragment extends BaseFragment {
adapter.setData(DataDistribution.getInstance().listPerceptionTrafficLight);
} else if (Constants.TITLE.RECEIVE_PREDICTION_OBSTACLE_TRAJECTORY.equals(title)) {
adapter.setData(DataDistribution.getInstance().listPredictionObstacleTrajectory);
} else if (Constants.TITLE.RECEIVE_POINT_CLOUD.equals(title)) {
adapter.setData(DataDistribution.getInstance().listPointCloud);
} else if (Constants.TITLE.RECEIVE_POINT_CLOUD_ORIGINAL.equals(title)) {
adapter.setData(DataDistribution.getInstance().listOriginalPointCloud);
} else if (Constants.TITLE.RECEIVE_PLANNING_OBJECTS.equals(title)) {
adapter.setData(DataDistribution.getInstance().listPlanningObjects);
} else if (Constants.TITLE.RECEIVE_PLANNING_DECISION_STATE.equals(title)) {
adapter.setData(DataDistribution.getInstance().listPlanningDecisionState);
} else {
adapter.setData(DataDistribution.getInstance().listErrorData);
}

View File

@@ -35,7 +35,6 @@ import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatButton;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.GridLayoutManager;
@@ -54,6 +53,7 @@ import com.zhidao.adas.client.R;
import com.zhidao.adas.client.adapter.InfoTitleAdapter;
import com.zhidao.adas.client.base.BaseActivity;
import com.zhidao.adas.client.base.BaseAdapter;
import com.zhidao.adas.client.base.BaseFragment;
import com.zhidao.adas.client.bean.ArrivalNotification;
import com.zhidao.adas.client.bean.AutopilotState;
import com.zhidao.adas.client.bean.BasicInfoReq;
@@ -65,6 +65,7 @@ import com.zhidao.adas.client.bean.IPCConnectState;
import com.zhidao.adas.client.bean.MogoReportMessage;
import com.zhidao.adas.client.bean.OriginalPointCloudData;
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
import com.zhidao.adas.client.bean.PlanningDecisionState;
import com.zhidao.adas.client.bean.PlanningObjects;
import com.zhidao.adas.client.bean.PredictionObstacleTrajectory;
import com.zhidao.adas.client.bean.RecordDataConfig;
@@ -87,11 +88,13 @@ import com.zhidao.support.adas.high.bean.VersionCompatibility;
import com.zhidao.support.adas.high.common.ByteUtil;
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS;
import com.zhidao.support.adas.high.common.CupidLogUtils;
import com.zhidao.support.adas.high.common.MessageType;
import com.zhidao.support.adas.high.common.ProtocolStatus;
import com.zhidao.support.adas.high.common.ReceiveTimeoutManager;
import com.zhidao.support.adas.high.other.permission.BackgrounderPermission;
import com.zhidao.support.adas.high.other.permission.OnAdasPermissionListener;
import com.zhidao.support.adas.high.other.router.RouterActivity;
import com.zhidao.support.adas.high.subscribe.SubscribeInterfaceOptions;
import java.net.Inet4Address;
import java.net.InetAddress;
@@ -101,8 +104,10 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import chassis.VehicleStateOuterClass;
@@ -148,7 +153,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
private final List<String> titleBtnData = new ArrayList<>();
private final List<IPCConnectState> connectStatusList = new ArrayList<>();
private InfoTitleAdapter fragmentAdapter;
private Fragment fromFragment;
private BaseFragment fromFragment;
private FragmentManager manager;
private String ftpTime;
private boolean isPad;
@@ -613,9 +618,9 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
titleFragmentData.add(Constants.TITLE.RECEIVE_REPORT_MESSAGE);
titleFragmentData.add(Constants.TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT);
titleFragmentData.add(Constants.TITLE.RECEIVE_PREDICTION_OBSTACLE_TRAJECTORY);
titleFragmentData.add(Constants.TITLE.RECEIVE_POINT_CLOUD);
titleFragmentData.add(Constants.TITLE.RECEIVE_POINT_CLOUD_ORIGINAL);
titleFragmentData.add(Constants.TITLE.RECEIVE_PLANNING_OBJECTS);
titleFragmentData.add(Constants.TITLE.RECEIVE_PLANNING_DECISION_STATE);
titleFragmentData.add(Constants.TITLE.RECEIVE_CAR_CONFIG_RESP);
titleFragmentData.add(Constants.TITLE.RECEIVE_RECORD_DATA_CONFIG_RESP);
titleFragmentData.add(Constants.TITLE.RECEIVE_RECORD_RESULT);
@@ -882,7 +887,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
public void onBasicInfoReq(MessagePad.Header header, MessagePad.BasicInfoReq basicInfoReq) {
BasicInfoReq info = new BasicInfoReq(header, basicInfoReq, sdf);
DataDistribution.getInstance().addData(info);
AdasManager.getInstance().sendBasicInfoResp("X202021111192N41VY", 0);
AdasManager.getInstance().sendBasicInfoResp("", 0, com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DEBUG);
showToastCenter("收到车机基础信息请求:" + info.toString());
}
@@ -930,6 +935,12 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
DataDistribution.getInstance().addData(base);
}
@Override
public void onPlanningActionMsg(MessagePad.Header header, MessagePad.PlanningActionMsg planningActionMsg) {
PlanningDecisionState base = new PlanningDecisionState(header, planningActionMsg, sdf);
DataDistribution.getInstance().addData(base);
}
private void initAdas() {
CupidLogUtils.e(TAG, "--->初始化");
@@ -949,7 +960,6 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
public void onClientStatusConnectChanged(int statusCode, String sign, Channel channel) {
if (statusCode == ConnectState.STATUS_CONNECT_SUCCESS) {
connectStatus = IPC_CONNECTION_STATUS.CONNECTED;
AdasManager.getInstance().startDispatchHandler();
} else {
connectStatus = IPC_CONNECTION_STATUS.DISCONNECTED;
AdasManager.getInstance().stopDispatchHandler();
@@ -961,13 +971,20 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
} else {
/*—————————————作为司机端———————————*/
int mode = Constants.getIpcConnectionMode(this);
Set<MessageType> messageTypes = new HashSet<>();
// 注释掉下面代码,默认开启点云订阅
messageTypes.add(MessageType.TYPE_RECEIVE_POINT_CLOUD);
SubscribeInterfaceOptions subscribeInterfaceOptions = SubscribeInterfaceOptions.newBuilder()
.setRole(com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DEBUG)
.setType(com.zhidao.support.adas.high.common.Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE)
.setMessageTypes(messageTypes).build();
switch (mode) {
default:
case AdasOptions.IPC_CONNECTION_MODE.FIXATION:
options = new AdasOptions.Builder().setClient(false).setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(this)).setIpcConnectionMode(mode).build();
options = new AdasOptions.Builder().setSubscribeInterfaceOptions(subscribeInterfaceOptions).setClient(false).setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(this)).setIpcConnectionMode(mode).build();
break;
case AdasOptions.IPC_CONNECTION_MODE.ASSIGN:
options = new AdasOptions.Builder().setClient(false).setIpcAssignIP(Constants.getIPCIp(this)).setIpcConnectionMode(mode).build();
options = new AdasOptions.Builder().setSubscribeInterfaceOptions(subscribeInterfaceOptions).setClient(false).setIpcAssignIP(Constants.getIPCIp(this)).setIpcConnectionMode(mode).build();
break;
}
@@ -1024,6 +1041,9 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
@Override
public void onConnectionIPCStatus(int ipcConnectionStatus, String reason) {
if (fromFragment != null) {
fromFragment.updateConnectStatus(ipcConnectionStatus);
}
// Log.i(TAG, "连接状态=" + (reason == null ? "主动断开连接" : reason));
String time = sdf.format(new Date());
ConnectStatusSave.getInstance().saveLog(time + " ipcConnectionStatus=" + ipcConnectionStatus + " reason=" + reason);
@@ -1089,7 +1109,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
}
private void showFragment(String title) {
Fragment to = manager.findFragmentByTag(title);
BaseFragment to = (BaseFragment) manager.findFragmentByTag(title);
if (to == null) {
if (Constants.TITLE.RECEIVE_CAR_CONFIG_RESP.equals(title)) {
to = new VersionFragment(Constants.TITLE.TITLE_CAR_CONFIG_RESP);
@@ -1149,7 +1169,42 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
break;
case Constants.TITLE.SEND_BASIC_INFO_RESP:
//发送sn
AdasManager.getInstance().sendBasicInfoResp("X202021111192N41VY", 0);
//速度设置
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("发送SN");
View view = getLayoutInflater().inflate(R.layout.dialog_sn, null);
final EditText et = view.findViewById(R.id.et);
final EditText ev = view.findViewById(R.id.ev);
final EditText role = view.findViewById(R.id.role);
builder.setView(view);//
builder.setCancelable(false);//
builder.setPositiveButton("发送", null);
//设置反面按钮,并做事件处理
builder.setNegativeButton("取消", null);
AlertDialog alertDialog = builder.show();//显示Dialog对话框
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Editable editable = et.getText();
if (TextUtils.isEmpty(editable)) {
// 条件不成立不能关闭 AlertDialog 窗口
Toast.makeText(MainActivity.this, "请输入SN", Toast.LENGTH_SHORT).show();
return;
}
int evInt = 0;
Editable evEd = ev.getText();
if (!TextUtils.isEmpty(evEd)) {
evInt = Integer.parseInt(evEd.toString().trim());
}
int roleInt = com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DEBUG;
Editable roleEd = role.getText();
if (!TextUtils.isEmpty(roleEd)) {
roleInt = Integer.parseInt(roleEd.toString().trim());
}
AdasManager.getInstance().sendBasicInfoResp(editable.toString().trim(), evInt, roleInt);
alertDialog.dismiss();
}
});
break;
case Constants.TITLE.SEND_RECORD_DATA_5:
//数据采集5秒
@@ -1192,30 +1247,31 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
break;
case Constants.TITLE.SEND_SET_AUTOPILOT_SPEED_REQ:
//速度设置
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("自动驾驶限速");
View view = getLayoutInflater().inflate(R.layout.dialog_speed, null);
final EditText et = (EditText) view.findViewById(R.id.et);
builder.setView(view);//
builder.setCancelable(false);//
builder.setPositiveButton("设置", new DialogInterface.OnClickListener() {
AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
builder1.setTitle("自动驾驶限速");
View view1 = getLayoutInflater().inflate(R.layout.dialog_speed, null);
final EditText et1 = (EditText) view1.findViewById(R.id.et);
builder1.setView(view1);//
builder1.setCancelable(false);//
builder1.setPositiveButton("设置", null);
//设置反面按钮,并做事件处理
builder1.setNegativeButton("取消", null);
AlertDialog alertDialog1 = builder1.show();//显示Dialog对话框
alertDialog1.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Editable editable = et.getText();
public void onClick(View v) {
Editable editable = et1.getText();
if (TextUtils.isEmpty(editable)) {
// 条件不成立不能关闭 AlertDialog 窗口
Toast.makeText(MainActivity.this, "请输入速度", Toast.LENGTH_SHORT).show();
return;
}
String temp = et.getText().toString().trim();
String temp = et1.getText().toString().trim();
double speed = Double.parseDouble(temp) / 3.6;
AdasManager.getInstance().sendAutopilotSpeedReq(speed);
alertDialog1.dismiss();
}
});
//设置反面按钮,并做事件处理
builder.setNegativeButton("取消", null);
builder.show();//显示Dialog对话框
break;
case Constants.TITLE.SEND_SYSTEM_CMD_REQ_REBOOT:
//重启所有节点

View File

@@ -7,8 +7,13 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@@ -21,12 +26,15 @@ import androidx.recyclerview.widget.SimpleItemAnimator;
import com.zhidao.adas.client.BuildConfig;
import com.zhidao.adas.client.R;
import com.zhidao.adas.client.adapter.ConfigAdapter;
import com.zhidao.adas.client.adapter.InterfaceAdapter;
import com.zhidao.adas.client.base.BaseFragment;
import com.zhidao.adas.client.bean.Config;
import com.zhidao.adas.client.bean.InterfaceModel;
import com.zhidao.support.adas.high.AdasManager;
import com.zhidao.support.adas.high.bean.VersionCompatibility;
import com.zhidao.support.adas.high.common.Constants;
import com.zhidao.support.adas.high.common.CupidLogUtils;
import com.zhidao.support.adas.high.common.MessageType;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -34,6 +42,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import mogo.telematics.pad.MessagePad;
@@ -42,11 +51,26 @@ import mogo.telematics.pad.MessagePad;
*/
public class VersionFragment extends BaseFragment {
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS ", Locale.getDefault());
private TextView ipsView;
private EditText ipView;
private RecyclerView recyclerView;
private RecyclerView rec_registered;
private RecyclerView rec_unregistered;
private CheckBox registered_check_all;
private CheckBox unregistered_check_all;
private TextView hint_registered;
private TextView hint_unregistered;
private ConfigAdapter adapter;
private InterfaceAdapter unregisteredAdapter;
private InterfaceAdapter registeredAdapter;
private int role = Constants.TERMINAL_ROLE.DEBUG;//角色 默认调试屏
public VersionFragment() {
}
private ConfigAdapter adapter;
public VersionFragment(String title) {
super(title);
@@ -87,7 +111,7 @@ public class VersionFragment extends BaseFragment {
for (String ip : ips) {
i++;
builder.append(ip);
if (i % 2 == 0) {
if (i % 4 == 0) {
builder.append("\n");
} else {
builder.append("\t\t\t\t");
@@ -98,9 +122,6 @@ public class VersionFragment extends BaseFragment {
}
private TextView ipsView;
private EditText ipView;
private RecyclerView recyclerView;
private void initView(View view) {
TextView tvTitle = view.findViewById(R.id.tv_title);
@@ -113,7 +134,7 @@ public class VersionFragment extends BaseFragment {
CupidLogUtils.w("InfoFragment===>" + title);
tvTitle.setText(title);
tvTitle.setGravity(Gravity.CENTER);
initRegistrationView(view);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -154,6 +175,18 @@ public class VersionFragment extends BaseFragment {
}
//根据连接状态更新数据
@Override
public void onConnectionIPCStatus(int ipcConnectionStatus) {
super.onConnectionIPCStatus(ipcConnectionStatus);
if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.DISCONNECTED || ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
showVersion();
initRegistrationData();
if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.DISCONNECTED) {
clearRegistrationViewState();
}
}
}
public void showVersion() {
List<Config> list = new ArrayList<>();
@@ -204,4 +237,197 @@ public class VersionFragment extends BaseFragment {
adapter = new ConfigAdapter();
recyclerView.setAdapter(adapter);
}
private void initRegistrationView(View view) {
recyclerView = view.findViewById(R.id.config_list);
rec_registered = view.findViewById(R.id.rec_registered);
rec_unregistered = view.findViewById(R.id.rec_unregistered);
registered_check_all = view.findViewById(R.id.registered_check_all);
unregistered_check_all = view.findViewById(R.id.unregistered_check_all);
hint_unregistered = view.findViewById(R.id.hint_unregistered);
hint_registered = view.findViewById(R.id.hint_registered);
Button update = view.findViewById(R.id.update);
initFragmentRecyclerView();
initRegisteredRecyclerView();
initUnregisteredRecyclerView();
initSpinner(view);
registered_check_all.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isPressed()) {
registeredAdapter.setCheckAll(isChecked);
unregisteredAdapter.setCheckAll(false);
unregisteredAdapter.setEnabled(!isChecked);
unregistered_check_all.setEnabled(!isChecked);
}
}
});
registeredAdapter.setListener(new InterfaceAdapter.OnInterfaceAdapterListener() {
@Override
public void onCheckAll(boolean isCheckAll) {
registered_check_all.setChecked(isCheckAll);
}
@Override
public void onCheckNum(int checkNum) {
boolean isEnable = checkNum == 0;
unregisteredAdapter.setEnabled(isEnable);
unregistered_check_all.setEnabled(isEnable);
}
});
unregistered_check_all.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isPressed()) {
unregisteredAdapter.setCheckAll(isChecked);
registeredAdapter.setCheckAll(false);
registeredAdapter.setEnabled(!isChecked);
registered_check_all.setEnabled(!isChecked);
}
}
});
unregisteredAdapter.setListener(new InterfaceAdapter.OnInterfaceAdapterListener() {
@Override
public void onCheckAll(boolean isCheckAll) {
unregistered_check_all.setChecked(isCheckAll);
}
@Override
public void onCheckNum(int checkNum) {
boolean isEnable = checkNum == 0;
registeredAdapter.setEnabled(isEnable);
registered_check_all.setEnabled(isEnable);
}
});
update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
update();
}
});
initRegistrationData();
}
private void update() {
if (registeredAdapter.getCheckNum() == 0 && unregisteredAdapter.getCheckNum() == 0) {
Toast.makeText(getContext(), "请选择后在更新", Toast.LENGTH_SHORT).show();
return;
}
Set<MessageType> set;
if (registeredAdapter.getCheckNum() == 0) {
//注册
set = unregisteredAdapter.getCheckedModel();
if (set == null || set.isEmpty()) {
Toast.makeText(getContext(), "请选择要注册的接口", Toast.LENGTH_SHORT).show();
return;
}
if (set.size() == 1) {
AdasManager.getInstance().subscribeInterface(role, Constants.SUBSCRIBE_TYPE.SUBSCRIBE, set.iterator().next());
} else {
AdasManager.getInstance().subscribeInterface(role, Constants.SUBSCRIBE_TYPE.SUBSCRIBE, set);
}
} else {
//取消注册
set = registeredAdapter.getCheckedModel();
if (set == null || set.isEmpty()) {
Toast.makeText(getContext(), "请选择要取消注册的接口", Toast.LENGTH_SHORT).show();
return;
}
if (set.size() == 1) {
AdasManager.getInstance().subscribeInterface(role, Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE, set.iterator().next());
} else {
AdasManager.getInstance().subscribeInterface(role, Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE, set);
}
}
clearRegistrationViewState();
initRegistrationData();
}
private void clearRegistrationViewState() {
registered_check_all.setChecked(false);
unregistered_check_all.setChecked(false);
registered_check_all.setEnabled(true);
unregistered_check_all.setEnabled(true);
if (registeredAdapter != null)
registeredAdapter.notifyDataSetChanged();
if (unregisteredAdapter != null)
unregisteredAdapter.notifyDataSetChanged();
}
private void initRegistrationData() {
//初始化数据
Set<MessageType> set = AdasManager.getInstance().getSubscribedInterface();
List<InterfaceModel> registeredList = new ArrayList<>();
List<InterfaceModel> unregisteredList = new ArrayList<>();
if (set != null && !set.isEmpty()) {
registered_check_all.setVisibility(View.VISIBLE);
for (MessageType messageType : set) {
registeredList.add(new InterfaceModel(messageType));
}
} else {
registered_check_all.setVisibility(View.INVISIBLE);
}
set = AdasManager.getInstance().getUnsubscribedInterface();
if (set != null && !set.isEmpty()) {
unregistered_check_all.setVisibility(View.VISIBLE);
for (MessageType messageType : set) {
unregisteredList.add(new InterfaceModel(messageType));
}
} else {
unregistered_check_all.setVisibility(View.INVISIBLE);
}
registeredAdapter.setData(registeredList, 0);
unregisteredAdapter.setData(unregisteredList, 0);
hint_registered.setText("已注册接口(" + registeredAdapter.getItemCount() + ")");
hint_unregistered.setText("未注册接口(" + unregisteredAdapter.getItemCount() + ")");
}
private void initRegisteredRecyclerView() {
//创建默认的线性LayoutManager 横向的GridLayoutManager
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rec_registered.setLayoutManager(linearLayoutManager);
//如果可以确定每个item的高度是固定的设置这个选项可以提高性能
rec_registered.setHasFixedSize(false);
rec_registered.setNestedScrollingEnabled(false);
registeredAdapter = new InterfaceAdapter();
rec_registered.setAdapter(registeredAdapter);
}
private void initUnregisteredRecyclerView() {
//创建默认的线性LayoutManager 横向的GridLayoutManager
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rec_unregistered.setLayoutManager(linearLayoutManager);
//如果可以确定每个item的高度是固定的设置这个选项可以提高性能
rec_unregistered.setHasFixedSize(false);
rec_unregistered.setNestedScrollingEnabled(false);
unregisteredAdapter = new InterfaceAdapter();
rec_unregistered.setAdapter(unregisteredAdapter);
}
private void initSpinner(View view) {
String[] s = {"司机", "乘客", "调试"};
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, s);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner sp = view.findViewById(R.id.spinner);
sp.setAdapter(dataAdapter);
sp.setSelection(2);
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
role = position;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
}

View File

@@ -10,10 +10,8 @@ import com.zhidao.support.adas.high.common.JsonUtil;
import com.zhidao.support.adas.high.common.MessageType;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* @author song kenan
@@ -157,12 +155,12 @@ public class Constants {
String RECEIVE_REPORT_MESSAGE = MessageType.TYPE_RECEIVE_REPORT_MESSAGE.desc;
String RECEIVE_PERCEPTION_TRAFFIC_LIGHT = MessageType.TYPE_RECEIVE_PERCEPTION_TRAFFIC_LIGHT.desc;
String RECEIVE_PREDICTION_OBSTACLE_TRAJECTORY = MessageType.TYPE_RECEIVE_PREDICTION_OBSTACLE_TRAJECTORY.desc;
String RECEIVE_POINT_CLOUD = MessageType.TYPE_RECEIVE_POINT_CLOUD.desc;
String RECEIVE_POINT_CLOUD_ORIGINAL = "点云原始透传";
String RECEIVE_POINT_CLOUD_ORIGINAL = MessageType.TYPE_RECEIVE_POINT_CLOUD.desc;
String RECEIVE_PLANNING_OBJECTS = MessageType.TYPE_RECEIVE_PLANNING_OBJECTS.desc;
String RECEIVE_PLANNING_DECISION_STATE = MessageType.TYPE_RECEIVE_PLANNING_DECISION_STATE.desc;
// String RECEIVE_BASIC_INFO_REQ = "自动驾驶设备基础信息请求";
String TITLE_CAR_CONFIG_RESP = "工控机版本\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t固定IP配置";
String TITLE_CAR_CONFIG_RESP = "工控机版本\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t配置";
String RECEIVE_CAR_CONFIG_RESP = "信息与配置";
String RECEIVE_RECORD_RESULT = MessageType.TYPE_RECEIVE_RECORD_RESULT.desc;
String RECEIVE_RECORD_DATA_CONFIG_RESP = MessageType.TYPE_RECEIVE_RECORD_DATA_CONFIG_RESP.desc;

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#7CFC00" android:state_pressed="true" />
<item android:color="#7CFC00" android:state_checked="true" />
<item android:color="#c9c9c9" android:state_enabled="false" />
<item android:color="#000000" />
</selector>

View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.12"
android:gravity="right"
android:text="SN"
android:textColor="#000000" />
<EditText
android:id="@+id/et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="输入SN"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:minWidth="100dp"
android:textColor="#000"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.12"
android:gravity="right"
android:text="环境:"
android:textColor="#000000" />
<EditText
android:id="@+id/ev"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="默认01研发环境2测试环境3生产环境4演示环境"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLines="1"
android:minWidth="100dp"
android:textColor="#000"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.12"
android:gravity="right"
android:text="角色:"
android:textColor="#000000" />
<EditText
android:id="@+id/role"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="默认20司机屏1乘客屏2调试屏"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLines="1"
android:minWidth="100dp"
android:textColor="#000"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>

View File

@@ -52,7 +52,16 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:padding="10dp">
android:paddingStart="10dp">
<TextView
android:id="@+id/ip_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="工控机固定IP配置"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/ip"
@@ -71,13 +80,13 @@
android:textSize="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@id/ip_hint" />
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="36dp"
android:layout_margin="5dp"
android:background="@drawable/btn_bg"
android:text="添加"
@@ -89,7 +98,7 @@
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="36dp"
android:layout_margin="5dp"
android:layout_toEndOf="@id/btn1"
android:background="@drawable/btn_bg"
@@ -106,10 +115,151 @@
android:layout_marginTop="10dp"
android:lineSpacingExtra="5dp"
android:textIsSelectable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn1" />
<View
android:id="@+id/line2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ips_view" />
<TextView
android:id="@+id/interface_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="接收接口订阅、取消订阅配置"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="@id/update"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/update" />
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/update"
app:layout_constraintStart_toEndOf="@id/interface_hint"
app:layout_constraintTop_toTopOf="@id/update" />
<Button
android:id="@+id/update"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginTop="5dp"
android:background="@drawable/btn_bg"
android:text="更新"
android:textColor="#ffffff"
app:layout_constraintStart_toEndOf="@id/spinner"
app:layout_constraintTop_toBottomOf="@id/line2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="选中已注册接口点击更新取消注册\n选中未注册接口点击更新进行注册"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="@id/update"
app:layout_constraintStart_toEndOf="@id/update"
app:layout_constraintTop_toTopOf="@id/update" />
<LinearLayout
android:id="@+id/layout_list_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/update">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingStart="5dp"
android:paddingEnd="5dp">
<TextView
android:id="@+id/hint_registered"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="已注册接口" />
<CheckBox
android:id="@+id/registered_check_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_gravity="end"
android:text="全选" />
</RelativeLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="@color/colorSlateGray" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingStart="5dp"
android:paddingEnd="5dp">
<TextView
android:id="@+id/hint_unregistered"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:text="未注册接口" />
<CheckBox
android:id="@+id/unregistered_check_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="全选" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_list_title">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rec_registered"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="@color/colorSlateGray" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rec_unregistered"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -15,7 +15,7 @@
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:text="INFO"
android:textColor="@drawable/item_text_color"
android:textColor="@color/item_text_color"
android:textSize="14sp" />
</LinearLayout>

View File

@@ -15,7 +15,7 @@
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:text="INFO"
android:textColor="@drawable/item_text_color"
android:textColor="@color/item_text_color"
android:textSize="16sp" />
</LinearLayout>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="3dp"
android:layout_marginBottom="2dp"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<TextView
android:id="@+id/index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:textColor="@color/item_text_color1"
android:textSize="12sp" />
<CheckBox
android:id="@+id/item_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:ellipsize="marquee"
android:focusable="false"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="sssds"
android:textColor="@color/item_text_color1"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>

1
app_mogo_magic_ring/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1 @@
# 工控机测试程序

View File

@@ -0,0 +1,72 @@
import java.text.SimpleDateFormat
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
defaultConfig {
applicationId "com.zhidao.adas.magic"
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
packagingOptions {
//解决编译时com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'META-INF/rxjava.properties'这个错误
exclude 'META-INF/rxjava.properties'
}
externalNativeBuild {
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
//插入构建时间
buildTypes.each {
//设置时间格式
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd.HHmmss", Locale.getDefault())
//获取当前时间
Date curDate = new Date(System.currentTimeMillis())
String buildTime = formatter.format(curDate)
it.buildConfigField 'String', 'BUILD_TIME', "\"${buildTime}\""
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.material
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.androidxappcompat
implementation "androidx.recyclerview:recyclerview:1.2.1"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation rootProject.ext.dependencies.gson
implementation project(':libraries:mogo-adas')
compileOnly project(':core:mogo-core-data')
implementation project(':core:mogo-core-utils')
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.android.support:multidex:1.0.3'
}

26
app_mogo_magic_ring/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,26 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-----MogoMap-----
-keep class com.mogo.map.MogoNavi{
private <init>();
}

Some files were not shown because too many files have changed in this diff Show More