[taxi/bus 2.5.1] taxi/bus绘制起点终点
This commit is contained in:
@@ -9,5 +9,5 @@ import java.util.List;
|
||||
* @date: 2021/10/22
|
||||
*/
|
||||
public interface RefreshBusStationsCallback {
|
||||
void refreshBusStations(List<OchBusStation> stationList, int currentStation, int nextStation);
|
||||
void refreshBusStations(List<OchBusStation> stationList, int currentStation, int nextStation,boolean isArrived);
|
||||
}
|
||||
|
||||
@@ -40,5 +40,10 @@ class OchBusConst {
|
||||
const val LOOP_PERIOD_60S = 60 * 1000L
|
||||
const val LOOP_PERIOD_1S = 1 * 1000L
|
||||
const val LOOP_DELAY = 100L
|
||||
|
||||
//起点UUID
|
||||
const val BUS_START_MAP_MAKER = "bus_start_map_maker";
|
||||
//终点UUID
|
||||
const val BUS_END_MAP_MAKER = "bus_end_map_maker";
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,24 @@
|
||||
package com.mogo.och.bus.fragment;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.bus.R;
|
||||
import com.mogo.och.bus.bean.OchBusStation;
|
||||
import com.mogo.och.bus.constant.OchBusConst;
|
||||
import com.mogo.och.bus.presenter.OchBusPresenter;
|
||||
import com.mogo.och.bus.view.SlidePanelView;
|
||||
|
||||
@@ -63,24 +69,24 @@ public class OchBusFragment extends BaseOchBusTabFragment< OchBusFragment, OchBu
|
||||
return true;
|
||||
} );
|
||||
|
||||
mCurrentStationName.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (DebugConfig.isDebug()){
|
||||
if (mDebugArrive.getVisibility() == View.VISIBLE){
|
||||
mDebugArrive.setVisibility(View.GONE);
|
||||
}else {
|
||||
mDebugArrive.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.module_och_bus_arrive_station).setOnClickListener(view ->{ //到站
|
||||
mPresenter.onAutopilotArriveAtStation(null);
|
||||
});
|
||||
}
|
||||
mCurrentStationName.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
// if (DebugConfig.isDebug()){
|
||||
if (mDebugArrive.getVisibility() == View.VISIBLE){
|
||||
mDebugArrive.setVisibility(View.GONE);
|
||||
}else {
|
||||
mDebugArrive.setVisibility(View.VISIBLE);
|
||||
}
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.module_och_bus_arrive_station).setOnClickListener(view ->{ //到站
|
||||
mPresenter.onAutopilotArriveAtStation(null);
|
||||
});
|
||||
|
||||
Logger.d( TAG, "initView: " + MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() );
|
||||
// 初始化的时候设置 UI 按钮状态
|
||||
@@ -124,7 +130,7 @@ public class OchBusFragment extends BaseOchBusTabFragment< OchBusFragment, OchBu
|
||||
* @param currentStation 当前站点
|
||||
* @param nextStation 下个站点
|
||||
*/
|
||||
public void refreshBusStations( List< OchBusStation > stationList, int currentStation, int nextStation ) {
|
||||
public void refreshBusStations( List< OchBusStation > stationList, int currentStation, int nextStation ,boolean isArrived) {
|
||||
if ( getActivity() == null ) {
|
||||
return;
|
||||
}
|
||||
@@ -135,14 +141,15 @@ public class OchBusFragment extends BaseOchBusTabFragment< OchBusFragment, OchBu
|
||||
}
|
||||
|
||||
// 渲染小巴路线数据
|
||||
renderCurrentStationStatus( stationList, currentStation, nextStation );
|
||||
renderCurrentStationStatus( stationList, currentStation, nextStation ,isArrived);
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新刷新站点信息
|
||||
*/
|
||||
private void renderCurrentStationStatus( List< OchBusStation > stationList, int currentStation, int nextStation ) {
|
||||
private void renderCurrentStationStatus( List< OchBusStation > stationList, int currentStation, int nextStation ,boolean isArrived) {
|
||||
Log.d("MapMaker= ","currentStation="+currentStation+",nextStation="+nextStation+"isArrived="+isArrived);
|
||||
String currentStationName = null;
|
||||
String nextStationName = null;
|
||||
int startStationFlagVisibility = View.INVISIBLE;
|
||||
@@ -155,19 +162,35 @@ public class OchBusFragment extends BaseOchBusTabFragment< OchBusFragment, OchBu
|
||||
// 获取当前站点的名称
|
||||
currentStationName = stationList.get( currentStation ).getName();
|
||||
|
||||
OchBusStation startStation = stationList.get(0);
|
||||
OchBusStation endStation = stationList.get(stationList.size() - 1);
|
||||
|
||||
// 是否到达起点
|
||||
if ( currentStation == 0 ) {
|
||||
startStationFlagVisibility = View.VISIBLE;
|
||||
isArriveAtStartStation = true;
|
||||
mStartStationFlag.setText( "始" );
|
||||
Log.d("MapMaker= ","起点=");
|
||||
setOrRemoveMapMaker(true, OchBusConst.BUS_START_MAP_MAKER,startStation.getLat(),startStation.getLon(),R.drawable.icon_station_start_end);
|
||||
setOrRemoveMapMaker(true, OchBusConst.BUS_END_MAP_MAKER,endStation.getLat(),endStation.getLon(),R.drawable.icon_station_start_end);
|
||||
} else if ( currentStation > 0 && currentStation < stationList.size() - 1 ) {// 是否到达站点
|
||||
Log.d("MapMaker= ","中间=");
|
||||
isArriveAtStation = true;
|
||||
setOrRemoveMapMaker(false, OchBusConst.BUS_START_MAP_MAKER,startStation.getLat(),startStation.getLon(),R.drawable.icon_station_start_end);
|
||||
setOrRemoveMapMaker(true, OchBusConst.BUS_END_MAP_MAKER,endStation.getLat(),endStation.getLon(),R.drawable.icon_station_start_end);
|
||||
} else if ( currentStation == stationList.size() - 1 ) {// 是否到达终点
|
||||
Log.d("MapMaker= ","终点=");
|
||||
isArriveEndStation = true;
|
||||
nextStationName = "--";
|
||||
mStartStationFlag.setText( "终" );
|
||||
startStationFlagVisibility = View.VISIBLE;
|
||||
endStationFlagVisibility = View.INVISIBLE;
|
||||
setOrRemoveMapMaker(false, OchBusConst.BUS_START_MAP_MAKER,startStation.getLat(),startStation.getLon(),R.drawable.icon_station_start_end);
|
||||
if (isArrived){
|
||||
setOrRemoveMapMaker(false, OchBusConst.BUS_END_MAP_MAKER,endStation.getLat(),endStation.getLon(),R.drawable.icon_station_start_end);
|
||||
}else {
|
||||
setOrRemoveMapMaker(true, OchBusConst.BUS_END_MAP_MAKER,endStation.getLat(),endStation.getLon(),R.drawable.icon_station_start_end);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取下一站点名称
|
||||
@@ -195,7 +218,6 @@ public class OchBusFragment extends BaseOchBusTabFragment< OchBusFragment, OchBu
|
||||
mEndStationFlag.setVisibility( endStationFlagVisibility );
|
||||
}
|
||||
|
||||
|
||||
public void hideOchBus() {
|
||||
// tvNotice.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -267,6 +289,29 @@ public class OchBusFragment extends BaseOchBusTabFragment< OchBusFragment, OchBu
|
||||
mRootView.setVisibility(isVRMode ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 绘制地图起点终点
|
||||
* @param isAdd
|
||||
* @param uuid
|
||||
* @param iconId
|
||||
*/
|
||||
private void setOrRemoveMapMaker(boolean isAdd, String uuid,double lat,double longi, int iconId){
|
||||
if (isAdd){
|
||||
Log.d("setMapMaker= ",uuid+"=latitude="+lat+",longitude="+longi);
|
||||
MogoMarkerOptions options = new MogoMarkerOptions();
|
||||
options.anchorColor("#000000");//不设置报错,暂时随便设置个
|
||||
options.setGps(true);//使用wgs 必须设置true
|
||||
options.scale(0.2f);
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(AbsMogoApplication.getApp().getResources(), iconId, null);
|
||||
options.icon(bitmap);
|
||||
options.latitude(lat);
|
||||
options.longitude(longi);
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).addMarker(uuid, options);
|
||||
}else {
|
||||
Log.d("RemoveMapMaker=",uuid+"=latitude="+lat+",longitude="+longi);
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).removeMarkers(uuid);
|
||||
}
|
||||
}
|
||||
public void debugAutoPilotStatus(int status){
|
||||
mPresenter.debugAutoPilotStatus(status);
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ public class OchBusOrderModel {
|
||||
if (site != null && site.size() > 0){
|
||||
backgroundCurrentStationIndex = currentStationIndex;
|
||||
if (refreshBusStationsCallback != null){
|
||||
refreshBusStationsCallback.refreshBusStations(stationList, currentStationIndex, getNextStopStation());
|
||||
refreshBusStationsCallback.refreshBusStations(stationList, currentStationIndex, getNextStopStation(),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -561,8 +561,10 @@ public class OchBusOrderModel {
|
||||
if (refreshBusStationsCallback != null){
|
||||
if (currentStation.isLeaving()){//如果服务端的当前站是leaving状态,展示当前站需要+1
|
||||
currentStationIndex ++;
|
||||
refreshBusStationsCallback.refreshBusStations(stationList, currentStationIndex, getNextStopStation(),false);
|
||||
}else{
|
||||
refreshBusStationsCallback.refreshBusStations(stationList, currentStationIndex, getNextStopStation(),true);
|
||||
}
|
||||
refreshBusStationsCallback.refreshBusStations(stationList, currentStationIndex, getNextStopStation());
|
||||
}
|
||||
if ( currentStation.isLeaving() && slidePannelHideCallback != null) {
|
||||
slidePannelHideCallback.hideSlidePanel();
|
||||
|
||||
@@ -93,9 +93,9 @@ public class OchBusPresenter extends Presenter< OchBusFragment > implements CarO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshBusStations(List<OchBusStation> stationList, int currentStation, int nextStation) {
|
||||
public void refreshBusStations(List<OchBusStation> stationList, int currentStation, int nextStation, boolean isArrived) {
|
||||
if ( mView != null ) {
|
||||
mView.refreshBusStations( stationList, currentStation, nextStation );
|
||||
mView.refreshBusStations( stationList, currentStation, nextStation ,isArrived);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/end_maker_icon.png
Executable file
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/end_maker_icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -39,5 +39,10 @@ class OCHTaxiConst {
|
||||
|
||||
// 订单信息
|
||||
const val SP_KEY_OCH_TAXI_ORDER = "SP_KEY_OCH_TAXI_ORDER"
|
||||
|
||||
//起点UUID
|
||||
const val TAXI_START_MAP_MAKER = "taxi_start_map_maker";
|
||||
//终点UUID
|
||||
const val TAXI_END_MAP_MAKER = "taxi_end_map_maker";
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,9 @@ public class MogoOCHTaxiModelNew {
|
||||
}
|
||||
|
||||
public void startOrStopOrderLoop(){
|
||||
startOrStopOrderLoop(mOCHCarStatus == 1);
|
||||
if (NetworkUtils.isConnected(mContext)) {
|
||||
startOrStopOrderLoop(mOCHCarStatus == 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.mogo.och.taxi.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Build;
|
||||
@@ -16,13 +18,17 @@ import androidx.annotation.RequiresApi;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.eagle.core.utilcode.util.DateTimeUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.taxi.callback.IOCHTaxiNaviChangedCallback;
|
||||
import com.mogo.och.taxi.constant.OCHTaxiConst;
|
||||
import com.mogo.och.taxi.constant.OrderStatusEnum;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRespBean;
|
||||
@@ -33,6 +39,7 @@ import com.mogo.och.taxi.utils.OchTaxiUtils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -150,7 +157,7 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
return;
|
||||
}
|
||||
mOrderId = order.orderId;
|
||||
onOrderStatusChanged(order.orderStatus);
|
||||
onOrderStatusChanged(order);
|
||||
if (OrderStatusEnum.ArriveAtEndStation.getCode() == order.orderStatus) {
|
||||
mTaxiFragment.queryCurOrderRouteInfo();
|
||||
mContentModule3.setVisibility(View.GONE);
|
||||
@@ -342,7 +349,8 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
}
|
||||
}
|
||||
|
||||
public void onOrderStatusChanged(int status) {
|
||||
public void onOrderStatusChanged(OrderQueryRespBean.Result order) {
|
||||
int status = order.orderStatus;
|
||||
Log.d(TAG, "status==" + status);
|
||||
mActivity.runOnUiThread(() -> {
|
||||
if (status == OrderStatusEnum.None.getCode() || status == OrderStatusEnum.Cancel.getCode() || status == OrderStatusEnum.JourneyCompleted.getCode()) {
|
||||
@@ -358,10 +366,14 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
showNotice(mActivity.getString(R.string.module_och_taxi_new_order));
|
||||
startNaviToStartStation(false, mOrderStartStationLat, mOrderStartStationLng);
|
||||
showOrHideNavi(true);
|
||||
setOrRemoveMapMaker(true, OCHTaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.drawable.icon_station_start_end);
|
||||
setOrRemoveMapMaker(true,OCHTaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.drawable.icon_station_start_end);
|
||||
break;
|
||||
case Cancel:
|
||||
showNotice(mActivity.getString(R.string.module_och_taxi_order_cancel));
|
||||
showOrHideNavi(false);
|
||||
setOrRemoveMapMaker(false, OCHTaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.drawable.icon_station_start_end);
|
||||
setOrRemoveMapMaker(false,OCHTaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.drawable.icon_station_start_end);
|
||||
break;
|
||||
case ArriveAtStartStation:
|
||||
showNotice(mActivity.getString(R.string.module_och_taxi_order_status_ph_text));
|
||||
@@ -370,10 +382,12 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
case OnTheWayToEndStation:
|
||||
// showNotice("欢迎使用蘑菇智行");
|
||||
showOrHideNavi(false);
|
||||
setOrRemoveMapMaker(false, OCHTaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint,R.drawable.icon_station_start_end);
|
||||
break;
|
||||
case ArriveAtEndStation:
|
||||
showNotice(mActivity.getString(R.string.module_och_taxi_order_complete_1));
|
||||
showOrHideNavi(false);
|
||||
setOrRemoveMapMaker(false,OCHTaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint,R.drawable.icon_station_start_end);
|
||||
break;
|
||||
case JourneyCompleted:
|
||||
showNotice("感谢您使用蘑菇智行,再见~");
|
||||
@@ -492,6 +506,31 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制地图起点终点
|
||||
* @param isAdd
|
||||
* @param uuid
|
||||
* @param station
|
||||
* @param iconId
|
||||
*/
|
||||
private void setOrRemoveMapMaker(boolean isAdd, String uuid, List<Double> station, int iconId){
|
||||
if (isAdd){
|
||||
Log.d("setMapMaker= ",uuid+"=latitude="+station.get(1)+",longitude="+station.get(0));
|
||||
MogoMarkerOptions options = new MogoMarkerOptions();
|
||||
options.anchorColor("#000000");//不设置报错,暂时随便设置个
|
||||
options.setGps(true);//使用wgs 必须设置true
|
||||
options.scale(0.2f);
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(mActivity.getResources(), iconId, null);
|
||||
options.icon(bitmap);
|
||||
options.latitude(station.get(1));
|
||||
options.longitude(station.get(0));
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).addMarker(uuid, options);
|
||||
}else {
|
||||
Log.d("RemoveMapMaker=",uuid+"=latitude="+station.get(1)+",longitude="+station.get(0));
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).removeMarkers(uuid);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* END
|
||||
*/
|
||||
|
||||
BIN
OCH/mogo-och-taxi/src/main/res/drawable-xhdpi-2560x1600/end_maker_icon.png
Executable file
BIN
OCH/mogo-och-taxi/src/main/res/drawable-xhdpi-2560x1600/end_maker_icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Reference in New Issue
Block a user