[Taxi driver V2.6.5] Taxi 司机端和 taxi乘客屏订单数据同步
This commit is contained in:
@@ -150,16 +150,12 @@ public abstract class BaseOchBusTabFragment<V extends IView, P extends Presenter
|
||||
});
|
||||
}
|
||||
initListener();
|
||||
ctvAutopilotStatus.setOnClickListener(v -> {
|
||||
// 如果能自动驾驶,就自动驾驶,不能就提示
|
||||
// if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
|
||||
// return;
|
||||
// }
|
||||
// if (autopilotLoadingAnimator != null){
|
||||
// TipToast.shortTip("正在开启自动驾驶。。。");
|
||||
// return;
|
||||
// }
|
||||
restartAutopilot();
|
||||
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClickImpl(View v) {
|
||||
restartAutopilot();
|
||||
}
|
||||
});
|
||||
|
||||
// debug下调用测试面板 2022.2.25修改到 长按当前站点名字
|
||||
|
||||
@@ -51,15 +51,20 @@ import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import io.reactivex.exceptions.UndeliverableException;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
|
||||
|
||||
/**
|
||||
@@ -138,13 +143,41 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
mContext = context.getApplicationContext();
|
||||
initListeners();
|
||||
|
||||
// IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
|
||||
// apis.getSocketManagerApi(mContext).init(mContext, DebugConfig.getSocketAppId());
|
||||
// TODO: 2021/8/27 因需要通过此回调的location进行坐标上传,暂改为全程监听,退出后再反注册,
|
||||
// 待后续整体调整location获取来源
|
||||
// if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
|
||||
// apis.getLocationInfoApi().start();
|
||||
// }
|
||||
// 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃
|
||||
// The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the excTeption has nowhere to go to begin with
|
||||
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable e) {
|
||||
if (e instanceof UndeliverableException) {
|
||||
e = e.getCause();
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "UndeliverableException");
|
||||
}
|
||||
if ((e instanceof IOException)) {//
|
||||
// fine, irrelevant network problem or API that throws on cancellation
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "IOException");
|
||||
return;
|
||||
}
|
||||
if (e instanceof InterruptedException) {
|
||||
// fine, some blocking code was interrupted by a dispose call
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "InterruptedException");
|
||||
return;
|
||||
}
|
||||
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
|
||||
// that's likely a bug in the application
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "NullPointerException or IllegalArgumentException");
|
||||
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
|
||||
return;
|
||||
}
|
||||
if (e instanceof IllegalStateException) {
|
||||
// that's a bug in RxJava or in a custom operator
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "IllegalStateException");
|
||||
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG,"Undeliverable exception");
|
||||
}
|
||||
});
|
||||
|
||||
startOrStopOrderLoop();
|
||||
}
|
||||
|
||||
@@ -606,6 +639,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
calculateRouteLineSum(data.data);
|
||||
mAutopilotPlanningCallback.routeResultByServer(data.data);
|
||||
}
|
||||
}else {
|
||||
queryOrderRouteList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,14 +99,14 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
|
||||
mView.updateOrderStatusView(order);
|
||||
}else if (mCurrentPassengerOrder.orderStatus != order.orderStatus) {
|
||||
mView.updateOrderStatusView(order);
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, GsonUtil.jsonFromObject(order));
|
||||
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEndStation.getCode() == order.orderStatus){
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "-----OnTheWayToEndStation----");
|
||||
TaxiPassengerModel.getInstance().startOrStopQueryOrderRemaining(true);
|
||||
TaxiPassengerModel.getInstance().queryOrderRouteList();
|
||||
}
|
||||
|
||||
if (TaxiPassengerOrderStatusEnum.Cancel.getCode() == mCurrentPassengerOrder.orderStatus
|
||||
|| TaxiPassengerOrderStatusEnum.ArriveAtStartStation.getCode() == mCurrentPassengerOrder.orderStatus){
|
||||
|| TaxiPassengerOrderStatusEnum.ArriveAtEndStation.getCode() == mCurrentPassengerOrder.orderStatus){
|
||||
TaxiPassengerModel.getInstance().startOrStopQueryOrderRemaining(false);
|
||||
}
|
||||
mCurrentPassengerOrder = order;
|
||||
|
||||
@@ -316,7 +316,6 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
}
|
||||
|
||||
mPresenter.routeResult(list);
|
||||
// TaxiPassengerModel.getInstance().startOrStopQueryOrderRemaining(true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -484,26 +483,25 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
/**
|
||||
* 剩余里程,剩余时间,当前定位点所在道路
|
||||
* @param meters 单位 米
|
||||
* @param remainTime 单位 分钟
|
||||
* @param remainTime 单位 秒
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public void onCurrentOrderDistToEndChanged(long meters, long remainTime) {
|
||||
String disUnit = "公里";
|
||||
String remainDis = "";
|
||||
if (meters == 0f){
|
||||
remainDis = "0";
|
||||
}else {
|
||||
String remainDis = "0";
|
||||
|
||||
if (meters > 0){
|
||||
if (meters / 1000 < 1){
|
||||
disUnit = "米";
|
||||
remainDis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
DecimalFormat fnum = new DecimalFormat("##0.00");
|
||||
remainDis = fnum.format((float) meters / 1000);
|
||||
remainDis = TaxiPassengerUtils.formatLong((double) meters / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
int time = new Long(remainTime).intValue();
|
||||
int time = (int)Math.ceil((double)remainTime/ 60f);
|
||||
|
||||
Calendar beforeTime = Calendar.getInstance();
|
||||
beforeTime.add(Calendar.MINUTE,time);
|
||||
String arriveTime = TaxiPassengerUtils.formatCalendarToString(beforeTime,TaxiPassengerUtils.TAXI_HH_mm);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.mogo.och.taxi.passenger.utils;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.DateTimeUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -89,4 +92,18 @@ public class TaxiPassengerUtils {
|
||||
int minute = (int)(seconds % 3600)/60;
|
||||
return String.valueOf(minute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 有小数两位, 没有小数保留整数
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
public static String formatLong(double d) {
|
||||
BigDecimal bg = new BigDecimal(d).setScale(2, RoundingMode.UP);
|
||||
double num = bg.doubleValue();
|
||||
if (Math.round(num) - num == 0) {
|
||||
return String.valueOf((long) num);
|
||||
}
|
||||
return String.valueOf(num);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1119,9 +1119,9 @@ public class MogoOCHTaxiModelNew {
|
||||
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude);
|
||||
|
||||
float lastSumLength = 0f;
|
||||
float lastSumLength = 0;
|
||||
|
||||
if (lastPoints.size() == 1){
|
||||
if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
lastPoints.get(0).longitude, lastPoints.get(0).latitude,
|
||||
mLongitude, mLatitude);
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.mogo.och.taxi.ui;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Build;
|
||||
@@ -41,7 +39,6 @@ import com.mogo.och.taxi.model.MogoOCHTaxiModelNew;
|
||||
import com.mogo.och.taxi.model.NaviToDestinationModel;
|
||||
import com.mogo.och.taxi.utils.OchTaxiUtils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
@@ -302,7 +299,7 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
* @param timeInSecond 秒
|
||||
*/
|
||||
public void updateDistanceAndTime(long meters, long timeInSecond) {
|
||||
// CallerLogger.INSTANCE.d(M_TAXI + TAG,"meters = "+meters);
|
||||
// CallerLogger.INSTANCE.d(M_TAXI + TAG,"meters = "+meters+"timeInSecond ="+timeInSecond);
|
||||
String dis = "0";
|
||||
String disUnit = "公里";
|
||||
if (meters > 0){
|
||||
@@ -311,12 +308,12 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
dis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
DecimalFormat fnum = new DecimalFormat("##0.00");
|
||||
dis = fnum.format((float) meters / 1000);
|
||||
dis = OchTaxiUtils.formatLong((double)meters / 1000);
|
||||
}
|
||||
}
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">里程 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> "+disUnit+"</font>"
|
||||
+ "<font color=\"#CAD6FF\">,剩余 </font>" + "<b><font color=\"#FFFFFF\">" + Math.ceil(timeInSecond/ 60) + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
+ "<font color=\"#CAD6FF\">,剩余 </font>" + "<b><font color=\"#FFFFFF\">" + (int)Math.ceil((double)timeInSecond/ 60f) + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
|
||||
if (mContentModule3 != null && mContentModule3.getVisibility() == View.VISIBLE) { //前往上车点
|
||||
|
||||
mDistanceAndTime3.setText(Html.fromHtml(strHtml2));
|
||||
@@ -325,8 +322,6 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
if (mTtsLessThan200Tip < 1 && meters <= 250 && meters > 150){
|
||||
speekVoice200mTipsOnce();
|
||||
}
|
||||
// String strHtml2 = "<font color=\"#CAD6FF\">里程 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> "+disUnit+"</font>"
|
||||
// + "<font color=\"#CAD6FF\">,剩余 </font>" + "<b><font color=\"#FFFFFF\">" + Math.ceil(timeInSecond / 60) + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
mDistanceAndTime2.setText(Html.fromHtml(strHtml2));
|
||||
}
|
||||
|
||||
@@ -338,17 +333,19 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
}
|
||||
|
||||
public void onCurrentOrderRouteInfoGot(OrderQueryRouteInfoRespBean.Result routeInfo) {// 单位 米, 秒
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "meters = " + routeInfo.durationToEnd);
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "durationToEnd = " + routeInfo.durationToEnd);
|
||||
|
||||
String dis = "0";
|
||||
long distance = routeInfo.distanceToEnd;
|
||||
long duration = routeInfo.durationToEnd;
|
||||
|
||||
if (routeInfo.distanceToEnd > 0){
|
||||
DecimalFormat fnum = new DecimalFormat("##0.00");
|
||||
dis = fnum.format((float) routeInfo.distanceToEnd / 1000);
|
||||
|
||||
dis = OchTaxiUtils.formatLong( (double) distance/ 1000);
|
||||
}
|
||||
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">距离 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> 公里</font>"
|
||||
+ "<font color=\"#CAD6FF\">,用时 </font>" + "<b><font color=\"#FFFFFF\">" + Math.ceil(routeInfo.durationToEnd / 60) + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
+ "<font color=\"#CAD6FF\">,用时 </font>" + "<b><font color=\"#FFFFFF\">" + (int)Math.ceil( (double) duration/ 60) + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
if (mContentModule2 != null && mContentModule2.getVisibility() == View.VISIBLE) {
|
||||
mDistanceAndTime2.setText(Html.fromHtml(strHtml2));
|
||||
} else if (mContentModule3 != null && mContentModule3.getVisibility() == View.VISIBLE) {
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.mogo.och.taxi.utils;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.DateTimeUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -90,4 +92,18 @@ public class OchTaxiUtils {
|
||||
int minute = (int)(seconds % 3600)/60;
|
||||
return String.valueOf(minute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 有小数两位, 没有小数保留整数
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
public static String formatLong(double d) {
|
||||
BigDecimal bg = new BigDecimal(d).setScale(2, RoundingMode.UP);
|
||||
double num = bg.doubleValue();
|
||||
if (Math.ceil(num) - num == 0) {
|
||||
return String.valueOf((long) num);
|
||||
}
|
||||
return String.valueOf(num);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user