From 55b59bfba6adb626871f924cc1c59206e5a7c2a4 Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Tue, 19 Jul 2022 19:35:49 +0800 Subject: [PATCH] =?UTF-8?q?[140=20bus=E4=B9=98=E5=AE=A2=E5=B1=8F]=20UI?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=88=E5=B0=8F=E5=9C=B0=E5=9B=BE=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E6=9C=AA=E6=94=B9=E7=AD=89UI=E5=9B=BE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...BusPassengerAutopilotPlanningCallback.java | 3 +- .../passenger/constant/BusPassengerConst.kt | 3 + .../passenger/model/BusPassengerModel.java | 19 ++- .../network/BusPassengerModelLoopManager.java | 92 ++++++++--- .../presenter/BaseBusPassengerPresenter.java | 9 +- .../ui/BusPassengerBaseFragment.java | 24 ++- .../ui/BusPassengerMapDirectionView.java | 29 +++- .../ui/BusPassengerRouteFragment.java | 12 +- .../bus_p_map_arrow.png | Bin 0 -> 588 bytes .../res/drawable-xhdpi/bus_p_map_arrow.png | Bin 0 -> 588 bytes .../bus_p_panel_cur_station_panel.xml | 9 ++ .../main/res/drawable/bus_progress_bar_bg.xml | 14 ++ .../main/res/drawable/progress_item_round.xml | 14 ++ .../main/res/layout/bus_p_base_fragment.xml | 128 +++++++++------ .../src/main/res/values-sw320dp/dimens.xml | 4 +- .../utils/CoordinateCalculateRouteUtil.java | 30 ++++ .../module/utils/OCHThreadPoolManager.java | 152 ++++++++++++++++++ 17 files changed, 451 insertions(+), 91 deletions(-) create mode 100644 OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_arrow.png create mode 100644 OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_arrow.png create mode 100644 OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_panel_cur_station_panel.xml create mode 100644 OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_progress_bar_bg.xml create mode 100644 OCH/mogo-och-bus-passenger/src/main/res/drawable/progress_item_round.xml create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/OCHThreadPoolManager.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java index 04cb54dea1..8d93dacbf1 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java @@ -11,7 +11,8 @@ import mogo.telematics.pad.MessagePad; * Created on 2022/3/31 */ public interface IBusPassengerAutopilotPlanningCallback { - void routeResult(List models); + void routeResult(List models,int haveArrivedIndex); void routePlanningToNextStationChanged(long meters, long timeInSecond); void setLineMarker(List models); + void updateTotalDistance(); } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt index 7f23e2f925..38f614a10b 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt @@ -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" } } \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java index 99d75f300c..f19e9ec7d0 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java @@ -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 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 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(); } } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java index d0d419c996..488488804b 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java @@ -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() { + @Override + public void accept(Disposable disposable) throws Exception { + } + }) + .doOnError(new Consumer() { + @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() { + @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() { + @Override + public void accept(Disposable disposable) throws Exception { + } + }) + .doOnError(new Consumer() { + @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() { + @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 startLoopRouteAndWipe(){ + return Observable.create(new ObservableOnSubscribe() { + @Override + public void subscribe(ObservableEmitter emitter) throws Exception { + if (emitter.isDisposed()) return; + BusPassengerModel.getInstance().loopRouteAndWipe(); + emitter.onComplete(); + } + }); + } + + private Observable startLoopCalculateRouteInfo(){ + return Observable.create(new ObservableOnSubscribe() { + @Override + public void subscribe(ObservableEmitter emitter) throws Exception { + if (emitter.isDisposed()) return; + BusPassengerModel.getInstance().dynamicCalculateRouteInfo(); + emitter.onComplete(); + } + }); + } } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java index 51799eb526..1b47d8e38d 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java @@ -136,8 +136,8 @@ public class BaseBusPassengerPresenter extends Presenter models) { - runOnUIThread(() -> mView.routeResult(models)); + public void routeResult(List models, int haveArrivedIndex) { + runOnUIThread(() -> mView.routeResult(models,haveArrivedIndex)); } @Override @@ -149,4 +149,9 @@ public class BaseBusPassengerPresenter extends Presenter models) { runOnUIThread(() -> mView.setLineMarker(models)); } + + @Override + public void updateTotalDistance() { + runOnUIThread(() -> mView.setProgressBarMax()); + } } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java index b7fee75b5c..95fe5e8e6c 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java @@ -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 0){ @@ -119,6 +128,19 @@ public abstract class BusPassengerBaseFragment { // 3. 其他过程直接更新 diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java index 1e56a29322..d0f1077fd7 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java @@ -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 colorList = new ArrayList<>(); +// private List colorList = new ArrayList<>(); + List textureList = new ArrayList<>(); + List texIndexList = new ArrayList<>(); + private int mHaveArrivedIndex = 0; + private List 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 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); diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java index e1b865de85..74357b47fd 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java @@ -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 latLngList) { + public void routeResult(List 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 coordinates) { + private void drawablePolyline(List 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(); } diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_arrow.png b/OCH/mogo-och-bus-passenger/src/main/res/drawable-sw320dp-xhdpi/bus_p_map_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..baa35592cb83ba3e19e26a33731e585765b02166 GIT binary patch literal 588 zcmeAS@N?(olHy`uVBq!ia0vp^3PAjfgAGV-Io%!$q!^2X+?^QKos)S9@YLn{4xqAao-U3d z6^w7M7<$V%iZDD7KY6vub7~lO^hVBaW*_GtxnB_auW`YD7wPPyYB!b{(W<~ z*L@PQaZa;89+a}?*aMbLuRh=HXnq%$Z8<%==poQ%Fhzd-cmCV@YLn{4xqAao-U3d z6^w7M7<$V%iZDD7KY6vub7~lO^hVBaW*_GtxnB_auW`YD7wPPyYB!b{(W<~ z*L@PQaZa;89+a}?*aMbLuRh=HXnq%$Z8<%==poQ%Fhzd-cmCV + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_progress_bar_bg.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_progress_bar_bg.xml new file mode 100644 index 0000000000..aa1eeaecd0 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_progress_bar_bg.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/progress_item_round.xml b/OCH/mogo-och-bus-passenger/src/main/res/drawable/progress_item_round.xml new file mode 100644 index 0000000000..2d74f8fd54 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/main/res/drawable/progress_item_round.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml index 7a3b8aff27..d16730cb71 100644 --- a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml @@ -28,69 +28,99 @@ + + + + + + + + + + + + + + - - - - - - + app:layout_constraintTop_toTopOf="parent" /> + + app:layout_constraintRight_toLeftOf="@+id/bus_p_route_panel" /> \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/res/values-sw320dp/dimens.xml b/OCH/mogo-och-bus-passenger/src/main/res/values-sw320dp/dimens.xml index e1eebd7bcb..a3ceb619eb 100644 --- a/OCH/mogo-och-bus-passenger/src/main/res/values-sw320dp/dimens.xml +++ b/OCH/mogo-och-bus-passenger/src/main/res/values-sw320dp/dimens.xml @@ -47,8 +47,8 @@ 60px 6px - 638px - 316px + 685px + 309px 50px 38px 44px diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/CoordinateCalculateRouteUtil.java b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/CoordinateCalculateRouteUtil.java index fdaa18be0b..01ec888715 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/CoordinateCalculateRouteUtil.java +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/CoordinateCalculateRouteUtil.java @@ -167,4 +167,34 @@ public class CoordinateCalculateRouteUtil { } return latePoints; } + + /** + * 简单粗暴 直接比较 todo 需要优化 + * @param mRoutePoints + * @param realLon + * @param realLat + * @return 返回已经到达点的index + */ + public static int getArrivedPointIndex(List 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; + } } diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/OCHThreadPoolManager.java b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/OCHThreadPoolManager.java new file mode 100644 index 0000000000..02a08f49b2 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/OCHThreadPoolManager.java @@ -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 { + + /** + * 根据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(200), + Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy()); + } + // 把一个任务丢到了线程池中 + try { + executor.execute(r); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * 开启一个有返回结果的线程 + * + * @param r + * @return + */ + public Future submit(Callable 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(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(200), + Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy()); + } + return executor.submit(r); + + } + + /** + * 把任务移除等待队列 + * + * @param r + */ + public void cancel(Runnable r) { + if (r != null) { + executor.getQueue().remove(r); + } + } + +} + +