[140 bus乘客屏] UI调整(小地图样式未改等UI图)
This commit is contained in:
@@ -11,7 +11,8 @@ import mogo.telematics.pad.MessagePad;
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public interface IBusPassengerAutopilotPlanningCallback {
|
||||
void routeResult(List<LatLng> models);
|
||||
void routeResult(List<LatLng> models,int haveArrivedIndex);
|
||||
void routePlanningToNextStationChanged(long meters, long timeInSecond);
|
||||
void setLineMarker(List<LatLng> models);
|
||||
void updateTotalDistance();
|
||||
}
|
||||
|
||||
@@ -41,5 +41,8 @@ class BusPassengerConst {
|
||||
|
||||
//bus平均速度
|
||||
const val BUS_AVERAGE_SPEED = 25
|
||||
|
||||
// 订单总里程
|
||||
const val BUS_SP_KEY_ORDER_SUM_DIS = "BUS_SP_KEY_ORDER_SUM_DIS"
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListen
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
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.NetworkUtils;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
@@ -38,6 +39,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.BusThreadPoolManager;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
@@ -369,6 +371,13 @@ public class BusPassengerModel {
|
||||
List<LatLng> latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjListCommon(mContext,routePoints);
|
||||
mRoutePoints.addAll(latLngModels);
|
||||
|
||||
float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mRoutePoints);
|
||||
SharedPrefsMgr.getInstance(mContext).putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,(int) sumLength);
|
||||
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.updateTotalDistance();
|
||||
}
|
||||
}
|
||||
|
||||
public void dynamicCalculateRouteInfo() {
|
||||
@@ -388,7 +397,6 @@ public class BusPassengerModel {
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void startRemainRouteInfo() {
|
||||
@@ -414,10 +422,12 @@ public class BusPassengerModel {
|
||||
|
||||
public void loopRouteAndWipe() {
|
||||
if (mRoutePoints != null && mRoutePoints.size() > 0){
|
||||
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude);
|
||||
int haveArrivedIndex = CoordinateCalculateRouteUtil
|
||||
.getArrivedPointIndex(mRoutePoints,mLongitude,mLatitude);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "thread = "+ Thread.currentThread().getName()+" haveArrivedIndex== " + haveArrivedIndex);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.routeResult(lastPoints);
|
||||
mAutopilotPlanningCallback.routeResult(mRoutePoints,haveArrivedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,7 +450,6 @@ public class BusPassengerModel {
|
||||
if (isStart) {
|
||||
BusPassengerModelLoopManager.getInstance().startCalculateRouteInfoLoop();
|
||||
} else {
|
||||
mRoutePoints.clear();
|
||||
BusPassengerModelLoopManager.getInstance().stopCalculateRouteInfLoop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,12 @@ import com.mogo.och.bus.passenger.model.BusPassengerModel;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
@@ -24,8 +28,6 @@ public class BusPassengerModelLoopManager {
|
||||
|
||||
private static final String TAG = BusPassengerModelLoopManager.class.getSimpleName();
|
||||
|
||||
private Disposable mCalculateRouteDisposable; //每隔2s计算一次剩余里程和时间
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final BusPassengerModelLoopManager INSTANCE = new BusPassengerModelLoopManager();
|
||||
}
|
||||
@@ -35,27 +37,37 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
private Disposable mHeartbeatDisposable; //心跳轮询
|
||||
private Disposable mRouteWipeDisposable; //轨迹擦除
|
||||
private CompositeDisposable mRouteWipeDisposable = new CompositeDisposable();
|
||||
private CompositeDisposable mCalculateRouteDisposable = new CompositeDisposable(); //每隔2s计算一次剩余里程和时间
|
||||
|
||||
public void startOrStopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null && !mRouteWipeDisposable.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startOrStopRouteWipe()");
|
||||
mRouteWipeDisposable = Observable.interval(LOOP_DELAY,
|
||||
LOOP_LINE_1S, TimeUnit.MILLISECONDS)
|
||||
.map((aLong -> aLong + 1))
|
||||
Disposable disposable = startLoopRouteAndWipe()
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
}
|
||||
})
|
||||
.doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
}
|
||||
})
|
||||
.delay(LOOP_LINE_1S, TimeUnit.MILLISECONDS, true) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。
|
||||
.subscribeOn(Schedulers.io())
|
||||
.repeat() // repeat保证请求成功后能够重新订阅。
|
||||
.retry() // retry保证请求失败后能重新订阅
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> BusPassengerModel.getInstance().loopRouteAndWipe());
|
||||
.subscribe(new Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer integer) throws Exception {
|
||||
}
|
||||
});
|
||||
mRouteWipeDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public void stopOrStopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopOrStopRouteWipe()");
|
||||
mRouteWipeDisposable.dispose();
|
||||
mRouteWipeDisposable = null;
|
||||
}
|
||||
if (mRouteWipeDisposable != null) mRouteWipeDisposable.dispose();
|
||||
}
|
||||
|
||||
public void startQueryDriverLineLoop() {
|
||||
@@ -80,23 +92,57 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
public void startCalculateRouteInfoLoop() {
|
||||
if (mCalculateRouteDisposable != null && !mCalculateRouteDisposable.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startCalculateRouteInfoLoop()");
|
||||
mCalculateRouteDisposable = Observable.interval(LOOP_DELAY,
|
||||
LOOP_LINE_2S, TimeUnit.MILLISECONDS)
|
||||
.map((aLong -> aLong + 1))
|
||||
Disposable disposable = startLoopCalculateRouteInfo()
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
}
|
||||
})
|
||||
.doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
}
|
||||
})
|
||||
.delay(LOOP_LINE_2S, TimeUnit.MILLISECONDS, true) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。
|
||||
.subscribeOn(Schedulers.io())
|
||||
.repeat() // repeat保证请求成功后能够重新订阅。
|
||||
.retry() // retry保证请求失败后能重新订阅
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> BusPassengerModel.getInstance().dynamicCalculateRouteInfo());
|
||||
.subscribe(new Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer integer) throws Exception {
|
||||
}
|
||||
});
|
||||
mCalculateRouteDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public void stopCalculateRouteInfLoop() {
|
||||
if (mCalculateRouteDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopCalculateRouteInfLoop()");
|
||||
mCalculateRouteDisposable.dispose();
|
||||
mCalculateRouteDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Observable<Integer> startLoopRouteAndWipe(){
|
||||
return Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
if (emitter.isDisposed()) return;
|
||||
BusPassengerModel.getInstance().loopRouteAndWipe();
|
||||
emitter.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Observable<Integer> startLoopCalculateRouteInfo(){
|
||||
return Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
if (emitter.isDisposed()) return;
|
||||
BusPassengerModel.getInstance().dynamicCalculateRouteInfo();
|
||||
emitter.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResult(List<LatLng> models) {
|
||||
runOnUIThread(() -> mView.routeResult(models));
|
||||
public void routeResult(List<LatLng> models, int haveArrivedIndex) {
|
||||
runOnUIThread(() -> mView.routeResult(models,haveArrivedIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,4 +149,9 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
public void setLineMarker(List<LatLng> models) {
|
||||
runOnUIThread(() -> mView.setLineMarker(models));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTotalDistance() {
|
||||
runOnUIThread(() -> mView.setProgressBarMax());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,17 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.widget.ContentLoadingProgressBar;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
|
||||
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.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
|
||||
/**
|
||||
@@ -29,7 +33,7 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
private TextView mCurrentArriveTip;
|
||||
private ImageView mAutopilotIv;
|
||||
private FrameLayout flContainer;
|
||||
|
||||
private ContentLoadingProgressBar mProgressBar;
|
||||
|
||||
/**
|
||||
* 改变自动驾驶状态
|
||||
@@ -59,6 +63,8 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
mCurrentArriveTip = findViewById(R.id.bus_p_cur_station_tip);
|
||||
mAutopilotIv = findViewById(R.id.bus_p_autopilot_iv);
|
||||
|
||||
mProgressBar = findViewById(R.id.bus_progress_bar);
|
||||
|
||||
showRouteFragment();
|
||||
}
|
||||
|
||||
@@ -103,6 +109,9 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
}
|
||||
|
||||
public void updateRoutePlanningToNextStation(long meters, long timeInSecond){
|
||||
//更新进度条
|
||||
updateProgressBar(meters);
|
||||
|
||||
String dis = "0";
|
||||
String disUnit = "公里";
|
||||
if (meters > 0){
|
||||
@@ -119,6 +128,19 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
mCurrentArriveTip.setText(Html.fromHtml(strHtml2));
|
||||
}
|
||||
|
||||
private void updateProgressBar(long meters) {
|
||||
int haveDriven = new Long(meters).intValue();
|
||||
int progressInt = SharedPrefsMgr.getInstance(getContext())
|
||||
.getInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,0) - haveDriven;
|
||||
mProgressBar.setProgress(progressInt);
|
||||
}
|
||||
|
||||
public void setProgressBarMax(){
|
||||
int max = SharedPrefsMgr.getInstance(getContext())
|
||||
.getInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,0);
|
||||
mProgressBar.setMax(max);
|
||||
}
|
||||
|
||||
public void onAutopilotStatusChanged(int status) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
// 3. 其他过程直接更新
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||
@@ -63,7 +64,11 @@ public class BusPassengerMapDirectionView
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
|
||||
private List<Integer> colorList = new ArrayList<>();
|
||||
// private List<Integer> colorList = new ArrayList<>();
|
||||
List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
List<Integer> texIndexList = new ArrayList<>();
|
||||
private int mHaveArrivedIndex = 0;
|
||||
|
||||
private List<Marker> mLineMarkers = new ArrayList<>();
|
||||
|
||||
private IBusPassengerMapViewCallback mIBusPassengerMapViewCallback;
|
||||
@@ -224,10 +229,13 @@ public class BusPassengerMapDirectionView
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(mCoordinatesLatLng);
|
||||
polylineOptions.colorValues(colorList);
|
||||
polylineOptions.useGradient(true);
|
||||
polylineOptions.width(10); //线段宽度
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// polylineOptions.colorValues(colorList);
|
||||
// polylineOptions.setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow));
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
@@ -240,9 +248,16 @@ public class BusPassengerMapDirectionView
|
||||
* 添加画线颜色值
|
||||
*/
|
||||
private void addRouteColorList() {
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++) {
|
||||
colorList.add(Color.argb(255, 70, 147, 253));//路线颜色
|
||||
for (int i = 0 ; i < mHaveArrivedIndex; i++){
|
||||
textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow));
|
||||
texIndexList.add(i);
|
||||
}
|
||||
|
||||
for (int i = mHaveArrivedIndex; i < mCoordinatesLatLng.size(); i++){
|
||||
textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow));
|
||||
texIndexList.add(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,6 +329,12 @@ public class BusPassengerMapDirectionView
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs,int haveArrivedIndex) {
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
mHaveArrivedIndex = haveArrivedIndex;
|
||||
}
|
||||
|
||||
public void clearLineMarkers(){
|
||||
for (int i =0; i< mLineMarkers.size();i++){
|
||||
mLineMarkers.get(i).setVisible(false);
|
||||
|
||||
@@ -17,10 +17,12 @@ import com.amap.api.maps.model.LatLng;
|
||||
import com.elegant.utils.UiThreadHandler;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
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.constant.BusPassengerConst;
|
||||
import com.mogo.och.bus.passenger.presenter.BaseBusPassengerPresenter;
|
||||
import com.mogo.och.bus.passenger.utils.BPRouteDataTestUtils;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
@@ -139,10 +141,10 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
public void routeResult(List<LatLng> latLngList) {
|
||||
public void routeResult(List<LatLng> latLngList,int haveArrivedIndex) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "routeResult:" + latLngList.size());
|
||||
if (latLngList.size() > 0) {
|
||||
drawablePolyline(latLngList);
|
||||
drawablePolyline(latLngList,haveArrivedIndex);
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
@@ -169,9 +171,9 @@ public class BusPassengerRouteFragment extends
|
||||
*
|
||||
* @param coordinates
|
||||
*/
|
||||
private void drawablePolyline(List<LatLng> coordinates) {
|
||||
private void drawablePolyline(List<LatLng> coordinates,int haveArrivedIndex) {
|
||||
if (mMapDirectionView != null) {
|
||||
mMapDirectionView.setCoordinatesLatLng(coordinates);
|
||||
mMapDirectionView.setCoordinatesLatLng(coordinates,haveArrivedIndex);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -245,6 +247,8 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
|
||||
if (currentStationIndex == 0 && isArrived){ //到达始发站且并未出发, 恢复站点marker 清楚路径 清空路径点
|
||||
SharedPrefsMgr.getInstance(getContext())
|
||||
.remove(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS);
|
||||
clearPolyline();
|
||||
if (mMapDirectionView != null) mMapDirectionView.clearCoordinatesLatLng();
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 588 B |
Binary file not shown.
|
After Width: | Height: | Size: 588 B |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:startColor="#D8E4FF"
|
||||
android:endColor="#D8E4FF"
|
||||
android:type="linear"/>
|
||||
<corners android:radius="@dimen/dp_30"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="@dimen/dp_10" />
|
||||
<solid android:color="@android:color/transparent" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<scale
|
||||
android:drawable="@drawable/progress_item_round"
|
||||
android:scaleWidth="100%" />
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:bottomLeftRadius="@dimen/dp_60"
|
||||
android:bottomRightRadius="@dimen/dp_30"
|
||||
android:topRightRadius="@dimen/dp_30"/>
|
||||
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:endColor="#009EFF"
|
||||
android:startColor="#4D006AFF"
|
||||
android:type="linear" />
|
||||
</shape>
|
||||
@@ -28,69 +28,99 @@
|
||||
|
||||
<com.mogo.och.common.module.wigets.OCHBorderShadowLayout
|
||||
android:id="@+id/iv_bg"
|
||||
android:layout_width="@dimen/bus_p_curent_station_panel_width"
|
||||
android:layout_height="@dimen/bus_p_curent_station_panel_height"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/bus_p_curent_station_panel_margin_left"
|
||||
android:layout_marginBottom="@dimen/bus_p_curent_station_panel_margin"
|
||||
app:bgColor="@android:color/transparent"
|
||||
app:blurRadius="@dimen/dp_30"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:bgColor="@color/bus_p_panel_cur_station_panel_color"
|
||||
app:blurRadius="@dimen/dp_12"
|
||||
app:shadowRadius="@dimen/dp_20"
|
||||
app:shadowColor="@color/bus_p_panel_edge_shadow"
|
||||
app:shadowRadius="@dimen/dp_30"
|
||||
app:xOffset="0px"
|
||||
app:yOffset="0px">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="@dimen/bus_p_curent_station_panel_width"
|
||||
android:layout_height="@dimen/bus_p_curent_station_panel_height"
|
||||
android:layout_margin="@dimen/dp_10"
|
||||
android:background="@drawable/bus_p_panel_cur_station_panel">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_p_cur_station_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_56"
|
||||
android:layout_marginTop="@dimen/dp_28"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:text="@string/bus_p_cur_station_title"
|
||||
android:textColor="@color/bus_p_panel_cur_txt_color"
|
||||
android:textSize="@dimen/bus_p_curent_station_txt_size"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_p_cur_station_name"
|
||||
android:layout_width="@dimen/bus_p_curent_station_txt_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="-- --"
|
||||
android:textColor="@color/bus_p_panel_cur_station_txt_color"
|
||||
android:textSize="@dimen/bus_p_curent_station_txt_size1"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_cur_station_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bus_p_cur_station_title" />
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_cur_station_name"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_cur_station_name"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bus_p_cur_station_name"
|
||||
android:layout_marginRight="8dp">
|
||||
|
||||
</androidx.appcompat.widget.AppCompatImageView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_p_cur_station_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:text="@string/bus_p_cur_station_arrived_tip"
|
||||
android:textColor="@color/bus_p_panel_cur_station_tips_color"
|
||||
android:textSize="@dimen/bus_p_curent_station_tip_size1"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_cur_station_name"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bus_p_cur_station_name" />
|
||||
|
||||
<androidx.core.widget.ContentLoadingProgressBar
|
||||
android:id="@+id/bus_progress_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/dp_10"
|
||||
android:progress="0"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
android:layout_marginLeft="@dimen/dp_12"
|
||||
android:layout_marginRight="@dimen/dp_15"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:progressDrawable="@drawable/bus_progress_bar_bg" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.mogo.och.common.module.wigets.OCHBorderShadowLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_p_cur_station_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_27"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:text="@string/bus_p_cur_station_title"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/bus_p_panel_cur_txt_color"
|
||||
android:textSize="@dimen/bus_p_curent_station_txt_size"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/iv_bg"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_p_cur_station_name"
|
||||
android:layout_width="@dimen/bus_p_curent_station_txt_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:textColor="@color/bus_p_panel_cur_station_txt_color"
|
||||
android:textSize="@dimen/bus_p_curent_station_txt_size1"
|
||||
android:textStyle="bold"
|
||||
android:text="-- --"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:elevation="@dimen/dp_10"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_cur_station_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bus_p_cur_station_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_p_cur_station_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:text="@string/bus_p_cur_station_arrived_tip"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/bus_p_panel_cur_station_tips_color"
|
||||
android:textSize="@dimen/bus_p_curent_station_tip_size1"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_cur_station_name"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bus_p_cur_station_name" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/bus_p_route_panel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -98,6 +128,6 @@
|
||||
android:layout_marginBottom="@dimen/dp_48"
|
||||
android:src="@drawable/bus_p_mogo_nor"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bus_p_route_panel"/>
|
||||
app:layout_constraintRight_toLeftOf="@+id/bus_p_route_panel" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -47,8 +47,8 @@
|
||||
<dimen name="bus_p_station_tag_line_height1">60px</dimen>
|
||||
<dimen name="bus_p_station_tag_line_width">6px</dimen>
|
||||
|
||||
<dimen name="bus_p_curent_station_panel_width">638px</dimen>
|
||||
<dimen name="bus_p_curent_station_panel_height">316px</dimen>
|
||||
<dimen name="bus_p_curent_station_panel_width">685px</dimen>
|
||||
<dimen name="bus_p_curent_station_panel_height">309px</dimen>
|
||||
<dimen name="bus_p_curent_station_panel_margin">50px</dimen>
|
||||
<dimen name="bus_p_curent_station_panel_margin_left">38px</dimen>
|
||||
<dimen name="bus_p_curent_station_txt_size">44px</dimen>
|
||||
|
||||
@@ -167,4 +167,34 @@ public class CoordinateCalculateRouteUtil {
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 todo 需要优化
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return 返回已经到达点的index
|
||||
*/
|
||||
public static int getArrivedPointIndex(List<LatLng> mRoutePoints,double realLon,double realLat) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
return currentIndex;
|
||||
}
|
||||
return currentIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.mogo.och.common.module.utils;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/7/19
|
||||
*/
|
||||
|
||||
public class OCHThreadPoolManager<T> {
|
||||
|
||||
/**
|
||||
* 根据cpu的数量动态的配置核心线程数和最大线程数
|
||||
*/
|
||||
private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
|
||||
/**
|
||||
* 核心线程数 = CPU核心数 + 1
|
||||
*/
|
||||
private static final int CORE_POOL_SIZE = CPU_COUNT + 1;
|
||||
/**
|
||||
* 线程池最大线程数 = CPU核心数 * 2 + 1
|
||||
*/
|
||||
private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1;
|
||||
/**
|
||||
* 非核心线程闲置时超时1s
|
||||
*/
|
||||
private static final int KEEP_ALIVE = 1;
|
||||
/**
|
||||
* 线程池的对象
|
||||
*/
|
||||
private ThreadPoolExecutor executor;
|
||||
|
||||
/**
|
||||
* 要确保该类只有一个实例对象,避免产生过多对象消费资源,所以采用单例模式
|
||||
*/
|
||||
private OCHThreadPoolManager() {
|
||||
}
|
||||
|
||||
private volatile static OCHThreadPoolManager INSTANCE;
|
||||
|
||||
public static OCHThreadPoolManager getsInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (OCHThreadPoolManager.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new OCHThreadPoolManager();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个无返回结果的线程
|
||||
*
|
||||
* @param r
|
||||
*/
|
||||
public void execute(Runnable r) {
|
||||
if (executor == null) {
|
||||
/**
|
||||
* corePoolSize:核心线程数
|
||||
* maximumPoolSize:线程池所容纳最大线程数(workQueue队列满了之后才开启)
|
||||
* keepAliveTime:非核心线程闲置时间超时时长
|
||||
* unit:keepAliveTime的单位
|
||||
* workQueue:等待队列,存储还未执行的任务
|
||||
* threadFactory:线程创建的工厂
|
||||
* handler:异常处理机制
|
||||
*
|
||||
*/
|
||||
executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE,
|
||||
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(200),
|
||||
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
|
||||
}
|
||||
// 把一个任务丢到了线程池中
|
||||
try {
|
||||
executor.execute(r);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个有返回结果的线程
|
||||
*
|
||||
* @param r
|
||||
* @return
|
||||
*/
|
||||
public Future<T> submit(Callable<T> r) {
|
||||
if (executor == null) {
|
||||
/**
|
||||
* corePoolSize:核心线程数
|
||||
* maximumPoolSize:线程池所容纳最大线程数(workQueue队列满了之后才开启)
|
||||
* keepAliveTime:非核心线程闲置时间超时时长
|
||||
* unit:keepAliveTime的单位
|
||||
* workQueue:等待队列,存储还未执行的任务
|
||||
* threadFactory:线程创建的工厂
|
||||
* handler:异常处理机制
|
||||
*
|
||||
*/
|
||||
executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE,
|
||||
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(20),
|
||||
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
|
||||
}
|
||||
// 把一个任务丢到了线程池中
|
||||
return executor.submit(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个无返回结果的线程
|
||||
*
|
||||
* @param r
|
||||
*/
|
||||
public Future submit(Runnable r) {
|
||||
if (executor == null) {
|
||||
/**
|
||||
* corePoolSize:核心线程数
|
||||
* maximumPoolSize:线程池所容纳最大线程数(workQueue队列满了之后才开启)
|
||||
* keepAliveTime:非核心线程闲置时间超时时长
|
||||
* unit:keepAliveTime的单位
|
||||
* workQueue:等待队列,存储还未执行的任务
|
||||
* threadFactory:线程创建的工厂
|
||||
* handler:异常处理机制
|
||||
*
|
||||
*/
|
||||
executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE,
|
||||
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(200),
|
||||
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
|
||||
}
|
||||
return executor.submit(r);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 把任务移除等待队列
|
||||
*
|
||||
* @param r
|
||||
*/
|
||||
public void cancel(Runnable r) {
|
||||
if (r != null) {
|
||||
executor.getQueue().remove(r);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user