[通用模块整理] util工具类整理
This commit is contained in:
@@ -53,6 +53,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.amapnavi3dmap
|
||||
implementation project(":OCH:mogo-och-common-module")
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerModelLoopManager;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceCallback;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager;
|
||||
import com.mogo.och.bus.passenger.utils.BPCoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -355,7 +355,7 @@ public class BusPassengerModel {
|
||||
};
|
||||
|
||||
public void dynamicCalculateRouteInfo() {
|
||||
List<LatLng> lastPoints = BPCoordinateCalculateRouteUtil
|
||||
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude);
|
||||
|
||||
float lastSumLength = 0;
|
||||
@@ -364,7 +364,7 @@ public class BusPassengerModel {
|
||||
lastPoints.get(0).longitude, lastPoints.get(0).latitude,
|
||||
mLongitude, mLatitude);
|
||||
}else {
|
||||
lastSumLength = BPCoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
|
||||
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
|
||||
}
|
||||
double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒
|
||||
|
||||
@@ -377,13 +377,13 @@ public class BusPassengerModel {
|
||||
public void updateRoutePoints(List<MessagePad.Location> routePoints) {
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.routeResult(
|
||||
BPCoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext
|
||||
, routePoints));
|
||||
}
|
||||
|
||||
//转换成高德坐标系
|
||||
mRoutePoints.clear();
|
||||
mRoutePoints.addAll(BPCoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routePoints));
|
||||
mRoutePoints.addAll(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routePoints));
|
||||
//开启实时计算剩余距离,剩余时间,预计时间
|
||||
startOrStopCalculateRouteInfo(true);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.map.CallerSmpManager;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.utils.BPDateTimeUtil;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
@@ -111,7 +111,7 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
dis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
dis = BPDateTimeUtil.formatLong((double)meters / 1000);
|
||||
dis = NumberFormatUtil.formatLong((double)meters / 1000);
|
||||
}
|
||||
}
|
||||
String strHtml2 = "<font color=\"#2D3E5F\">距离 </font>" + "<b><font color=\"#0043FF\">" + dis + "</font></b>" + "<font color=\"#2D3E5F\"> "+disUnit+"</font>"
|
||||
|
||||
@@ -22,8 +22,8 @@ import com.mogo.och.bus.passenger.adapter.BusPassengerLineStationsAdapter;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerMapViewCallback;
|
||||
import com.mogo.och.bus.passenger.presenter.BaseBusPassengerPresenter;
|
||||
import com.mogo.och.bus.passenger.utils.BPCoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.bus.passenger.utils.BPRouteDataTestUtils;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -241,7 +241,7 @@ public class BusPassengerRouteFragment extends
|
||||
private void updateWayPointList(List<BusPassengerStation> stations,int currentStationIndex) {
|
||||
mLinePointsList.clear();
|
||||
for (int i = 0; i< stations.size(); i++) {//站点集合
|
||||
LatLng latLng = BPCoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(getContext()
|
||||
LatLng latLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(getContext()
|
||||
,stations.get(i).getLon(),stations.get(i).getLat());// lat,lon
|
||||
mLinePointsList.add(latLng);
|
||||
}
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
|
||||
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_BUS_P;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/28
|
||||
*/
|
||||
public class BPCoordinateCalculateRouteUtil {
|
||||
|
||||
public static float calculateRouteSumLength(List<LatLng> points){
|
||||
if (null == points || points.size() == 0) return 0;
|
||||
|
||||
float sumLength = 0;
|
||||
|
||||
//计算全路径总距离
|
||||
for (int i = 0;i + 1< points.size();i++){
|
||||
double preLat = points.get(i).latitude;
|
||||
double preLon = points.get(i).longitude;
|
||||
double laLat = points.get(i+1).latitude;
|
||||
double laLon = points.get(i+1).longitude;
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
return sumLength;
|
||||
}
|
||||
|
||||
public static List<LatLng> coordinateConverterWgsToGcjListCommon(Context mContext, List<MessagePad.Location> models) {
|
||||
//转成MogoLatLng集合
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MessagePad.Location m : models) {
|
||||
LatLng mogoLatLng = coordinateConverterWgsToGcj(mContext, m);
|
||||
list.add(mogoLatLng);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static LatLng coordinateConverterWgsToGcj(Context mContext, double lon, double lat) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(lat,lon));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
public static LatLng coordinateConverterWgsToGcj(Context mContext, MessagePad.Location mogoLatLng) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(mogoLatLng.getLatitude(), mogoLatLng.getLongitude()));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 todo 需要优化
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return
|
||||
*/
|
||||
public static List<LatLng> getRemainPointListByCompare(List<LatLng> mRoutePoints,double realLon,double realLat) {
|
||||
List<LatLng> latePoints = new ArrayList<>();
|
||||
int currentIndex = 0; //记录疑似点
|
||||
if (mRoutePoints.size() > 0){
|
||||
//基础点
|
||||
LatLng baseLatLng = mRoutePoints.get(0);
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,baseLatLng.longitude,baseLatLng.latitude);// lon,lat, prelon, prelat
|
||||
|
||||
for (int i= 1; i < mRoutePoints.size(); i++){
|
||||
LatLng latLng = mRoutePoints.get(i);
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,latLng.longitude,latLng.latitude);
|
||||
if (baseDiffDis > diff){
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
Logger.d(M_BUS_P + "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
|
||||
if (currentIndex == mRoutePoints.size()-1){
|
||||
latePoints.add(mRoutePoints.get(currentIndex));
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -11,6 +11,7 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
@@ -45,7 +46,7 @@ import com.mogo.och.bus.net.BusServiceManager;
|
||||
import com.mogo.och.bus.net.IBusServiceCallback;
|
||||
import com.mogo.och.bus.presenter.BusModelLoopManager;
|
||||
import com.mogo.och.bus.util.BusAnalyticsUtil;
|
||||
import com.mogo.och.bus.util.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -217,13 +218,25 @@ public class BusOrderModel {
|
||||
public void onAutopilotRotting(MessagePad.GlobalPathResp routeList) {
|
||||
if (null != routeList && routeList.getWayPointsList().size() > 0){
|
||||
points.clear();
|
||||
points.addAll(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjList(mContext,routeList.getWayPointsList()));
|
||||
points.addAll(coordinateConverterWgsToGcjList(mContext,routeList.getWayPointsList()));
|
||||
updateOrderRoute();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static List<BusRoutePlanningUpdateReqBean.Result> coordinateConverterWgsToGcjList(Context mContext, List<MessagePad.Location> mogoLatLngList) {
|
||||
List<BusRoutePlanningUpdateReqBean.Result> points = new ArrayList<>();
|
||||
for (MessagePad.Location m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m);
|
||||
BusRoutePlanningUpdateReqBean.Result result = new BusRoutePlanningUpdateReqBean.Result();
|
||||
result.latitude = mogoLatLng.latitude;
|
||||
result.longitude = mogoLatLng.longitude;
|
||||
points.add(result);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报订单全路径规划数据
|
||||
*/
|
||||
@@ -253,7 +266,7 @@ public class BusOrderModel {
|
||||
|
||||
public void debugUpdateOrderRoute(List<MessagePad.Location> list){
|
||||
points.clear();
|
||||
points.addAll(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjList(mContext,list));
|
||||
points.addAll(coordinateConverterWgsToGcjList(mContext,list));
|
||||
updateOrderRoute();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
package com.mogo.och.bus.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean;
|
||||
|
||||
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_BUS;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/28
|
||||
*/
|
||||
public class CoordinateCalculateRouteUtil {
|
||||
|
||||
public static float calculateRouteSumLength(List<LatLng> points){
|
||||
if (null == points || points.size() == 0) return 0;
|
||||
|
||||
float sumLength = 0;
|
||||
|
||||
//计算全路径总距离
|
||||
for (int i = 0;i + 1< points.size();i++){
|
||||
double preLat = points.get(i).latitude;
|
||||
double preLon = points.get(i).longitude;
|
||||
double laLat = points.get(i+1).latitude;
|
||||
double laLon = points.get(i+1).longitude;
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
return sumLength;
|
||||
}
|
||||
|
||||
public static List<LatLng> coordinateConverterWgsToGcjListCommon(Context mContext, List<MessagePad.Location> models) {
|
||||
//转成MogoLatLng集合
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MessagePad.Location m : models) {
|
||||
LatLng mogoLatLng = coordinateConverterWgsToGcj(mContext, m);
|
||||
list.add(mogoLatLng);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static LatLng coordinateConverterWgsToGcj(Context mContext, MessagePad.Location mogoLatLng) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(mogoLatLng.getLatitude(), mogoLatLng.getLongitude()));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
|
||||
public static List<BusRoutePlanningUpdateReqBean.Result> coordinateConverterWgsToGcjList(Context mContext, List<MessagePad.Location> mogoLatLngList) {
|
||||
List<BusRoutePlanningUpdateReqBean.Result> points = new ArrayList<>();
|
||||
for (MessagePad.Location m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m);
|
||||
BusRoutePlanningUpdateReqBean.Result result = new BusRoutePlanningUpdateReqBean.Result();
|
||||
result.latitude = mogoLatLng.latitude;
|
||||
result.longitude = mogoLatLng.longitude;
|
||||
points.add(result);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据实时定位的坐标确定出已行驶到那个坐标点 todo 有问题 暂不使用
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return 返回剩余路径集合
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<LatLng> getCurrentPoinByCompare(List<LatLng> mRoutePoints, double realLon, double realLat) {
|
||||
// 疑似坐标 先以坐标中间1/2为第一个比对点
|
||||
int currentIndex = Math.round(mRoutePoints.size()/2);
|
||||
LatLng currentLatLng = mRoutePoints.get(currentIndex);
|
||||
|
||||
//差值初始化
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,currentLatLng.longitude,currentLatLng.latitude);// lon,lat, prelon, prelat
|
||||
|
||||
List<LatLng> latePoints = new ArrayList<>();
|
||||
//与选中点左右比较
|
||||
if (currentIndex -1 >= 0 && currentIndex+1<= mRoutePoints.size()-1){
|
||||
LatLng leftCurrentLatLng = mRoutePoints.get(currentIndex -1);
|
||||
LatLng rightCurentLatLng = mRoutePoints.get(currentIndex + 1);
|
||||
float leftDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,leftCurrentLatLng.longitude,leftCurrentLatLng.latitude);
|
||||
float rightDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat,rightCurentLatLng.longitude,rightCurentLatLng.latitude);
|
||||
|
||||
if (rightDiffDis < leftDiffDis){ //靠近了右半边
|
||||
baseDiffDis = rightDiffDis;
|
||||
for (int i = currentIndex +1; i+1 <mRoutePoints.size() ;i++){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,mRoutePoints.get(i).longitude,mRoutePoints.get(i).latitude);
|
||||
Logger.d(M_BUS + "Compare右半边集合", "点:"+i+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
if (baseDiffDis >= diff){
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
if (i == mRoutePoints.size()-1){
|
||||
latePoints.addAll(mRoutePoints);
|
||||
}
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
}else if (rightDiffDis > leftDiffDis){ //靠近左半边
|
||||
baseDiffDis = leftDiffDis;
|
||||
for (int j = currentIndex-1; j -1 >=0 ;j++){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat,mRoutePoints.get(j).longitude,mRoutePoints.get(j).latitude);
|
||||
Logger.d(M_BUS + "Compare左半边集合", "点:"+j+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
if (baseDiffDis >= diff){
|
||||
baseDiffDis = diff;
|
||||
currentIndex = j;
|
||||
if (j == 0){
|
||||
latePoints.addAll(mRoutePoints);
|
||||
}
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
Logger.d(M_BUS + "正好相等", "点:"+currentIndex+"------------baseDiffDis = "+baseDiffDis+"---diff="+leftDiffDis);
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,currentIndex));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 todo 需要优化
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return
|
||||
*/
|
||||
public static List<LatLng> getRemainPointListByCompare(List<LatLng> mRoutePoints,double realLon,double realLat) {
|
||||
List<LatLng> latePoints = new ArrayList<>();
|
||||
int currentIndex = 0; //记录疑似点
|
||||
if (mRoutePoints.size() > 0){
|
||||
//基础点
|
||||
LatLng baseLatLng = mRoutePoints.get(0);
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,baseLatLng.longitude,baseLatLng.latitude);// lon,lat, prelon, prelat
|
||||
|
||||
for (int i= 1; i < mRoutePoints.size(); i++){
|
||||
LatLng latLng = mRoutePoints.get(i);
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,latLng.longitude,latLng.latitude);
|
||||
if (baseDiffDis > diff){
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
Logger.d(M_BUS + "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
|
||||
if (currentIndex == mRoutePoints.size()-1){
|
||||
latePoints.add(mRoutePoints.get(currentIndex));
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.och.common.module.utils;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
@@ -56,6 +54,14 @@ public class CoordinateCalculateRouteUtil {
|
||||
return latLng;
|
||||
}
|
||||
|
||||
public static LatLng coordinateConverterWgsToGcj(Context mContext, double lon, double lat) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(lat,lon));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据实时定位的坐标确定出已行驶到那个坐标点 todo 有问题 暂不使用
|
||||
@@ -88,7 +94,7 @@ public class CoordinateCalculateRouteUtil {
|
||||
for (int i = currentIndex +1; i+1 <mRoutePoints.size() ;i++){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,mRoutePoints.get(i).longitude,mRoutePoints.get(i).latitude);
|
||||
Logger.d(M_TAXI + "Compare右半边集合", "点:"+i+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
// Logger.d(M_TAXI + "Compare右半边集合", "点:"+i+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
if (baseDiffDis >= diff){
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
@@ -104,7 +110,7 @@ public class CoordinateCalculateRouteUtil {
|
||||
baseDiffDis = leftDiffDis;
|
||||
for (int j = currentIndex-1; j -1 >=0 ;j++){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat,mRoutePoints.get(j).longitude,mRoutePoints.get(j).latitude);
|
||||
Logger.d(M_TAXI + "Compare左半边集合", "点:"+j+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
// Logger.d(M_TAXI + "Compare左半边集合", "点:"+j+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
if (baseDiffDis >= diff){
|
||||
baseDiffDis = diff;
|
||||
currentIndex = j;
|
||||
@@ -117,7 +123,7 @@ public class CoordinateCalculateRouteUtil {
|
||||
}
|
||||
}
|
||||
}else {
|
||||
Logger.d(M_TAXI + "正好相等", "点:"+currentIndex+"------------baseDiffDis = "+baseDiffDis+"---diff="+leftDiffDis);
|
||||
// Logger.d(M_TAXI + "正好相等", "点:"+currentIndex+"------------baseDiffDis = "+baseDiffDis+"---diff="+leftDiffDis);
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,currentIndex));
|
||||
return latePoints;
|
||||
}
|
||||
@@ -151,7 +157,7 @@ public class CoordinateCalculateRouteUtil {
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
|
||||
if (currentIndex == mRoutePoints.size()-1){
|
||||
latePoints.add(mRoutePoints.get(currentIndex));
|
||||
}else {
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package com.mogo.och.bus.passenger.utils;
|
||||
package com.mogo.och.common.module.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;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/8/20
|
||||
* @date: 2022/5/6
|
||||
*/
|
||||
public class BPDateTimeUtil {
|
||||
|
||||
public class DateTimeUtil {
|
||||
public static final String TAXI_HH_mm = "HH:mm";
|
||||
public static final String TAXI_MM_dd = "MM-dd";
|
||||
public static final String TAXI_MM_dd_HH_mm = "MM-dd HH:mm";
|
||||
@@ -51,13 +48,13 @@ public class BPDateTimeUtil {
|
||||
return calendar;
|
||||
}
|
||||
public static String formatLongToString(long time, String format){
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
||||
return dateFormat.format(time);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
||||
return dateFormat.format(time);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static String getYMDTime(long time){//格式为 2021.8.21
|
||||
try {
|
||||
@@ -92,18 +89,4 @@ public class BPDateTimeUtil {
|
||||
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(1, RoundingMode.HALF_UP);
|
||||
double num = bg.doubleValue();
|
||||
if (Math.ceil(num) - num == 0) {
|
||||
return String.valueOf((long) num);
|
||||
}
|
||||
return String.valueOf(num);
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.mogo.och.common.module.utils
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.DateTimeUtils
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.math.ceil
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/4/27
|
||||
*/
|
||||
class DateTimeUtil {
|
||||
fun formatCalendarToString(calendar: Calendar?, format: String?): String {
|
||||
if (calendar == null) return ""
|
||||
try {
|
||||
val dateFormat = SimpleDateFormat(format)
|
||||
return dateFormat.format(calendar.time)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun compareDateIsCurrentDay(targetCalendar: Calendar?): Boolean {
|
||||
val currentCale = DateTimeUtils.getCurrentDateTime()
|
||||
val currentDay = formatCalendarToString(currentCale, COMMON_yyyy_MM_dd)
|
||||
return currentDay == formatCalendarToString(targetCalendar, COMMON_yyyy_MM_dd)
|
||||
}
|
||||
|
||||
fun formatLongToCalendar(time: Long): Calendar? {
|
||||
var calendar: Calendar? = null
|
||||
try {
|
||||
calendar = Calendar.getInstance()
|
||||
calendar.timeInMillis = time
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return calendar
|
||||
}
|
||||
|
||||
fun formatLongToString(time: Long, format: String?): String? {
|
||||
try {
|
||||
val dateFormat = SimpleDateFormat(format)
|
||||
return dateFormat.format(time)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun getYMDTime(time: Long): String? { //格式为 2021.8.21
|
||||
try {
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.timeInMillis = time
|
||||
val month = calendar[Calendar.MONTH] + 1
|
||||
return calendar[Calendar.YEAR].toString() + "." + month + "." + calendar[Calendar.DAY_OF_MONTH]
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param seconds 60
|
||||
* @return 1 时
|
||||
*/
|
||||
fun secondsToHourStr(seconds: Long): String? { //秒数转成相应的 小时分钟数
|
||||
if (seconds >= 3600) {
|
||||
val hours = seconds.toInt() / 3600
|
||||
return hours.toString()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param seconds 60
|
||||
* @return 1 时
|
||||
*/
|
||||
fun secondsToMinuteStr(seconds: Long): String? { //秒数转成相应的 小时分钟数
|
||||
val minute = (seconds % 3600).toInt() / 60
|
||||
return minute.toString()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val COMMON_HH_mm = "HH:mm"
|
||||
const val COMMON_MM_dd = "MM-dd"
|
||||
const val COMMON_MM_dd_HH_mm = "MM-dd HH:mm"
|
||||
const val COMMON_yyyy_MM_dd = "yyyy-MM-dd"
|
||||
const val COMMON_yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.och.common.module.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/5/6
|
||||
*/
|
||||
public class NumberFormatUtil {
|
||||
/**
|
||||
* 有小数两位, 没有小数保留整数
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
public static String formatLong(double d) {
|
||||
BigDecimal bg = new BigDecimal(d).setScale(1, RoundingMode.HALF_UP);
|
||||
double num = bg.doubleValue();
|
||||
if (Math.ceil(num) - num == 0) {
|
||||
return String.valueOf((long) num);
|
||||
}
|
||||
return String.valueOf(num);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.och.common.module.utils
|
||||
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
import kotlin.math.ceil
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/4/28
|
||||
*/
|
||||
class NumerFormatUtil {
|
||||
|
||||
/**
|
||||
* 有小数两位, 没有小数保留整数
|
||||
* @param d
|
||||
* @param scaleInt 若有小数保留几位小数
|
||||
* @return
|
||||
*/
|
||||
fun formatLong(d: Double, scaleInt: Int): String? {
|
||||
val bg = BigDecimal(d).setScale(scaleInt, RoundingMode.HALF_UP)
|
||||
val num = bg.toDouble()
|
||||
if (ceil(num) - num == 0.0) {
|
||||
return (num as Long).toString()
|
||||
}
|
||||
return num.toString()
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.amapnavi3dmap
|
||||
implementation rootProject.ext.dependencies.amapsearch
|
||||
implementation project(":OCH:mogo-och-common-module")
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
|
||||
Binary file not shown.
@@ -29,6 +29,7 @@ import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean;
|
||||
@@ -44,7 +45,6 @@ import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum;
|
||||
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceCallback;
|
||||
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceManager;
|
||||
import com.mogo.aicloud.services.socket.IMogoLifecycleListener;
|
||||
import com.mogo.och.taxi.passenger.utils.TPCoordinateCalculateRouteUtil;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -563,7 +563,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
@Override
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) {
|
||||
if (null != routeList && routeList.getWayPointsList().size() > 0){
|
||||
calculateRouteLineSum(TPCoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routeList.getWayPointsList()));
|
||||
calculateRouteLineSum(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routeList.getWayPointsList()));
|
||||
updateRouteResult(routeList.getWayPointsList());
|
||||
}
|
||||
}
|
||||
@@ -669,7 +669,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
}
|
||||
|
||||
public void calculateRouteLineSum(List<LatLng> points){
|
||||
float sumLength = TPCoordinateCalculateRouteUtil.calculateRouteSumLength(points);
|
||||
float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(points);
|
||||
SharedPrefsMgr.getInstance(mContext).putInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS,(int) sumLength);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
import com.mogo.och.taxi.passenger.R;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback;
|
||||
@@ -30,7 +32,6 @@ import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum;
|
||||
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel;
|
||||
import com.mogo.och.taxi.passenger.presenter.TaxiPassengerServingOrderPresenter;
|
||||
import com.mogo.och.taxi.passenger.utils.TPRouteDataTestUtils;
|
||||
import com.mogo.och.taxi.passenger.utils.TaxiPassengerUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
@@ -298,7 +299,7 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
remainDis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
remainDis = TaxiPassengerUtils.formatLong((double) meters / 1000);
|
||||
remainDis = NumberFormatUtil.formatLong((double) meters / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +307,7 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
|
||||
Calendar beforeTime = Calendar.getInstance();
|
||||
beforeTime.add(Calendar.MINUTE,time);
|
||||
String arriveTime = TaxiPassengerUtils.formatCalendarToString(beforeTime,TaxiPassengerUtils.TAXI_HH_mm);
|
||||
String arriveTime = DateTimeUtil.formatCalendarToString(beforeTime,DateTimeUtil.TAXI_HH_mm);
|
||||
updateOrderDisAndTimeView(remainDis, disUnit,time, arriveTime);
|
||||
updateDriveProcessLoading(new Long(meters).intValue());
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.utils
|
||||
|
||||
import android.content.res.Resources
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/1/21
|
||||
*/
|
||||
object DimenUtil{
|
||||
fun dp2px(value:Float):Float{
|
||||
return (0.5f + value * Resources.getSystem().displayMetrics.density)
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.utils;
|
||||
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/11/26
|
||||
*/
|
||||
public class PinYinUtil {
|
||||
/**
|
||||
* 得到中文字符串首字母
|
||||
* @param str 需要转化的中文字符串
|
||||
* @return 大写首字母缩写的字符串
|
||||
*/
|
||||
public static String getPinYinHeadChar(String str) {
|
||||
str = str.replaceAll("[\\p{P}‘’“”|+=¥$<>^~~]", "");
|
||||
StringBuilder convert = new StringBuilder();
|
||||
for (int j = 0; j < str.length(); j++) {
|
||||
char word = str.charAt(j);
|
||||
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
|
||||
if (pinyinArray != null) {
|
||||
convert.append(pinyinArray[0].charAt(0));
|
||||
} else {
|
||||
if (!"".equals(String.valueOf(word).trim())){
|
||||
convert.append(word);
|
||||
}
|
||||
}
|
||||
}
|
||||
return convert.toString().trim().toUpperCase();
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/28
|
||||
*/
|
||||
public class TPCoordinateCalculateRouteUtil {
|
||||
|
||||
public static float calculateRouteSumLength(List<LatLng> points){
|
||||
if (null == points || points.size() == 0) return 0;
|
||||
|
||||
float sumLength = 0;
|
||||
|
||||
//计算全路径总距离
|
||||
for (int i = 0;i + 1< points.size();i++){
|
||||
double preLat = points.get(i).latitude;
|
||||
double preLon = points.get(i).longitude;
|
||||
double laLat = points.get(i+1).latitude;
|
||||
double laLon = points.get(i+1).longitude;
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
return sumLength;
|
||||
}
|
||||
|
||||
public static List<LatLng> coordinateConverterWgsToGcjListCommon(Context mContext, List<MessagePad.Location> models) {
|
||||
//转成MogoLatLng集合
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MessagePad.Location m : models) {
|
||||
LatLng mogoLatLng = coordinateConverterWgsToGcj(mContext, m);
|
||||
list.add(mogoLatLng);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static LatLng coordinateConverterWgsToGcj(Context mContext, MessagePad.Location mogoLatLng) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(mogoLatLng.getLatitude(), mogoLatLng.getLongitude()));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/8/20
|
||||
*/
|
||||
public class TaxiPassengerUtils {
|
||||
|
||||
public static final String TAXI_HH_mm = "HH:mm";
|
||||
public static final String TAXI_MM_dd = "MM-dd";
|
||||
public static final String TAXI_MM_dd_HH_mm = "MM-dd HH:mm";
|
||||
public static final String TAXI_yyyy_MM_dd = "yyyy-MM-dd";
|
||||
public static final String TAXI_yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
|
||||
|
||||
public static String formatCalendarToString(Calendar calendar, String format){
|
||||
if (calendar == null) return "";
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
||||
return dateFormat.format(calendar.getTime());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static boolean compareDateIsCurrentDay(Calendar targetCalendar){
|
||||
Calendar currentCale = DateTimeUtils.getCurrentDateTime();
|
||||
String currentDay = formatCalendarToString(currentCale, TaxiPassengerUtils.TAXI_yyyy_MM_dd);
|
||||
if (currentDay.equals(formatCalendarToString(targetCalendar, TaxiPassengerUtils.TAXI_yyyy_MM_dd))){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Calendar formatLongToCalendar(long time){
|
||||
Calendar calendar = null;
|
||||
try {
|
||||
calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return calendar;
|
||||
}
|
||||
public static String formatLongToString(long time, String format){
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
||||
return dateFormat.format(time);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static String getYMDTime(long time){//格式为 2021.8.21
|
||||
try {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
int month = calendar.get(Calendar.MONTH) + 1;
|
||||
return calendar.get(Calendar.YEAR)+"."+month+"."+ calendar.get(Calendar.DAY_OF_MONTH);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param seconds 60
|
||||
* @return 1 时
|
||||
*/
|
||||
public static String secondsToHourStr(long seconds){//秒数转成相应的 小时分钟数
|
||||
if (seconds >= 3600){
|
||||
int hours = (int)seconds/3600;
|
||||
return String.valueOf(hours);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param seconds 60
|
||||
* @return 1 时
|
||||
*/
|
||||
public static String secondsToMinuteStr(long seconds){//秒数转成相应的 小时分钟数
|
||||
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(1, RoundingMode.HALF_UP);
|
||||
double num = bg.doubleValue();
|
||||
if (Math.round(num) - num == 0) {
|
||||
return String.valueOf((long) num);
|
||||
}
|
||||
return String.valueOf(num);
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,9 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.amapnavi3dmap
|
||||
|
||||
implementation project(":OCH:mogo-och-common-module")
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
|
||||
Binary file not shown.
@@ -31,6 +31,8 @@ import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
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.taxi.bean.DriverServiceDataRespBean;
|
||||
import com.mogo.och.taxi.bean.DriverStatusQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrderGrabRespBean;
|
||||
@@ -52,10 +54,8 @@ 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.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.taxi.utils.TaxiAnalyticsUtil;
|
||||
import com.mogo.och.taxi.utils.OrderUtil;
|
||||
import com.mogo.och.taxi.utils.PinYinUtil;
|
||||
import com.mogo.aicloud.services.socket.IMogoLifecycleListener;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
@@ -1067,8 +1067,7 @@ public class TaxiModel {
|
||||
*/
|
||||
public void updateOrderRoute(List<MessagePad.Location> models) {
|
||||
if (null == mCurrentOCHOrder) return;
|
||||
List<OrderRouteUpdateReqBean.Result> points =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjList(mContext,models);
|
||||
List<OrderRouteUpdateReqBean.Result> points = coordinateConverterWgsToGcjList(mContext,models);
|
||||
TaxiServiceManager.getInstance().updateOrderRoute(mContext, mCurrentOCHOrder.orderNo
|
||||
, points, new TaxiServiceCallback<BaseData>() {
|
||||
@Override
|
||||
@@ -1083,6 +1082,18 @@ public class TaxiModel {
|
||||
});
|
||||
}
|
||||
|
||||
public static List<OrderRouteUpdateReqBean.Result> coordinateConverterWgsToGcjList(Context mContext, List<MessagePad.Location> mogoLatLngList) {
|
||||
List<OrderRouteUpdateReqBean.Result> points = new ArrayList<>();
|
||||
for (MessagePad.Location m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m);
|
||||
OrderRouteUpdateReqBean.Result result = new OrderRouteUpdateReqBean.Result();
|
||||
result.latitude = mogoLatLng.latitude;
|
||||
result.longitude = mogoLatLng.longitude;
|
||||
points.add(result);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算全路径长度,以及实时更新剩余距离,剩余时间,预计时间
|
||||
* @param models
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
import com.mogo.och.taxi.callback.ITaxiNaviChangedCallback;
|
||||
import com.mogo.och.taxi.constant.TaxiConst;
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum;
|
||||
@@ -36,7 +38,6 @@ import com.mogo.och.taxi.bean.OrderQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRouteInfoRespBean;
|
||||
import com.mogo.och.taxi.model.TaxiModel;
|
||||
import com.mogo.och.taxi.model.NaviToDestinationModel;
|
||||
import com.mogo.och.taxi.utils.TaxiDateTimeUtil;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
@@ -204,8 +205,8 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
|
||||
mOrderServerStatus.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mOrderServerStatus.setClickable(true);
|
||||
Calendar currentCale = DateTimeUtils.getCurrentDateTime();
|
||||
String currentHM = TaxiDateTimeUtil.formatCalendarToString(currentCale, TaxiDateTimeUtil.TAXI_HH_mm);
|
||||
String currentDay = TaxiDateTimeUtil.formatCalendarToString(currentCale, TaxiDateTimeUtil.TAXI_yyyy_MM_dd);
|
||||
String currentHM = DateTimeUtil.formatCalendarToString(currentCale, DateTimeUtil.TAXI_HH_mm);
|
||||
String currentDay = DateTimeUtil.formatCalendarToString(currentCale, DateTimeUtil.TAXI_yyyy_MM_dd);
|
||||
String strHtml11 = "<font color=\"#CAD6FF\">已于</font><br>"
|
||||
+ "<b><font color=\"#FFFFFF\"><big><big>" + currentHM + "</big></big></font></b>"
|
||||
+ "<font color=\"#CAD6FF\">" + " " + "到达乘客上车地点</font>";
|
||||
@@ -217,13 +218,13 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
|
||||
mStationTv32.setText(order.endSiteAddr);
|
||||
currentCale.add(Calendar.MINUTE, 10);
|
||||
String strHtml13 = "";
|
||||
if (currentDay.equals(TaxiDateTimeUtil.formatCalendarToString(currentCale, TaxiDateTimeUtil.TAXI_yyyy_MM_dd))) {
|
||||
if (currentDay.equals(DateTimeUtil.formatCalendarToString(currentCale, DateTimeUtil.TAXI_yyyy_MM_dd))) {
|
||||
strHtml13 = "<font color=\"#CAD6FF\">免费等待至 </font>"
|
||||
+ "<b><font color=\"#FFFFFF\"><big>" + TaxiDateTimeUtil.formatCalendarToString(currentCale, TaxiDateTimeUtil.TAXI_HH_mm) + "</big></b></font>";
|
||||
+ "<b><font color=\"#FFFFFF\"><big>" + DateTimeUtil.formatCalendarToString(currentCale, DateTimeUtil.TAXI_HH_mm) + "</big></b></font>";
|
||||
|
||||
} else {
|
||||
strHtml13 = "<font color=\"#CAD6FF\">免费等待至</font>"
|
||||
+ "<font color=\"#FFFFFF\"><big>" + TaxiDateTimeUtil.formatCalendarToString(currentCale, TaxiDateTimeUtil.TAXI_MM_dd_HH_mm) + "</big></font>";
|
||||
+ "<font color=\"#FFFFFF\"><big>" + DateTimeUtil.formatCalendarToString(currentCale, DateTimeUtil.TAXI_MM_dd_HH_mm) + "</big></font>";
|
||||
}
|
||||
mDistanceAndTime3.setText(Html.fromHtml(strHtml13));
|
||||
} else if (TaxiModel.getInstance().checkCurrentOCHOrder()) {
|
||||
@@ -248,17 +249,17 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
|
||||
// + "<font color=\"#CAD6FF\">接乘客</font>";
|
||||
mStationTv31.setText(order.startSiteAddr);
|
||||
Calendar currentCale = DateTimeUtils.getCurrentDateTime();
|
||||
Calendar startCale = TaxiDateTimeUtil.formatLongToCalendar(order.bookingTime);
|
||||
String currentDay = TaxiDateTimeUtil.formatCalendarToString(currentCale, TaxiDateTimeUtil.TAXI_yyyy_MM_dd);
|
||||
String startDay = TaxiDateTimeUtil.formatCalendarToString(startCale, TaxiDateTimeUtil.TAXI_yyyy_MM_dd);
|
||||
Calendar startCale = DateTimeUtil.formatLongToCalendar(order.bookingTime);
|
||||
String currentDay = DateTimeUtil.formatCalendarToString(currentCale, DateTimeUtil.TAXI_yyyy_MM_dd);
|
||||
String startDay = DateTimeUtil.formatCalendarToString(startCale, DateTimeUtil.TAXI_yyyy_MM_dd);
|
||||
String strHtml1 = "";
|
||||
if (currentDay.equals(startDay)) {
|
||||
strHtml1 = "<font color=\"#CAD6FF\">乘客将于</font><br>"
|
||||
+ "<b><font color=\"#FFFFFF\"><big><big>" + TaxiDateTimeUtil.formatCalendarToString(startCale, TaxiDateTimeUtil.TAXI_HH_mm) + "</big></big></font></b>"
|
||||
+ "<b><font color=\"#FFFFFF\"><big><big>" + DateTimeUtil.formatCalendarToString(startCale, DateTimeUtil.TAXI_HH_mm) + "</big></big></font></b>"
|
||||
+ "<font color=\"#CAD6FF\"> 用车</font>";
|
||||
} else {
|
||||
strHtml1 = "<font color=\"#CAD6FF\">乘客将于</font><br>"
|
||||
+ "<b><font color=\"#FFFFFF\"><big><big>" + TaxiDateTimeUtil.formatCalendarToString(startCale, TaxiDateTimeUtil.TAXI_MM_dd_HH_mm) + "</big></big></font></b>"
|
||||
+ "<b><font color=\"#FFFFFF\"><big><big>" + DateTimeUtil.formatCalendarToString(startCale, DateTimeUtil.TAXI_MM_dd_HH_mm) + "</big></big></font></b>"
|
||||
+ "<font color=\"#CAD6FF\"> 用车</font>";
|
||||
}
|
||||
mOrderOtherContent3.setText(Html.fromHtml(strHtml1));
|
||||
@@ -300,7 +301,7 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
|
||||
dis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
dis = TaxiDateTimeUtil.formatLong((double)meters / 1000);
|
||||
dis = NumberFormatUtil.formatLong((double)meters / 1000);
|
||||
}
|
||||
}
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">里程 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> "+disUnit+"</font>"
|
||||
@@ -333,7 +334,7 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
|
||||
|
||||
if (routeInfo.distanceToEnd > 0){
|
||||
|
||||
dis = TaxiDateTimeUtil.formatLong( (double) distance/ 1000);
|
||||
dis = NumberFormatUtil.formatLong( (double) distance/ 1000);
|
||||
}
|
||||
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">距离 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> 公里</font>"
|
||||
|
||||
@@ -15,13 +15,13 @@ import androidx.fragment.app.FragmentTransaction;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRouteInfoRespBean;
|
||||
import com.mogo.och.taxi.model.TaxiModel;
|
||||
import com.mogo.och.taxi.presenter.TaxiPresenter;
|
||||
import com.mogo.och.taxi.utils.PinYinUtil;
|
||||
import com.mogo.och.taxi.utils.TPRouteDataTestUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@@ -11,9 +11,9 @@ import android.widget.TextView;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRespBean;
|
||||
import com.mogo.och.taxi.utils.TaxiDateTimeUtil;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -90,14 +90,14 @@ public class TaxiGrabOrderFragment extends BaseTaxiUIFragment implements View.On
|
||||
}
|
||||
public void updateGrabOrder(OrderQueryRespBean.Result order){
|
||||
mGrabResultAnimView.setVisibility(View.GONE);
|
||||
Calendar calendar = TaxiDateTimeUtil.formatLongToCalendar(order.bookingTime);
|
||||
if (TaxiDateTimeUtil.compareDateIsCurrentDay(calendar)){
|
||||
mOrderReserverTime.setText("用车时间:今天 "+ TaxiDateTimeUtil.formatCalendarToString(calendar, TaxiDateTimeUtil.TAXI_HH_mm));
|
||||
getOchTaxiFragment().showNotice("预约单,今天"+ TaxiDateTimeUtil.formatCalendarToString(calendar, TaxiDateTimeUtil.TAXI_HH_mm)+"从"
|
||||
Calendar calendar = DateTimeUtil.formatLongToCalendar(order.bookingTime);
|
||||
if (DateTimeUtil.compareDateIsCurrentDay(calendar)){
|
||||
mOrderReserverTime.setText("用车时间:今天 "+ DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_HH_mm));
|
||||
getOchTaxiFragment().showNotice("预约单,今天"+ DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_HH_mm)+"从"
|
||||
+order.startSiteAddr+"到"+order.endSiteAddr);
|
||||
}else {
|
||||
mOrderReserverTime.setText("用车时间:"+ TaxiDateTimeUtil.formatCalendarToString(calendar, TaxiDateTimeUtil.TAXI_MM_dd_HH_mm));
|
||||
getOchTaxiFragment().showNotice("预约单,"+ TaxiDateTimeUtil.formatCalendarToString(calendar, TaxiDateTimeUtil.TAXI_MM_dd)+"从"
|
||||
mOrderReserverTime.setText("用车时间:"+ DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_MM_dd_HH_mm));
|
||||
getOchTaxiFragment().showNotice("预约单,"+ DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_MM_dd)+"从"
|
||||
+order.startSiteAddr+"到"+order.endSiteAddr);
|
||||
}
|
||||
mOrderStartStation.setText(order.startSiteAddr);
|
||||
|
||||
@@ -13,8 +13,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.utils.TaxiDateTimeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -98,8 +98,8 @@ public class TaxiOperationDatasFragment extends BaseTaxiUIFragment {
|
||||
if (holder instanceof OperationDataViewHolder) {
|
||||
OperationDataViewHolder viewHolder = (OperationDataViewHolder) holder;
|
||||
if (0 == mType){
|
||||
String hourData = TextUtils.isEmpty(TaxiDateTimeUtil.secondsToHourStr(datas.get(position))) ? "0": TaxiDateTimeUtil.secondsToHourStr(datas.get(position));
|
||||
String minuteData = TaxiDateTimeUtil.secondsToMinuteStr(datas.get(position));
|
||||
String hourData = TextUtils.isEmpty(DateTimeUtil.secondsToHourStr(datas.get(position))) ? "0": DateTimeUtil.secondsToHourStr(datas.get(position));
|
||||
String minuteData = DateTimeUtil.secondsToMinuteStr(datas.get(position));
|
||||
String data = "<font><b><big><big><big>" + hourData + "</big></big></big></b> 时 </font>" + "<font><b><big><big><big>" + minuteData + "</big></big></big></b> 分</font>";
|
||||
viewHolder.operationDataTv.setText(Html.fromHtml(data));
|
||||
viewHolder.operationDataTitle.setText("今日在线时长");
|
||||
|
||||
@@ -31,11 +31,11 @@ import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
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.utils.TaxiDateTimeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -302,7 +302,7 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
|
||||
if (null == queryRespBean) return;
|
||||
if (holder instanceof DayGroupViewHolder){
|
||||
DayGroupViewHolder groupViewHolder = (DayGroupViewHolder)holder;
|
||||
groupViewHolder.dayGroupTv.setText(TaxiDateTimeUtil.getYMDTime(queryRespBean.createTime));
|
||||
groupViewHolder.dayGroupTv.setText(DateTimeUtil.getYMDTime(queryRespBean.createTime));
|
||||
bindOrderDetailData(queryRespBean,groupViewHolder.orderTimeTv,groupViewHolder.startStationTv,groupViewHolder.endStationTv,
|
||||
groupViewHolder.orderStatusBt,groupViewHolder.orderTypeBt,groupViewHolder.orderNumTv);
|
||||
if (isNoLineItem(position)){
|
||||
@@ -343,9 +343,9 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
|
||||
if (position == 0){
|
||||
return DAY_GROUP_ITEM;
|
||||
}
|
||||
String currentDate = TaxiDateTimeUtil.getYMDTime(orders.get(position).createTime);//获取当前订单时间
|
||||
String currentDate = DateTimeUtil.getYMDTime(orders.get(position).createTime);//获取当前订单时间
|
||||
int prevIndex = position - 1;
|
||||
String preDate = TaxiDateTimeUtil.getYMDTime(orders.get(prevIndex).createTime);
|
||||
String preDate = DateTimeUtil.getYMDTime(orders.get(prevIndex).createTime);
|
||||
boolean isDifferent = !preDate.equals(currentDate);//前一个订单的日期跟第二个订单的日期是否一致
|
||||
return isDifferent ? DAY_GROUP_ITEM : ORDER_DETAIL_ITEM;//一样订单详情, 不一样新添加分组
|
||||
}
|
||||
@@ -354,9 +354,9 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
|
||||
if (position == orders.size() -1){
|
||||
return false;
|
||||
}else {
|
||||
String currentDate = TaxiDateTimeUtil.getYMDTime(orders.get(position).createTime);//获取当前订单时间
|
||||
String currentDate = DateTimeUtil.getYMDTime(orders.get(position).createTime);//获取当前订单时间
|
||||
int nextIndex = position + 1;
|
||||
String preDate = TaxiDateTimeUtil.getYMDTime(orders.get(nextIndex).createTime);
|
||||
String preDate = DateTimeUtil.getYMDTime(orders.get(nextIndex).createTime);
|
||||
boolean isDifferent = preDate.equals(currentDate);//订单跟后一个订单是否是同一天
|
||||
return isDifferent;//一样有划分线, 不一样没有划分线
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public class TaxiPersonalDialogFragment extends DialogFragment implements View.O
|
||||
Button orderStatusBt, Button orderTypeBt, TextView orderNumTv){
|
||||
Calendar calendar= Calendar.getInstance();
|
||||
calendar.setTimeInMillis(queryRespBean.createTime);
|
||||
orderTimeTv.setText(TaxiDateTimeUtil.formatCalendarToString(calendar, TaxiDateTimeUtil.TAXI_HH_mm));
|
||||
orderTimeTv.setText(DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_HH_mm));
|
||||
startStationTv.setText(queryRespBean.startSiteAddr);
|
||||
endStationTv.setText(queryRespBean.endSiteAddr);
|
||||
orderStatusBt.setText(getOrderStatus(queryRespBean.orderStatus,orderStatusBt));
|
||||
|
||||
@@ -15,10 +15,9 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRespBean;
|
||||
import com.mogo.och.taxi.utils.TaxiDateTimeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
@@ -129,11 +128,11 @@ public class TaxiReserveOrdersFragment extends BaseTaxiUIFragment {
|
||||
if (datas != null && datas.size() >0 ){
|
||||
ToBeServedOrdersViewHolder viewHolder = (ToBeServedOrdersViewHolder)holder;
|
||||
OrderQueryRespBean.Result order = datas.get(position);
|
||||
Calendar calendar = TaxiDateTimeUtil.formatLongToCalendar(order.bookingTime);
|
||||
if (TaxiDateTimeUtil.compareDateIsCurrentDay(calendar)){
|
||||
viewHolder.orderTime.setText("用车时间:今天"+ TaxiDateTimeUtil.formatCalendarToString(calendar, TaxiDateTimeUtil.TAXI_HH_mm));
|
||||
Calendar calendar = DateTimeUtil.formatLongToCalendar(order.bookingTime);
|
||||
if (DateTimeUtil.compareDateIsCurrentDay(calendar)){
|
||||
viewHolder.orderTime.setText("用车时间:今天"+ DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_HH_mm));
|
||||
}else {
|
||||
viewHolder.orderTime.setText("用车时间:"+ TaxiDateTimeUtil.formatCalendarToString(calendar, TaxiDateTimeUtil.TAXI_MM_dd_HH_mm));
|
||||
viewHolder.orderTime.setText("用车时间:"+ DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_MM_dd_HH_mm));
|
||||
}
|
||||
viewHolder.orderCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
package com.mogo.och.taxi.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.och.taxi.bean.OrderRouteUpdateReqBean;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/28
|
||||
*/
|
||||
public class CoordinateCalculateRouteUtil {
|
||||
|
||||
public static float calculateRouteSumLength(List<LatLng> points){
|
||||
if (null == points || points.size() == 0) return 0;
|
||||
|
||||
float sumLength = 0;
|
||||
|
||||
//计算全路径总距离
|
||||
for (int i = 0;i + 1< points.size();i++){
|
||||
double preLat = points.get(i).latitude;
|
||||
double preLon = points.get(i).longitude;
|
||||
double laLat = points.get(i+1).latitude;
|
||||
double laLon = points.get(i+1).longitude;
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
return sumLength;
|
||||
}
|
||||
|
||||
public static List<LatLng> coordinateConverterWgsToGcjListCommon(Context mContext, List<MessagePad.Location> models) {
|
||||
//转成MogoLatLng集合
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MessagePad.Location m : models) {
|
||||
LatLng mogoLatLng = coordinateConverterWgsToGcj(mContext, m);
|
||||
list.add(mogoLatLng);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static LatLng coordinateConverterWgsToGcj(Context mContext, MessagePad.Location mogoLatLng) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(mogoLatLng.getLatitude(), mogoLatLng.getLongitude()));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
|
||||
public static List<OrderRouteUpdateReqBean.Result> coordinateConverterWgsToGcjList(Context mContext, List<MessagePad.Location> mogoLatLngList) {
|
||||
List<OrderRouteUpdateReqBean.Result> points = new ArrayList<>();
|
||||
for (MessagePad.Location m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m);
|
||||
OrderRouteUpdateReqBean.Result result = new OrderRouteUpdateReqBean.Result();
|
||||
result.latitude = mogoLatLng.latitude;
|
||||
result.longitude = mogoLatLng.longitude;
|
||||
points.add(result);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据实时定位的坐标确定出已行驶到那个坐标点 todo 有问题 暂不使用
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return 返回剩余路径集合
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<LatLng> getCurrentPoinByCompare(List<LatLng> mRoutePoints,double realLon,double realLat) {
|
||||
// 疑似坐标 先以坐标中间1/2为第一个比对点
|
||||
int currentIndex = Math.round(mRoutePoints.size()/2);
|
||||
LatLng currentLatLng = mRoutePoints.get(currentIndex);
|
||||
|
||||
//差值初始化
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,currentLatLng.longitude,currentLatLng.latitude);// lon,lat, prelon, prelat
|
||||
|
||||
List<LatLng> latePoints = new ArrayList<>();
|
||||
//与选中点左右比较
|
||||
if (currentIndex -1 >= 0 && currentIndex+1<= mRoutePoints.size()-1){
|
||||
LatLng leftCurrentLatLng = mRoutePoints.get(currentIndex -1);
|
||||
LatLng rightCurentLatLng = mRoutePoints.get(currentIndex + 1);
|
||||
float leftDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,leftCurrentLatLng.longitude,leftCurrentLatLng.latitude);
|
||||
float rightDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat,rightCurentLatLng.longitude,rightCurentLatLng.latitude);
|
||||
|
||||
if (rightDiffDis < leftDiffDis){ //靠近了右半边
|
||||
baseDiffDis = rightDiffDis;
|
||||
for (int i = currentIndex +1; i+1 <mRoutePoints.size() ;i++){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,mRoutePoints.get(i).longitude,mRoutePoints.get(i).latitude);
|
||||
Logger.d(M_TAXI + "Compare右半边集合", "点:"+i+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
if (baseDiffDis >= diff){
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
if (i == mRoutePoints.size()-1){
|
||||
latePoints.addAll(mRoutePoints);
|
||||
}
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
}else if (rightDiffDis > leftDiffDis){ //靠近左半边
|
||||
baseDiffDis = leftDiffDis;
|
||||
for (int j = currentIndex-1; j -1 >=0 ;j++){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat,mRoutePoints.get(j).longitude,mRoutePoints.get(j).latitude);
|
||||
Logger.d(M_TAXI + "Compare左半边集合", "点:"+j+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
if (baseDiffDis >= diff){
|
||||
baseDiffDis = diff;
|
||||
currentIndex = j;
|
||||
if (j == 0){
|
||||
latePoints.addAll(mRoutePoints);
|
||||
}
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
Logger.d(M_TAXI + "正好相等", "点:"+currentIndex+"------------baseDiffDis = "+baseDiffDis+"---diff="+leftDiffDis);
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,currentIndex));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 todo 需要优化
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return
|
||||
*/
|
||||
public static List<LatLng> getRemainPointListByCompare(List<LatLng> mRoutePoints,double realLon,double realLat) {
|
||||
List<LatLng> latePoints = new ArrayList<>();
|
||||
int currentIndex = 0; //记录疑似点
|
||||
if (mRoutePoints.size() > 0){
|
||||
//基础点
|
||||
LatLng baseLatLng = mRoutePoints.get(0);
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,baseLatLng.longitude,baseLatLng.latitude);// lon,lat, prelon, prelat
|
||||
|
||||
for (int i= 1; i < mRoutePoints.size(); i++){
|
||||
LatLng latLng = mRoutePoints.get(i);
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,latLng.longitude,latLng.latitude);
|
||||
if (baseDiffDis > diff){
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
|
||||
if (currentIndex == mRoutePoints.size()-1){
|
||||
latePoints.add(mRoutePoints.get(currentIndex));
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.mogo.och.taxi.utils;
|
||||
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/11/26
|
||||
*/
|
||||
public class PinYinUtil {
|
||||
/**
|
||||
* 得到中文字符串首字母
|
||||
* @param str 需要转化的中文字符串
|
||||
* @return 大写首字母缩写的字符串
|
||||
*/
|
||||
public static String getPinYinHeadChar(String str) {
|
||||
str = str.replaceAll("[\\p{P}‘’“”|+=¥$<>^~~]", "");
|
||||
StringBuilder convert = new StringBuilder();
|
||||
for (int j = 0; j < str.length(); j++) {
|
||||
char word = str.charAt(j);
|
||||
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
|
||||
if (pinyinArray != null) {
|
||||
convert.append(pinyinArray[0].charAt(0));
|
||||
} else {
|
||||
if (!"".equals(String.valueOf(word).trim())){
|
||||
convert.append(word);
|
||||
}
|
||||
}
|
||||
}
|
||||
return convert.toString().trim().toUpperCase();
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/8/20
|
||||
*/
|
||||
public class TaxiDateTimeUtil {
|
||||
|
||||
public static final String TAXI_HH_mm = "HH:mm";
|
||||
public static final String TAXI_MM_dd = "MM-dd";
|
||||
public static final String TAXI_MM_dd_HH_mm = "MM-dd HH:mm";
|
||||
public static final String TAXI_yyyy_MM_dd = "yyyy-MM-dd";
|
||||
public static final String TAXI_yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
|
||||
|
||||
public static String formatCalendarToString(Calendar calendar, String format){
|
||||
if (calendar == null) return "";
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
||||
return dateFormat.format(calendar.getTime());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static boolean compareDateIsCurrentDay(Calendar targetCalendar){
|
||||
Calendar currentCale = DateTimeUtils.getCurrentDateTime();
|
||||
String currentDay = formatCalendarToString(currentCale, TaxiDateTimeUtil.TAXI_yyyy_MM_dd);
|
||||
if (currentDay.equals(formatCalendarToString(targetCalendar, TaxiDateTimeUtil.TAXI_yyyy_MM_dd))){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Calendar formatLongToCalendar(long time){
|
||||
Calendar calendar = null;
|
||||
try {
|
||||
calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return calendar;
|
||||
}
|
||||
public static String formatLongToString(long time, String format){
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
||||
return dateFormat.format(time);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static String getYMDTime(long time){//格式为 2021.8.21
|
||||
try {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
int month = calendar.get(Calendar.MONTH) + 1;
|
||||
return calendar.get(Calendar.YEAR)+"."+month+"."+ calendar.get(Calendar.DAY_OF_MONTH);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param seconds 60
|
||||
* @return 1 时
|
||||
*/
|
||||
public static String secondsToHourStr(long seconds){//秒数转成相应的 小时分钟数
|
||||
if (seconds >= 3600){
|
||||
int hours = (int)seconds/3600;
|
||||
return String.valueOf(hours);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param seconds 60
|
||||
* @return 1 时
|
||||
*/
|
||||
public static String secondsToMinuteStr(long seconds){//秒数转成相应的 小时分钟数
|
||||
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(1, RoundingMode.HALF_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