同步212 版本
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.bus.passenger.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -8,13 +9,18 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
|
||||
import com.mogo.och.common.module.utils.BlinkAnimationUtil;
|
||||
import com.mogo.och.common.module.wigets.MarqueeTextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_ARRIVING;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_LEAVING;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED;
|
||||
|
||||
/**
|
||||
@@ -25,10 +31,6 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
|
||||
|
||||
private Context mContext;
|
||||
private List<BusPassengerStation> mStations;
|
||||
private static final int LINE_START_STATION_ITEM = 0;
|
||||
private static final int LINE_END_STATION_ITEM = 1;
|
||||
private static final int LINE_MIDDLE_STATION_ITEM = 2;
|
||||
// private String preArrivingStation = "";
|
||||
|
||||
public BusPassengerLineStationsAdapter(Context context, List<BusPassengerStation> stations){
|
||||
this.mContext = context;
|
||||
@@ -38,78 +40,67 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == LINE_START_STATION_ITEM){
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.bus_p_stations_start_item,parent,false);
|
||||
StartStationViewHolder viewHolder = new StartStationViewHolder(view);
|
||||
return viewHolder;
|
||||
}else if (viewType == LINE_END_STATION_ITEM) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.bus_p_stations_end_item,parent,false);
|
||||
EndStationViewHolder viewHolder = new EndStationViewHolder(view);
|
||||
return viewHolder;
|
||||
}else {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.bus_p_stations_middle_item,parent,false);
|
||||
MiddleStationViewHolder viewHolder = new MiddleStationViewHolder(view);
|
||||
return viewHolder;
|
||||
}
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.bus_p_stations_common_item,parent,false);
|
||||
StationViewHolder viewHolder = new StationViewHolder(view);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
BusPassengerStation station = mStations.get(position);
|
||||
if (holder instanceof StartStationViewHolder){
|
||||
StartStationViewHolder viewHolder = (StartStationViewHolder)holder;
|
||||
// if (!preArrivingStation.equals(station.getName())){
|
||||
viewHolder.startStationName.setText(station.getName());
|
||||
// }
|
||||
if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){//到站
|
||||
viewHolder.curStationBg.setVisibility(View.VISIBLE);
|
||||
viewHolder.stationCircle.setVisibility(View.GONE);
|
||||
viewHolder.startStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
|
||||
viewHolder.startStationName.setSelected(true);
|
||||
// preArrivingStation = station.getName();
|
||||
StationViewHolder viewHolder = (StationViewHolder)holder;
|
||||
viewHolder.stationName.setText(station.getName());
|
||||
BlinkAnimationUtil.clearAnimation(viewHolder.stationCircle);
|
||||
if (position == 0){ //第一个 起点
|
||||
viewHolder.stationTagTxt.setText("起");
|
||||
viewHolder.stationStationTag.setBackground(mContext.getDrawable(R.drawable.bg_bus_p_start_tag_bg));
|
||||
viewHolder.groupStationTagPanel.setVisibility(View.VISIBLE);
|
||||
viewHolder.curArrowBg.setVisibility(View.GONE);
|
||||
if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){//到达未离开
|
||||
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
|
||||
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_green);
|
||||
BlinkAnimationUtil.setAnimation(viewHolder.stationCircle);
|
||||
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||
}else {
|
||||
viewHolder.curStationBg.setVisibility(View.GONE);
|
||||
viewHolder.stationCircle.setVisibility(View.VISIBLE);
|
||||
viewHolder.startStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
|
||||
viewHolder.startStationName.setSelected(false);
|
||||
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
|
||||
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_gray);
|
||||
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.END);
|
||||
}
|
||||
}else if (holder instanceof EndStationViewHolder){
|
||||
EndStationViewHolder viewHolder = (EndStationViewHolder)holder;
|
||||
// if (!preArrivingStation.equals(station.getName())){
|
||||
viewHolder.endStationName.setText(station.getName());
|
||||
// }
|
||||
BusPassengerStation preStation = mStations.get(position -1);
|
||||
if ((preStation.getDrivingStatus() == STATION_STATUS_STOPPED && preStation.isLeaving())
|
||||
|| (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving())){//到站
|
||||
viewHolder.curStationBg.setVisibility(View.VISIBLE);
|
||||
viewHolder.stationCircle.setVisibility(View.GONE);
|
||||
viewHolder.endStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
|
||||
viewHolder.endStationName.setSelected(true);
|
||||
// preArrivingStation = station.getName();
|
||||
}else{
|
||||
if (position == mStations.size() - 1){
|
||||
viewHolder.stationTagTxt.setText("终");
|
||||
viewHolder.stationStationTag.setBackground(mContext.getDrawable(R.drawable.bg_bus_p_end_tag_bg));
|
||||
viewHolder.groupStationTagPanel.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
viewHolder.curStationBg.setVisibility(View.GONE);
|
||||
viewHolder.stationCircle.setVisibility(View.VISIBLE);
|
||||
viewHolder.endStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
|
||||
viewHolder.endStationName.setSelected(false);
|
||||
viewHolder.groupStationTagPanel.setVisibility(View.GONE);
|
||||
}
|
||||
}else {
|
||||
MiddleStationViewHolder viewHolder = (MiddleStationViewHolder)holder;
|
||||
// if (!preArrivingStation.equals(station.getName())){
|
||||
viewHolder.middleStationName.setText(station.getName());
|
||||
// }
|
||||
viewHolder.curArrowBg.setVisibility(View.VISIBLE);
|
||||
BusPassengerStation preStation = mStations.get(position -1);
|
||||
if ((preStation.getDrivingStatus() == STATION_STATUS_STOPPED && preStation.isLeaving())
|
||||
|| (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving())) {//到站
|
||||
viewHolder.curStationBg.setVisibility(View.VISIBLE);
|
||||
viewHolder.middleStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
|
||||
viewHolder.stationCircle.setVisibility(View.GONE);
|
||||
viewHolder.middleStationName.setSelected(true);
|
||||
// preArrivingStation = station.getName();
|
||||
}else {
|
||||
viewHolder.curStationBg.setVisibility(View.GONE);
|
||||
viewHolder.middleStationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
|
||||
viewHolder.stationCircle.setVisibility(View.VISIBLE);
|
||||
viewHolder.middleStationName.setSelected(false);
|
||||
if (station.getDrivingStatus() == STATION_STATUS_LEAVING ||
|
||||
(station.getDrivingStatus() == STATION_STATUS_STOPPED && station.isLeaving())){ //过站
|
||||
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
|
||||
viewHolder.curArrowBg.setImageResource(R.drawable.bus_p_line_grey);
|
||||
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_gray);
|
||||
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.END);
|
||||
} else if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){//刚到站未离开的
|
||||
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
|
||||
viewHolder.curArrowBg.setImageResource(R.drawable.bus_p_line_grey);
|
||||
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_green);
|
||||
BlinkAnimationUtil.setAnimation(viewHolder.stationCircle);
|
||||
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||
}else if (station.getDrivingStatus() == STATION_STATUS_ARRIVING && preStation.isLeaving()){//即将到站
|
||||
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_current_station_txt_color));
|
||||
viewHolder.curArrowBg.setImageResource(R.drawable.bus_p_line_green);
|
||||
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_green);
|
||||
BlinkAnimationUtil.setAnimation(viewHolder.stationCircle);
|
||||
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||
}else if (station.getDrivingStatus() == STATION_STATUS_ARRIVING &&
|
||||
(preStation.getDrivingStatus() == STATION_STATUS_ARRIVING
|
||||
|| preStation.getDrivingStatus() == STATION_STATUS_STOPPED)){ //未到站的并且前面也是未到站或者刚到站的
|
||||
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_station_txt_color));
|
||||
viewHolder.curArrowBg.setImageResource(R.drawable.bus_p_line_blue);
|
||||
viewHolder.stationCircle.setImageResource(R.drawable.bus_p_point_blue);
|
||||
viewHolder.stationName.setEllipsize(TextUtils.TruncateAt.END);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,55 +109,23 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
|
||||
public int getItemCount() {
|
||||
return mStations.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
//第一个要显示时间
|
||||
if (position == 0){
|
||||
return LINE_START_STATION_ITEM;
|
||||
}else if (position == mStations.size() -1){
|
||||
return LINE_END_STATION_ITEM;
|
||||
}else {
|
||||
return LINE_MIDDLE_STATION_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class StartStationViewHolder extends RecyclerView.ViewHolder{
|
||||
public TextView startStationName;
|
||||
class StationViewHolder extends RecyclerView.ViewHolder{
|
||||
public MarqueeTextView stationName;
|
||||
public ImageView stationCircle;
|
||||
public ImageView curStationBg;
|
||||
public StartStationViewHolder(@NonNull View itemView) {
|
||||
public ImageView curArrowBg;
|
||||
public ImageView stationStationTag;
|
||||
public TextView stationTagTxt;
|
||||
public Group groupStationTagPanel;
|
||||
public StationViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
startStationName = itemView.findViewById(R.id.bus_p_start_station);
|
||||
stationCircle = itemView.findViewById(R.id.bus_p_start_circle);
|
||||
curStationBg = itemView.findViewById(R.id.bus_p_cur_start_station_tag);
|
||||
stationName = itemView.findViewById(R.id.bus_p_station);
|
||||
stationCircle = itemView.findViewById(R.id.bus_p_circle);
|
||||
curArrowBg = itemView.findViewById(R.id.bus_p_cur_arrow_bg);
|
||||
stationStationTag = itemView.findViewById(R.id.bus_p_tag);
|
||||
stationTagTxt = itemView.findViewById(R.id.bus_p_tag_txt);
|
||||
groupStationTagPanel = itemView.findViewById(R.id.group_station_tag_panel);
|
||||
}
|
||||
}
|
||||
|
||||
class EndStationViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
public TextView endStationName;
|
||||
public ImageView stationCircle;
|
||||
public ImageView curStationBg;
|
||||
public EndStationViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
endStationName = itemView.findViewById(R.id.bus_p_end_station);
|
||||
stationCircle = itemView.findViewById(R.id.bus_p_end_circle);
|
||||
curStationBg = itemView.findViewById(R.id.bus_p_cur_end_station_tag);
|
||||
}
|
||||
}
|
||||
|
||||
class MiddleStationViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
public TextView middleStationName;
|
||||
public ImageView curStationBg;
|
||||
public ImageView stationCircle;
|
||||
public MiddleStationViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
middleStationName = itemView.findViewById(R.id.bus_p_middle_station);
|
||||
curStationBg = itemView.findViewById(R.id.bus_p_middle_tag);
|
||||
stationCircle = itemView.findViewById(R.id.bus_p_middle_circle);
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,8 @@ public class BusPassengerOperationStatusResponse extends BaseData {
|
||||
|
||||
public static class Result {
|
||||
private String sn; //司机屏sn
|
||||
private String phone; //司机手机号
|
||||
public String plateNumber; //车牌号
|
||||
public int serviceStatus;//0:已收车,1:已出车
|
||||
public int businessType;// 车辆类型: taxi/bus
|
||||
public int driverStatus;//0:已收车,1:已出车
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,5 @@ public class BusPassengerRoutesResponse extends BaseData {
|
||||
"data=" + data +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.bus.passenger.bean;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 网约车小巴路线接口返回接口数据封装
|
||||
@@ -15,6 +16,7 @@ public class BusPassengerRoutesResult {
|
||||
private String description;
|
||||
private int status;
|
||||
private String runningDur; //运营时间
|
||||
private long taskTime; //线路时间班次
|
||||
|
||||
public List<BusPassengerStation> getSites() {
|
||||
return sites;
|
||||
@@ -56,4 +58,22 @@ public class BusPassengerRoutesResult {
|
||||
", runningDur='" + runningDur + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
BusPassengerRoutesResult that = (BusPassengerRoutesResult) o;
|
||||
return lineId == that.lineId
|
||||
&& lineType == that.lineType
|
||||
&& status == that.status
|
||||
&& sites.equals(that.sites)
|
||||
&& name.equals(that.name)
|
||||
&& runningDur.equals(that.runningDur);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(sites, lineId, name, lineType, description, status, runningDur);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.och.bus.passenger.bean;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 单个网约车小巴车站信息
|
||||
*
|
||||
@@ -143,4 +145,29 @@ public class BusPassengerStation {
|
||||
", leaving=" + leaving +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
BusPassengerStation that = (BusPassengerStation) o;
|
||||
return Double.compare(that.lon, lon) == 0
|
||||
&& Double.compare(that.lat, lat) == 0
|
||||
&& Double.compare(that.gcjLon, gcjLon) == 0
|
||||
&& Double.compare(that.gcjLat, gcjLat) == 0
|
||||
&& businessType == that.businessType
|
||||
&& status == that.status
|
||||
&& siteId == that.siteId
|
||||
&& seq == that.seq
|
||||
&& drivingStatus == that.drivingStatus
|
||||
&& ifStop == that.ifStop
|
||||
&& leaving == that.leaving
|
||||
&& Objects.equals(name, that.name)
|
||||
&& Objects.equals(cityCode, that.cityCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, description, cityCode, lon, lat, gcjLon, gcjLat, businessType, status, siteId, seq, drivingStatus, ifStop, leaving);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,6 @@ import java.util.List;
|
||||
public interface IBusPassengerRouteLineInfoCallback {
|
||||
void updateLineInfo(String lineName, String lineDurTime);
|
||||
void updateStationsInfo(List<BusPassengerStation> stations,int currentStationIndex,boolean isArrived);
|
||||
void showNoTaskView();
|
||||
void hideNoTaskView();
|
||||
}
|
||||
|
||||
@@ -44,5 +44,7 @@ class BusPassengerConst {
|
||||
|
||||
// 订单总里程
|
||||
const val BUS_SP_KEY_ORDER_SUM_DIS = "BUS_SP_KEY_ORDER_SUM_DIS"
|
||||
|
||||
const val QUERY_BUS_P_STATION_DELAY = 3 * 1000L
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -37,8 +39,8 @@ import com.mogo.och.bus.passenger.callback.IBusPassengerControllerStatusCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerRouteLineInfoCallback;
|
||||
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.common.module.biz.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
@@ -56,6 +58,7 @@ import mogo_msg.MogoReportMsg;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.QUERY_BUS_P_STATION_DELAY;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED;
|
||||
|
||||
/**
|
||||
@@ -84,10 +87,24 @@ public class BusPassengerModel {
|
||||
|
||||
private double mLongitude, mLatitude;
|
||||
|
||||
private BusPassengerRoutesResult routesResult = null;
|
||||
|
||||
List<BusPassengerStation> mStations = new ArrayList<>();
|
||||
private int mNextStationIndex = 0;// 要到达站的index
|
||||
private List<LatLng> mTwoStationsRouts = new ArrayList<>();
|
||||
|
||||
private static final int MSG_QUERY_BUS_P_STATION = 1001;
|
||||
private final Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if ( msg.what == MSG_QUERY_BUS_P_STATION ) {
|
||||
queryDriverOperationStatus();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
private BusPassengerModel() {
|
||||
}
|
||||
|
||||
@@ -96,6 +113,7 @@ public class BusPassengerModel {
|
||||
initListeners();
|
||||
// TODO: 2022/3/31
|
||||
queryDriverOperationStatus();
|
||||
startOrStopOrderLoop(true);
|
||||
}
|
||||
|
||||
public void setDriverStatusCallback(IBusPassegerDriverStatusCallback callback){
|
||||
@@ -106,42 +124,60 @@ public class BusPassengerModel {
|
||||
this.mRouteLineInfoCallback = callback;
|
||||
}
|
||||
|
||||
private void queryDriverOperationDelay() {
|
||||
handler.sendEmptyMessageDelayed( MSG_QUERY_BUS_P_STATION, QUERY_BUS_P_STATION_DELAY );
|
||||
}
|
||||
|
||||
private void queryDriverOperationStatus() {
|
||||
BusPassengerServiceManager.getInstance().queryDriverOperationStatus(mContext
|
||||
, new BusPassengerServiceCallback<BusPassengerOperationStatusResponse>() {
|
||||
BusPassengerServiceManager.queryDriverOperationStatus(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerOperationStatusResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusPassengerOperationStatusResponse data) {
|
||||
if (data == null || data.data == null) return;
|
||||
startOrStopOrderLoop(data.data.serviceStatus == 1);
|
||||
if(mDriverStatusCallback != null){
|
||||
mDriverStatusCallback.changeOperationStatus(data.data.serviceStatus == 1);
|
||||
mDriverStatusCallback.changeOperationStatus(data.data.driverStatus == 1);
|
||||
mDriverStatusCallback.updatePlateNumber(data.data.plateNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
queryDriverOperationStatus();
|
||||
//延迟3s再次查询
|
||||
queryDriverOperationDelay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void queryDriverSiteByCoordinate(){
|
||||
BusPassengerServiceManager.getInstance().queryDriverSiteByCoordinate(mContext
|
||||
, new BusPassengerServiceCallback<BusPassengerRoutesResponse>() {
|
||||
BusPassengerServiceManager.queryDriverSiteByCoordinate(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusPassengerRoutesResponse data) {
|
||||
if ( data == null
|
||||
|| data.getResult() == null
|
||||
|| data.getResult().getSites() == null) {
|
||||
routesResult = null;
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
if (mRouteLineInfoCallback != null){
|
||||
mRouteLineInfoCallback.showNoTaskView();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (routesResult != null && routesResult.equals(data.getResult())){
|
||||
return;
|
||||
}
|
||||
routesResult = data.getResult();
|
||||
updatePassengerRouteInfo(data.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
|
||||
//code = 1003; message = bus车辆已收车或未出车;bus driver shadow,not exists
|
||||
if (code == 1003){
|
||||
routesResult = null;
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
queryDriverOperationDelay();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -149,6 +185,7 @@ public class BusPassengerModel {
|
||||
private void updatePassengerRouteInfo(BusPassengerRoutesResult result) {
|
||||
if (mRouteLineInfoCallback != null){
|
||||
mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur());
|
||||
mRouteLineInfoCallback.hideNoTaskView();
|
||||
if (result.getSites() != null){
|
||||
List<BusPassengerStation> stations = result.getSites();
|
||||
mStations.clear();
|
||||
@@ -409,7 +446,9 @@ public class BusPassengerModel {
|
||||
//要前往的站在轨迹中对应的点
|
||||
int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndex(mRoutePoints
|
||||
,stationNext.getGcjLon(),stationNext.getGcjLat());
|
||||
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex));
|
||||
if (currentRouteIndex < nextRouteIndex){ //如果找到的next在起点的轨迹前面,直接舍弃这个轨迹,不显示
|
||||
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex));
|
||||
}
|
||||
}
|
||||
}else { //只有两个站点的时候整个路线就是两个站点之间的轨迹
|
||||
mTwoStationsRouts.clear();
|
||||
|
||||
@@ -36,7 +36,7 @@ public class BusPassengerModelLoopManager {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Disposable mHeartbeatDisposable; //心跳轮询
|
||||
private Disposable mQueryLineDisposable; //心跳轮询
|
||||
private CompositeDisposable mRouteWipeDisposable;
|
||||
private CompositeDisposable mCalculateRouteDisposable; //每隔2s计算一次剩余里程和时间
|
||||
|
||||
@@ -78,11 +78,11 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
public void startQueryDriverLineLoop() {
|
||||
if (mHeartbeatDisposable != null && !mHeartbeatDisposable.isDisposed()) {
|
||||
if (mQueryLineDisposable != null && !mQueryLineDisposable.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startQueryDriverLineLoop()");
|
||||
mHeartbeatDisposable = Observable.interval(LOOP_DELAY,
|
||||
mQueryLineDisposable = Observable.interval(LOOP_DELAY,
|
||||
LOOP_LINE_2S, TimeUnit.MILLISECONDS)
|
||||
.map((aLong -> aLong + 1))
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -91,10 +91,10 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
public void stopQueryDriverLineLoop() {
|
||||
if (mHeartbeatDisposable != null) {
|
||||
if (mQueryLineDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopQueryDriverLineLoop()");
|
||||
mHeartbeatDisposable.dispose();
|
||||
mHeartbeatDisposable = null;
|
||||
mQueryLineDisposable.dispose();
|
||||
mQueryLineDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,14 @@ interface BusPassengerServiceApi {
|
||||
Observable<BusPassengerRoutesResponse> queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusPassengerQueryLineRequest request);
|
||||
|
||||
/**
|
||||
* 查询司机端出车/收车状态
|
||||
* 查询司机端的登陆状态
|
||||
* @param sn
|
||||
* @return
|
||||
*/
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
@GET("/autopilot-car-hailing/car/v2/driver/bus/passenger/takeOrderStatus/query")
|
||||
// @GET("/autopilot-car-hailing/car/v2/driver/bus/passenger/takeOrderStatus/query")
|
||||
@GET("/autopilot-car-hailing/operation/v1/driver/bus/passenger/loginStatus")
|
||||
Observable<BusPassengerOperationStatusResponse> queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.network;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public interface BusPassengerServiceCallback<T> {
|
||||
|
||||
void onSuccess(T data);
|
||||
|
||||
void onFail(int code, String msg);
|
||||
|
||||
default void onError() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.network;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public class BusPassengerServiceManager {
|
||||
private static final String TAG = BusPassengerServiceManager.class.getSimpleName();
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final BusPassengerServiceManager INSTANCE = new BusPassengerServiceManager();
|
||||
}
|
||||
|
||||
public static BusPassengerServiceManager getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private BusPassengerServiceApi mBusPassengerServiceApi;
|
||||
|
||||
private BusPassengerServiceManager() {
|
||||
if (mBusPassengerServiceApi == null){
|
||||
mBusPassengerServiceApi = MoGoRetrofitFactory.getInstance(
|
||||
BusPassengerConst.getBaseUrl()).create(BusPassengerServiceApi.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Bus司机端的sn
|
||||
* @return
|
||||
*/
|
||||
private String getDriverAppSn(){
|
||||
return CallerTelematicManager.INSTANCE.getServerToken();
|
||||
// return "X2020211111NG0XNFK";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询绑定行驶的小巴车路线
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryDriverSiteByCoordinate(Context context
|
||||
,BusPassengerServiceCallback<BusPassengerRoutesResponse> callback){
|
||||
mBusPassengerServiceApi.queryDriverSiteByCoordinate(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusPassengerQueryLineRequest(getDriverAppSn()))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryDriverSiteByCoordinate"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询司机端出车收车状态,以及车牌号
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryDriverOperationStatus(Context context, BusPassengerServiceCallback<BusPassengerOperationStatusResponse> callback){
|
||||
mBusPassengerServiceApi.queryDriverOperationStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,getDriverAppSn())
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryDriverOperationStatus"));
|
||||
}
|
||||
|
||||
|
||||
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
|
||||
Context context, BusPassengerServiceCallback<T> callback, String apiName) {
|
||||
return new SubscribeImpl<T>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(T o) {
|
||||
super.onSuccess(o);
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG,apiName +
|
||||
": onSuccess() " + o.msg);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG,apiName +
|
||||
": onError() " + e.getMessage());
|
||||
if (callback != null) {
|
||||
callback.onError();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG,String.format(apiName +
|
||||
": onError() code = %d; message = %s;", code, message));
|
||||
if (callback != null) {
|
||||
callback.onFail(code, message);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.mogo.och.bus.passenger.network
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst.Companion.getBaseUrl
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl
|
||||
import com.mogo.och.common.module.biz.network.interceptor.transformTry
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
object BusPassengerServiceManager {
|
||||
|
||||
private var mBusPassengerServiceApi = MoGoRetrofitFactory.getInstance(getBaseUrl())
|
||||
.create(BusPassengerServiceApi::class.java)
|
||||
|
||||
/**
|
||||
* 获取Bus司机端的sn
|
||||
* @return
|
||||
*/
|
||||
private val driverAppSn: String
|
||||
get() = getServerToken()
|
||||
/**
|
||||
* 查询绑定行驶的小巴车路线
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryDriverSiteByCoordinate(
|
||||
context: Context, callback: OchCommonServiceCallback<BusPassengerRoutesResponse>?
|
||||
) {
|
||||
mBusPassengerServiceApi.queryDriverSiteByCoordinate(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusPassengerQueryLineRequest(driverAppSn))
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询司机端出车收车状态,以及车牌号
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryDriverOperationStatus(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<BusPassengerOperationStatusResponse>?) {
|
||||
mBusPassengerServiceApi.queryDriverOperationStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
driverAppSn)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus"))
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,16 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
runOnUIThread(() -> mView.updateStationsInfo(stations,currentStationIndex, isArrived));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showNoTaskView() {
|
||||
runOnUIThread(() -> mView.showNoTaskView());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideNoTaskView() {
|
||||
runOnUIThread(() -> mView.hideNoTaskView());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResult(List<LatLng> models, int haveArrivedIndex) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "routeResult:" + models.size()
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
import com.mogo.och.common.module.wigets.OCHBorderShadowLayout;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
@@ -102,6 +103,9 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
public void updateArrivedStation(String station,int currentIndex,boolean isArrived){
|
||||
if (null == station){
|
||||
mCurrentArriveStation.setText("----");
|
||||
mCurrentArriveStationTitle.setText(getResources().getString(R.string.bus_p_cur_station_title_init));
|
||||
mCurrentArriveTip.setText(getResources().getString(R.string.bus_p_cur_station_arrived_tip));
|
||||
removeProgressBar();
|
||||
}else {
|
||||
mCurrentArriveStation.setText(station);
|
||||
if (currentIndex == 0){
|
||||
|
||||
@@ -57,8 +57,8 @@ public class BusPassengerMapDirectionView
|
||||
private int mCurrentIndex = -1;
|
||||
|
||||
private int zoomLevel = 13;
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private List<LatLng> mLinePointsLatLng = new ArrayList<>();
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>(); //站点坐标数据
|
||||
private List<LatLng> mLinePointsLatLng = new ArrayList<>(); //轨迹坐标数据
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
@@ -106,14 +106,14 @@ public class BusPassengerMapDirectionView
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// 注册定位监听
|
||||
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG);
|
||||
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
@@ -182,7 +182,7 @@ public class BusPassengerMapDirectionView
|
||||
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(@Nullable MogoLocation location, int from) {
|
||||
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class BusPassengerMapDirectionView
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
|
||||
if (mLinePointsLatLng.size() > 1){
|
||||
if (mLinePointsLatLng.size() > 0){
|
||||
//圈定地图显示范围
|
||||
//存放经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
@@ -208,12 +208,13 @@ public class BusPassengerMapDirectionView
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100));
|
||||
|
||||
}else {
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
// else {
|
||||
// //设置希望展示的地图缩放级别
|
||||
// CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
// .target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
|
||||
// mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -226,8 +227,8 @@ public class BusPassengerMapDirectionView
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
|
||||
if (mCoordinatesLatLng.size() > 2) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mLinePointsLatLng.size() = " +mLinePointsLatLng.size());
|
||||
if (mLinePointsLatLng.size() >= 2 && mCoordinatesLatLng.size() > 2) {
|
||||
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
@@ -302,6 +303,7 @@ public class BusPassengerMapDirectionView
|
||||
texIndexList.clear();
|
||||
mCoordinatesLatLng.clear();
|
||||
mLinePointsLatLng.clear();
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, " mCoordinatesLatLng.clear " );
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
@@ -368,7 +370,7 @@ public class BusPassengerMapDirectionView
|
||||
mLinePointsLatLng.clear();
|
||||
mLinePointsLatLng.addAll(routeLineLatLngs);
|
||||
|
||||
if (mCoordinatesLatLng.size() > 0 && mCurrentIndex != currentIndex) {
|
||||
if (mLinePointsLatLng.size() > 0 && mCurrentIndex != currentIndex) {
|
||||
if (mAMap != null && mLineMarkers.size() > 0) {
|
||||
mCurrentIndex = currentIndex;
|
||||
for (int i = 0; i < mLineMarkers.size(); i++) {
|
||||
|
||||
@@ -10,11 +10,11 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.elegant.utils.UiThreadHandler;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
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;
|
||||
@@ -24,8 +24,10 @@ 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.ui.layoutmanager.CenterLayoutManager;
|
||||
import com.mogo.och.bus.passenger.utils.BPRouteDataTestUtils;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.wigets.MarqueeTextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -49,7 +51,7 @@ public class BusPassengerRouteFragment extends
|
||||
private TextView mSpeedTv;
|
||||
private ConstraintLayout mNoLineInfoView;
|
||||
private TextView mCarPlateNum;
|
||||
private TextView mLineName;
|
||||
private MarqueeTextView mLineName;
|
||||
private TextView mOperationTime;
|
||||
private ConstraintLayout mRouteInfoView;
|
||||
private RecyclerView mStationsListRv;
|
||||
@@ -58,6 +60,7 @@ public class BusPassengerRouteFragment extends
|
||||
private RotateAnimation rotateAnimation;
|
||||
private float lastBearing = 0;
|
||||
private BusPassengerLineStationsAdapter mAdapter;
|
||||
private TextView emptyTv;
|
||||
|
||||
@Override
|
||||
public int getStationPanelViewId() {
|
||||
@@ -79,6 +82,7 @@ public class BusPassengerRouteFragment extends
|
||||
mSpeedTv = findViewById(R.id.bus_p_speed_tv);
|
||||
|
||||
mNoLineInfoView =findViewById(R.id.bus_p_no_order_data_view);
|
||||
emptyTv = findViewById(R.id.no_order_data_tv);
|
||||
|
||||
mCarPlateNum = findViewById(R.id.bus_p_driver_num_plate_tv);
|
||||
mLineName = findViewById(R.id.bus_p_line_name_tv);
|
||||
@@ -86,7 +90,8 @@ public class BusPassengerRouteFragment extends
|
||||
|
||||
mRouteInfoView = findViewById(R.id.bus_p_line_cl);
|
||||
mStationsListRv = findViewById(R.id.bus_p_line_stations_rl);
|
||||
LinearLayoutManager manager = new LinearLayoutManager(getContext());
|
||||
|
||||
CenterLayoutManager manager = new CenterLayoutManager(getContext());
|
||||
mStationsListRv.setLayoutManager(manager);
|
||||
mAdapter = new BusPassengerLineStationsAdapter(getContext(), mStationsList);
|
||||
mStationsListRv.setAdapter(mAdapter);
|
||||
@@ -94,19 +99,21 @@ public class BusPassengerRouteFragment extends
|
||||
mMapArrowIcon = findViewById(R.id.bus_p_arrow_nor);
|
||||
|
||||
//测试
|
||||
mSpeedTv.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
BPRouteDataTestUtils.converToRouteData();
|
||||
UiThreadHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateWayPointList(mStationsList,1);
|
||||
}
|
||||
},1000);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (DebugConfig.isDebug()){
|
||||
mSpeedTv.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
BPRouteDataTestUtils.converToRouteData();
|
||||
UiThreadHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateWayPointList(mStationsList,1);
|
||||
}
|
||||
},1000);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,7 +152,7 @@ public class BusPassengerRouteFragment extends
|
||||
if (latLngList.size() > 0) {
|
||||
drawablePolyline(latLngList,haveArrivedIndex);
|
||||
} else {
|
||||
clearPolyline();
|
||||
clearMapView();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +168,7 @@ public class BusPassengerRouteFragment extends
|
||||
});
|
||||
}
|
||||
} else {
|
||||
clearPolyline();
|
||||
clearMapView();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,12 +189,24 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
public void clearPolyline() {
|
||||
public void clearMapView() {
|
||||
if (mMapDirectionView != null) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.clearPolyline();
|
||||
mMapDirectionView.clearCoordinatesLatLng();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void clearMapMarkers() {
|
||||
if (mMapDirectionView != null) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.clearLineMarkers();
|
||||
|
||||
}
|
||||
});
|
||||
@@ -211,8 +230,30 @@ public class BusPassengerRouteFragment extends
|
||||
mNoLineInfoView.setVisibility(View.GONE);
|
||||
mRouteInfoView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
emptyTv.setText(getString(R.string.bus_p_no_out));
|
||||
mNoLineInfoView.setVisibility(View.VISIBLE);
|
||||
mRouteInfoView.setVisibility(View.GONE);
|
||||
updateArrivedStation(null,0,true);
|
||||
clearMapView();
|
||||
clearMapMarkers();
|
||||
}
|
||||
}
|
||||
|
||||
public void showNoTaskView(){
|
||||
if (mNoLineInfoView.getVisibility() == View.GONE){
|
||||
mNoLineInfoView.setVisibility(View.VISIBLE);
|
||||
mRouteInfoView.setVisibility(View.GONE);
|
||||
updateArrivedStation(null,0,true);
|
||||
clearMapView();
|
||||
clearMapMarkers();
|
||||
}
|
||||
emptyTv.setText(getString(R.string.bus_p_no_task));
|
||||
}
|
||||
|
||||
public void hideNoTaskView(){
|
||||
if (mNoLineInfoView.getVisibility() == View.VISIBLE){
|
||||
mNoLineInfoView.setVisibility(View.GONE);
|
||||
mRouteInfoView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,8 +289,7 @@ public class BusPassengerRouteFragment extends
|
||||
if (currentStationIndex == 0 && isArrived){ //到达始发站且并未出发, 恢复站点marker 清楚路径 清空路径点
|
||||
SharedPrefsMgr.getInstance(getContext())
|
||||
.remove(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS);
|
||||
if (mMapDirectionView != null) mMapDirectionView.clearCoordinatesLatLng();
|
||||
clearPolyline();
|
||||
clearMapView();
|
||||
}
|
||||
|
||||
if (stations.size() > 0){
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mogo.och.bus.passenger.ui.layoutmanager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class CenterLayoutManager extends LinearLayoutManager {
|
||||
public CenterLayoutManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public CenterLayoutManager(Context context, int orientation, boolean reverseLayout) {
|
||||
super(context, orientation, reverseLayout);
|
||||
}
|
||||
|
||||
public CenterLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
|
||||
RecyclerView.SmoothScroller smoothScroller = new CenterSmoothScroller(recyclerView.getContext());
|
||||
smoothScroller.setTargetPosition(position);
|
||||
startSmoothScroll(smoothScroller);
|
||||
}
|
||||
|
||||
private static class CenterSmoothScroller extends LinearSmoothScroller {
|
||||
|
||||
CenterSmoothScroller(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference) {
|
||||
return (boxStart + (boxEnd - boxStart) / 2) - (viewStart + (viewEnd - viewStart) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 475 B |
|
After Width: | Height: | Size: 494 B |
|
After Width: | Height: | Size: 505 B |
|
After Width: | Height: | Size: 996 B |
|
After Width: | Height: | Size: 632 B |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 475 B |
|
After Width: | Height: | Size: 494 B |
|
After Width: | Height: | Size: 505 B |
|
After Width: | Height: | Size: 996 B |
|
After Width: | Height: | Size: 632 B |
|
After Width: | Height: | Size: 5.5 KiB |
@@ -27,7 +27,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<com.mogo.och.common.module.wigets.OCHBorderShadowLayout
|
||||
android:id="@+id/iv_bg"
|
||||
android:id="@+id/arrive_station_shadow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/bus_p_curent_station_panel_margin_left"
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/no_order_data_iv"
|
||||
android:text="@string/bus_p_no_data"/>
|
||||
android:text="@string/bus_p_no_out"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -105,21 +105,25 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
<com.mogo.och.common.module.wigets.MarqueeTextView
|
||||
android:id="@+id/bus_p_line_name_tv"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_20"
|
||||
android:layout_marginRight="@dimen/dp_20"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:text="----"
|
||||
app:customGap="0.5"
|
||||
app:useCustomGap="true"
|
||||
android:textColor="@color/bus_p_line_name_color"
|
||||
android:textSize="@dimen/bus_p_driver_number_plate_size"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toRightOf="@+id/bus_p_driver_num_plate_tv"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_driver_num_plate_tv"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_driver_num_plate_tv"
|
||||
app:layout_goneMarginLeft="0px" />
|
||||
|
||||
<TextView
|
||||
@@ -146,9 +150,9 @@
|
||||
android:id="@+id/bus_p_line_stations_rl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/dp_280"
|
||||
android:paddingBottom="@dimen/dp_30"
|
||||
android:paddingLeft="@dimen/bus_p_route_info_margin_left"
|
||||
android:layout_marginTop="@dimen/dp_260"
|
||||
android:paddingBottom="@dimen/dp_20"
|
||||
android:paddingLeft="@dimen/dp_30"
|
||||
android:paddingRight="@dimen/bus_p_route_info_margin_right"
|
||||
android:requiresFadingEdge="vertical"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_driver_num_plate_tv"
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.mogo.och.common.module.wigets.MarqueeTextView
|
||||
android:id="@+id/bus_p_station"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="--"
|
||||
android:textSize="@dimen/bus_p_station_txt_size"
|
||||
android:textStyle="bold"
|
||||
android:includeFontPadding = "false"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:layout_marginRight="@dimen/dp_60"
|
||||
android:textColor="@color/bus_p_station_txt_color"
|
||||
android:layout_marginLeft="@dimen/dp_90"
|
||||
app:customGap="0.5"
|
||||
app:useCustomGap="true"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bus_p_tag"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bus_p_cur_arrow_bg"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="62px"
|
||||
android:layout_height="62px"
|
||||
android:src="@drawable/bus_p_point_gray"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_circle"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_circle"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_circle"
|
||||
app:layout_constraintRight_toRightOf="@+id/bus_p_circle"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_circle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/bus_p_point_blue"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_station"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_station"/>
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_cur_arrow_bg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_marginLeft="8px"
|
||||
android:src="@drawable/bus_p_line_blue"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_circle"
|
||||
app:layout_constraintRight_toRightOf="@+id/bus_p_circle"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_tag"
|
||||
android:layout_width="@dimen/bus_p_station_tag_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_tag_width_height"
|
||||
android:background="@drawable/bg_bus_p_end_tag_bg"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_circle"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_circle"/>
|
||||
<TextView
|
||||
android:id="@+id/bus_p_tag_txt"
|
||||
android:layout_width="@dimen/bus_p_station_tag_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_tag_width_height"
|
||||
android:textSize="@dimen/bus_p_station_tag_txt_size"
|
||||
android:textColor="@color/bus_p_end_tag_txt_color"
|
||||
android:text="@string/bus_p_end_station_txt_tag"
|
||||
android:includeFontPadding="false"
|
||||
android:gravity="center"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_tag"
|
||||
app:layout_constraintRight_toRightOf="@+id/bus_p_tag"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_tag"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_tag"/>
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/group_station_tag_panel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="bus_p_tag,bus_p_tag_txt"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,72 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/bus_p_station_item_height"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/bus_p_station_tag_line_width"
|
||||
android:layout_height="@dimen/bus_p_station_tag_line_height1"
|
||||
android:background="@color/bus_p_tag_line_color"
|
||||
android:layout_marginLeft="@dimen/dp_7"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_p_end_station"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="--"
|
||||
android:textSize="@dimen/bus_p_station_txt_size"
|
||||
android:textStyle="bold"
|
||||
android:includeFontPadding = "false"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:layout_marginRight="@dimen/dp_60"
|
||||
android:textColor="@color/bus_p_station_txt_color"
|
||||
android:layout_marginLeft="@dimen/dp_45"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bus_p_end_tag"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_end_circle"
|
||||
android:layout_width="@dimen/bus_p_station_circle_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_circle_width_height"
|
||||
android:background="@drawable/bg_bus_p_end_station_circle"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_end_station"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_end_station"/>
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_cur_end_station_tag"
|
||||
android:layout_width="@dimen/bus_p_cur_station_circle_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
android:background="@drawable/bg_bus_p_arrived_station"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_end_station"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_end_station"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_end_tag"
|
||||
android:layout_width="@dimen/bus_p_station_tag_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_tag_width_height"
|
||||
android:background="@drawable/bg_bus_p_end_tag_bg"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
<TextView
|
||||
android:layout_width="@dimen/bus_p_station_tag_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_tag_width_height"
|
||||
android:textSize="@dimen/bus_p_station_tag_txt_size"
|
||||
android:textColor="@color/bus_p_end_tag_txt_color"
|
||||
android:text="@string/bus_p_end_station_txt_tag"
|
||||
android:includeFontPadding="false"
|
||||
android:gravity="center"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_end_tag"
|
||||
app:layout_constraintRight_toRightOf="@+id/bus_p_end_tag"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_end_tag"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_end_tag"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/bus_p_station_item_middle_height"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/bus_p_station_tag_line_width"
|
||||
android:layout_height="@dimen/bus_p_station_tag_line_height"
|
||||
android:background="@color/bus_p_tag_line_color"
|
||||
android:layout_marginLeft="@dimen/dp_7"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
<ImageView
|
||||
android:layout_width="@dimen/bus_p_station_tag_line_width"
|
||||
android:layout_height="@dimen/bus_p_station_tag_line_height"
|
||||
android:background="@color/bus_p_tag_line_color"
|
||||
android:layout_marginLeft="@dimen/dp_7"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
<TextView
|
||||
android:id="@+id/bus_p_middle_station"
|
||||
android:layout_width="@dimen/bus_p_station_txt_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="--"
|
||||
android:textSize="@dimen/bus_p_station_txt_size"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:layout_marginBottom="@dimen/dp_20"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:layout_marginRight="@dimen/dp_60"
|
||||
android:includeFontPadding = "false"
|
||||
android:textColor="@color/bus_p_current_station_txt_color"
|
||||
android:layout_marginLeft="@dimen/dp_45"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_middle_circle"
|
||||
android:layout_width="@dimen/bus_p_station_circle_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_circle_width_height"
|
||||
android:background="@drawable/bg_bus_p_middle_station_circle"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_middle_station"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_middle_station"/>
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_middle_tag"
|
||||
android:layout_width="@dimen/bus_p_cur_station_circle_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
android:background="@drawable/bg_bus_p_arrived_station"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_middle_station"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_middle_station"/>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,74 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/bus_p_station_item_height"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/bus_p_station_tag_line_width"
|
||||
android:layout_height="@dimen/bus_p_station_tag_line_height1"
|
||||
android:background="@color/bus_p_tag_line_color"
|
||||
android:layout_marginLeft="@dimen/dp_7"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_p_start_station"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_45"
|
||||
android:includeFontPadding="false"
|
||||
android:text="--"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:textColor="@color/bus_p_station_txt_color"
|
||||
android:textSize="@dimen/bus_p_station_txt_size"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginRight="@dimen/dp_60"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bus_p_start_tag"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_start_circle"
|
||||
android:layout_width="@dimen/bus_p_station_circle_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_circle_width_height"
|
||||
android:background="@drawable/bg_bus_p_start_station_circle"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_start_station"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_start_station"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_cur_start_station_tag"
|
||||
android:layout_width="@dimen/bus_p_cur_station_circle_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
android:background="@drawable/bg_bus_p_arrived_station"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_start_station"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_start_station"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_p_start_tag"
|
||||
android:layout_width="@dimen/bus_p_station_tag_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_tag_width_height"
|
||||
android:background="@drawable/bg_bus_p_start_tag_bg"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_start_station"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_start_station"/>
|
||||
<TextView
|
||||
android:layout_width="@dimen/bus_p_station_tag_width_height"
|
||||
android:layout_height="@dimen/bus_p_station_tag_width_height"
|
||||
android:textSize="@dimen/bus_p_station_tag_txt_size"
|
||||
android:textColor="@color/bus_p_end_tag_txt_color"
|
||||
android:text="@string/bus_p_start_station_txt_tag"
|
||||
android:includeFontPadding="false"
|
||||
android:gravity="center"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/bus_p_start_tag"
|
||||
app:layout_constraintRight_toRightOf="@+id/bus_p_start_tag"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_p_start_tag"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_p_start_tag"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="bus_p_speed_unit_txt">KM/H</string>
|
||||
<string name="bus_p_no_data">您已收车</string>
|
||||
<string name="bus_p_no_out">您已收车</string>
|
||||
<string name="bus_p_no_task">暂无班次</string>
|
||||
<string name="bus_p_start_station_txt_tag">起</string>
|
||||
<string name="bus_p_end_station_txt_tag">终</string>
|
||||
<string name="bus_p_cur_station_title">到达站:</string>
|
||||
|
||||
@@ -51,6 +51,7 @@ dependencies {
|
||||
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
compileOnly rootProject.ext.dependencies.recyclerviewadapterhelper
|
||||
|
||||
implementation project(":OCH:mogo-och-common-module")
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<activity android:name=".ui.BusSwitchLineActivity"
|
||||
android:theme="@style/SwitchLineDialogStyle"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="landscape" />/>
|
||||
android:screenOrientation="landscape" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
package com.mogo.och.bus;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
|
||||
@@ -6,10 +7,10 @@ import android.content.Context;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
@@ -50,14 +51,20 @@ public class BusProvider implements IMogoOCH {
|
||||
}
|
||||
|
||||
private void showFragment() {
|
||||
FragmentManager supportFragmentManager = activity.getSupportFragmentManager();
|
||||
if (busFragment == null) {
|
||||
CallerLogger.INSTANCE.d(TAG, "准备add fragment======");
|
||||
busFragment = new BusFragment();
|
||||
activity.getSupportFragmentManager().beginTransaction().add(containerId, busFragment).commitAllowingStateLoss();
|
||||
Fragment fragmentByTag = supportFragmentManager.findFragmentByTag(BusFragment.TAG);
|
||||
if(fragmentByTag instanceof BusFragment){
|
||||
busFragment = (BusFragment)fragmentByTag;
|
||||
}else {
|
||||
busFragment = new BusFragment();
|
||||
}
|
||||
supportFragmentManager.beginTransaction().add(containerId, busFragment,BusFragment.TAG).commitAllowingStateLoss();
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(TAG, "准备show fragment");
|
||||
activity.getSupportFragmentManager().beginTransaction().show(busFragment).commitAllowingStateLoss();
|
||||
supportFragmentManager.beginTransaction().show(busFragment).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
private void hideFragment() {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mogo.och.bus.bean;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
|
||||
/**
|
||||
* 中止/结束任务请求
|
||||
*/
|
||||
public class BusCloseTaskRequest {
|
||||
|
||||
private String sn;
|
||||
private int taskId;
|
||||
public BusCloseTaskRequest(int taskId) {
|
||||
this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.och.bus.bean;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/22
|
||||
*
|
||||
* 小巴车运营状态返回参数
|
||||
*/
|
||||
public class BusOperationStatusResponse extends BaseData {
|
||||
|
||||
public Result data;
|
||||
|
||||
public static class Result {
|
||||
|
||||
public int serviceStatus;//0:已收车,1:已出车
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,55 +2,57 @@ package com.mogo.och.bus.bean;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/22
|
||||
*
|
||||
* 根据车机行驶线路站点信息
|
||||
*/
|
||||
class BusQueryLineStationsRequest {
|
||||
public class BusQueryLineStationsRequest {
|
||||
|
||||
private String sn;
|
||||
private double lat;
|
||||
private double lon;
|
||||
private boolean markDrivingStatus; // 默认false;true:是否需要返回站点的行驶状态,对应返回的drivingStatus
|
||||
// private double lat;
|
||||
// private double lon;
|
||||
// private boolean markDrivingStatus; // 默认false;true:是否需要返回站点的行驶状态,对应返回的drivingStatus
|
||||
// 0 - 关闭、1 - 启动
|
||||
// public String status;
|
||||
public BusQueryLineStationsRequest(double lon, double lat, boolean markDrivingStatus) {
|
||||
// public BusQueryLineStationsRequest(double lon, double lat, boolean markDrivingStatus) {
|
||||
// this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
// this.lat = lat;
|
||||
// this.lon = lon;
|
||||
// this.markDrivingStatus = markDrivingStatus;
|
||||
// }
|
||||
public BusQueryLineStationsRequest() {
|
||||
this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.markDrivingStatus = markDrivingStatus;
|
||||
}
|
||||
|
||||
public boolean isMarkDrivingStatus() {
|
||||
return markDrivingStatus;
|
||||
}
|
||||
|
||||
public void setMarkDrivingStatus(boolean markDrivingStatus) {
|
||||
this.markDrivingStatus = markDrivingStatus;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
// public boolean isMarkDrivingStatus() {
|
||||
// return markDrivingStatus;
|
||||
// }
|
||||
//
|
||||
// public void setMarkDrivingStatus(boolean markDrivingStatus) {
|
||||
// this.markDrivingStatus = markDrivingStatus;
|
||||
// }
|
||||
//
|
||||
// public void setLat(double lat) {
|
||||
// this.lat = lat;
|
||||
// }
|
||||
//
|
||||
// public void setLon(double lon) {
|
||||
// this.lon = lon;
|
||||
// }
|
||||
//
|
||||
// public String getSn() {
|
||||
// return sn;
|
||||
// }
|
||||
//
|
||||
// public double getLat() {
|
||||
// return lat;
|
||||
// }
|
||||
//
|
||||
// public double getLon() {
|
||||
// return lon;
|
||||
// }
|
||||
// public BusOperationStatusRequest shutdown() {
|
||||
// status = "0";
|
||||
// return this;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mogo.och.bus.bean;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/2/9
|
||||
*/
|
||||
public class BusQueryLineTaskResponse extends BaseData {
|
||||
|
||||
public List<Result> data;
|
||||
|
||||
public static class Result {
|
||||
public int id;
|
||||
public long taskStartTime;
|
||||
}
|
||||
}
|
||||
@@ -19,5 +19,9 @@ public class BusQueryLinesResponse extends BaseData {
|
||||
public String startSiteName;//始发站名称
|
||||
public String endSiteName;//终点名称
|
||||
|
||||
public boolean open;//true 打开状态 false
|
||||
public boolean haveTask;
|
||||
|
||||
public List<BusQueryLineTaskResponse.Result> taskList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.och.bus.bean;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/19
|
||||
*/
|
||||
public class BusQueryWriteOffPassengersResponse extends BaseData {
|
||||
public List<WriteOffPassenger> data;
|
||||
}
|
||||
@@ -9,10 +9,10 @@ import com.mogo.commons.network.Utils;
|
||||
*/
|
||||
public class BusResetDrivingLineRequest {
|
||||
public String sn;
|
||||
public int lineId; //切换到的线路id
|
||||
public int taskId; //切换到的线路id
|
||||
|
||||
public BusResetDrivingLineRequest(int lineId) {
|
||||
sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
this.lineId = lineId;
|
||||
public BusResetDrivingLineRequest(int taskId) {
|
||||
this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
this.taskId = taskId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.och.bus.bean;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/22
|
||||
*
|
||||
* 小巴车重置路线状态请求参数
|
||||
*/
|
||||
class BusResetLineStatusRequest {
|
||||
|
||||
private String sn;
|
||||
public BusResetLineStatusRequest() {
|
||||
this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public class BusRoutesResult {
|
||||
private int lineType; //线路类型,0:环形
|
||||
private String description;
|
||||
private int status;
|
||||
private long taskTime; //线路时间班次
|
||||
private int taskId;// 线路班次id
|
||||
|
||||
//线路轨迹相关字段
|
||||
public String csvFileUrl = ""; //轨迹文件下载的cos url,默认“”
|
||||
@@ -32,6 +34,10 @@ public class BusRoutesResult {
|
||||
return lineId;
|
||||
}
|
||||
|
||||
public int getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -44,12 +50,17 @@ public class BusRoutesResult {
|
||||
this.sites = sites;
|
||||
}
|
||||
|
||||
public long getTaskTime() {
|
||||
return taskTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BusRoutesResult{" +
|
||||
"sites=" + sites +
|
||||
", lineId=" + lineId +
|
||||
", name='" + name + '\'' +
|
||||
", taskTime='" + taskTime + '\'' +
|
||||
", lineType=" + lineType +
|
||||
", description='" + description + '\'' +
|
||||
", status=" + status +
|
||||
|
||||
@@ -12,16 +12,14 @@ import com.mogo.commons.network.Utils;
|
||||
public class BusUpdateSiteStatusRequest {
|
||||
|
||||
public String sn;
|
||||
public int taskId;
|
||||
public int seq;//站点序号
|
||||
public int siteId;//站点id
|
||||
public double lon;
|
||||
public double lat;
|
||||
|
||||
public BusUpdateSiteStatusRequest(int seq, int siteId, double lon, double lat) {
|
||||
public BusUpdateSiteStatusRequest(int taskId,int siteId,int seq) {
|
||||
this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
this.seq = seq;
|
||||
this.siteId = siteId;
|
||||
this.lon = lon;
|
||||
this.lat = lat;
|
||||
this.taskId = taskId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.och.bus.bean;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
|
||||
/**
|
||||
* 查询核销乘客
|
||||
*/
|
||||
public class BusWriteOffPassengersQueryRequest {
|
||||
|
||||
private String sn;
|
||||
private int taskId;
|
||||
private int siteId;
|
||||
private long verificationTime;
|
||||
public BusWriteOffPassengersQueryRequest(int taskId, int siteId,long prePassengerTime) {
|
||||
this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
this.taskId = taskId;
|
||||
this.siteId = siteId;
|
||||
this.verificationTime = prePassengerTime;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mogo.och.bus.bean;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/9/23
|
||||
*/
|
||||
public class WriteOffPassenger {
|
||||
public String phone;
|
||||
public String orderNo;
|
||||
public int passengerSize;
|
||||
public long writeOffTime;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.och.bus.callback;
|
||||
|
||||
/**
|
||||
* Created on 2021/9/8
|
||||
*
|
||||
* Model->Presenter回调:ADAS相关(自动驾驶状态回调,到达终点等等)
|
||||
*/
|
||||
public interface IBusADASStatusCallback {
|
||||
//自驾返回失败
|
||||
void onStartAdasFailure();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.och.bus.callback;
|
||||
|
||||
import com.mogo.och.bus.bean.BusQueryLineTaskResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
|
||||
/**
|
||||
@@ -9,4 +10,5 @@ import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
public interface IBusLinesCallback {
|
||||
void onBusLinesChange(BusQueryLinesResponse lines);
|
||||
void onChangeLineIdSuccess();
|
||||
void onBusLineTasks(BusQueryLineTaskResponse o, int position,boolean autoRefresh);
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.mogo.och.bus.callback;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/22
|
||||
*/
|
||||
public interface ICarOperationStatusCallback {
|
||||
void changeOperationStatus(boolean changeStatus);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.och.bus.callback;
|
||||
|
||||
import com.mogo.och.bus.bean.WriteOffPassenger;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/9/26
|
||||
*/
|
||||
public interface IPassengerCallback {
|
||||
void playPassenger(WriteOffPassenger passenger);
|
||||
}
|
||||
@@ -9,5 +9,15 @@ import java.util.List;
|
||||
* @date: 2021/10/22
|
||||
*/
|
||||
public interface IRefreshBusStationsCallback {
|
||||
void refreshBusStations(String lineName,List<BusStationBean> stationList, int currentStation, int nextStation, boolean isArrived);
|
||||
void updateBusTaskStatus(String lineName,String lintTime,
|
||||
List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived);
|
||||
|
||||
/**
|
||||
* 结束清理一遍、选择任务后清理一遍
|
||||
*/
|
||||
void clearBusStationsMarkers();
|
||||
|
||||
void updateEmptyUi();
|
||||
}
|
||||
|
||||
@@ -63,8 +63,12 @@ class BusConst {
|
||||
const val EVENT_PARAM_END_NAME = "end_name"
|
||||
const val EVENT_PARAM_LINE_ID = "line_id"
|
||||
const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false
|
||||
const val EVENT_PARAM_START_FAILURE_MSG = "start_autopilot_failure_msg" // 启动自驾失败原因
|
||||
const val EVENT_PARAM_PLATE_NUM = "plate_number" // 车牌号
|
||||
const val EVENT_PARAM_ENV_ONLINE = "env_online" // 是否线上环境:true/false
|
||||
// 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾
|
||||
const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_bus_ap_unable_start_reason"
|
||||
const val EVENT_PARAM_UNABLE_START_REASON = "unable_start_reason";
|
||||
|
||||
/**
|
||||
* 订单起终点Marker类型
|
||||
@@ -75,5 +79,13 @@ class BusConst {
|
||||
|
||||
//围栏到站 暂定10米
|
||||
const val ARRIVE_AT_END_STATION_DISTANCE = 10
|
||||
|
||||
// 轮询
|
||||
const val LOOP_PASSENGER_5S = 5 * 1000L
|
||||
const val LOOP_PASSENGER_2S = 2 * 1000L
|
||||
const val LOOP_PASSENGER_1S = 1 * 1000L
|
||||
const val LOOP_DELAY_500 = 500L
|
||||
|
||||
const val DELAY_10S = 10 * 1000L
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,10 @@ import static com.mogo.och.bus.constant.BusConst.TIMER_START_AUTOPILOT_INTERVAL;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
@@ -32,6 +34,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListener
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.TrafficDataView;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
@@ -48,6 +51,10 @@ import com.mogo.och.bus.constant.BusConst;
|
||||
import com.mogo.och.bus.model.BusOrderModel;
|
||||
import com.mogo.och.bus.util.BDRouteDataTestUtils;
|
||||
import com.mogo.och.bus.view.SlidePanelView;
|
||||
import com.mogo.och.common.module.utils.SoundPoolHelper;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import record_cache.RecordPanelOuterClass;
|
||||
@@ -67,17 +74,13 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
private RelativeLayout ctvAutopilotStatus;
|
||||
private ImageView ctvAutopilotStatusIv;
|
||||
private TextView ctvAutopilotStatusTv;
|
||||
protected TextView tvOperationStatus;
|
||||
protected TextView tvArrived;
|
||||
protected RelativeLayout mSettingBtn;
|
||||
protected RelativeLayout mBadcaseBtn;
|
||||
protected RelativeLayout mAICollectBtn;
|
||||
public boolean isOperationStatus;//false-收车,true-出车
|
||||
private FrameLayout flStationPanelContainer;
|
||||
private Group groupTestPanel;
|
||||
private FrameLayout flSpeed;
|
||||
// private BusArcView mouduleArc;
|
||||
private TrafficDataView mTrafficDataView;
|
||||
private ImageView mUpgradeTipIv;
|
||||
// private BusTrafficLightView mTrafficLightView;
|
||||
|
||||
public static final String TYPE_ENTRANCE = "entrance";
|
||||
@@ -105,8 +108,6 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
return R.layout.bus_base_fragment;
|
||||
}
|
||||
|
||||
private View panelView;
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
groupTestPanel = findViewById(R.id.groupTestPanel);
|
||||
@@ -119,12 +120,12 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
// mTrafficLightView = findViewById(R.id.bus_traffic_light_view);
|
||||
// CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView);
|
||||
|
||||
tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status);
|
||||
// tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status);
|
||||
tvArrived = findViewById(R.id.module_mogo_och_arrived_tv);
|
||||
|
||||
flSpeed = (FrameLayout) findViewById(R.id.fl_speed);
|
||||
mTrafficDataView = (TrafficDataView) findViewById(R.id.bus_arc);
|
||||
|
||||
panelView = LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer);
|
||||
LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer);
|
||||
slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener);
|
||||
|
||||
mSwitchMapModeLayout = findViewById(R.id.bus_switch_model_layout);
|
||||
@@ -137,14 +138,21 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
public void onClickImpl(View v) {
|
||||
//切换地图的远近视图
|
||||
if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight()) {
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).visibleAllMarkers();
|
||||
// 2.11.0去掉
|
||||
// MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).visibleAllMarkers();
|
||||
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
|
||||
mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium);
|
||||
} else if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isMediumSight()) {
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
.inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS, BusConst.TYPE_MARKER_BUS_ORDER);
|
||||
// 2.11.0去掉
|
||||
// MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
// .inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS, BusConst.TYPE_MARKER_BUS_ORDER);
|
||||
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null);
|
||||
mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long);
|
||||
} else {
|
||||
// 2.11.0去掉
|
||||
// MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).visibleAllMarkers();
|
||||
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
|
||||
mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -160,19 +168,15 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
});
|
||||
}
|
||||
initListener();
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClickImpl(View v) {
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
|
||||
restartAutopilot();
|
||||
}else {
|
||||
ToastUtils.showShort(getResources().getString(R.string.bus_auto_disable_tip));
|
||||
}
|
||||
restartAutopilot();
|
||||
}
|
||||
});
|
||||
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
// 模拟 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接
|
||||
findViewById(R.id.btnAutopilotDisable).setOnClickListener(view ->
|
||||
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE)
|
||||
@@ -194,9 +198,9 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
);
|
||||
|
||||
findViewById(R.id.btnAutopilotRoute).setOnClickListener(view -> debugArrivedRoute());
|
||||
|
||||
tvOperationStatus.setOnClickListener(view -> {
|
||||
onChangeOperationStatus();
|
||||
|
||||
tvArrived.setOnClickListener(view -> {
|
||||
onArriveStation();
|
||||
});
|
||||
|
||||
mSettingBtn = findViewById(R.id.module_mogo_och_setting_layout);
|
||||
@@ -207,11 +211,6 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
|
||||
// mBadcaseBtn的visible显示逻辑在showBadcaseEntrance内处理
|
||||
mBadcaseBtn = findViewById(R.id.module_mogo_och_badcase_rl);
|
||||
// CallerHmiManager.INSTANCE.registerBadCaseCallback(
|
||||
// () -> { // onShow()
|
||||
// return mBadcaseBtn; },
|
||||
// () -> { // onHide()
|
||||
// return null; });
|
||||
|
||||
if (mBadcaseBtn != null) {
|
||||
CallerDevaToolsManager.INSTANCE.initBadCase(mBadcaseBtn);
|
||||
@@ -226,6 +225,16 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container
|
||||
, @Nullable Bundle savedInstanceState) {
|
||||
EventBus.getDefault().register(this);
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
protected abstract void onArriveStation();
|
||||
|
||||
private void updateSwitchMapIcon(){
|
||||
if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight()) {
|
||||
mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long);
|
||||
@@ -246,6 +255,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
if (!HmiBuildConfig.isShowBadCaseView) {
|
||||
CallerAutopilotRecordListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -270,22 +280,32 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoMapListener(TYPE_ENTRANCE, this);
|
||||
}
|
||||
|
||||
protected void onChangeOperationStatus() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示滑动按钮
|
||||
*
|
||||
* @param text 指定的文字
|
||||
*/
|
||||
public void showSlidePanle(String text) {
|
||||
if (isOperationStatus) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
slidePanelView.setText(text);
|
||||
slidePanelView.setVisibility(View.VISIBLE);
|
||||
});
|
||||
}
|
||||
public void showSlidePanel(String text) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
slidePanelView.setText(text);
|
||||
slidePanelView.setVisibility(View.VISIBLE);
|
||||
});
|
||||
setArrivedClikable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进站按钮状态
|
||||
* @param isClickable
|
||||
*/
|
||||
public void setArrivedClikable(boolean isClickable){
|
||||
getActivity().runOnUiThread(() -> {
|
||||
tvArrived.setEnabled(isClickable);
|
||||
if (isClickable){
|
||||
tvArrived.setTextColor(getResources().getColor(R.color.bus_white));
|
||||
}else {
|
||||
tvArrived.setTextColor(getResources().getColor(R.color.bus_arrived_btn_un_clickable_color));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,12 +317,9 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
});
|
||||
}
|
||||
|
||||
public void showNotice(String notice) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice(notice);
|
||||
});
|
||||
public void playDI(){
|
||||
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(getContext(), R.raw.bus_di);
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变自动驾驶状态
|
||||
*
|
||||
@@ -321,13 +338,13 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv));
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon);
|
||||
ctvAutopilotStatus.setSelected(false);
|
||||
ctvAutopilotStatus.setFocusableInTouchMode(true);
|
||||
ctvAutopilotStatus.setClickable(true);
|
||||
|
||||
} else {
|
||||
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
|
||||
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv));
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot);
|
||||
ctvAutopilotStatus.setFocusableInTouchMode(true);
|
||||
ctvAutopilotStatus.setClickable(true);
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) {//1可用
|
||||
ctvAutopilotStatus.setSelected(false);
|
||||
}else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus){
|
||||
@@ -343,12 +360,12 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
|
||||
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_success_tv));
|
||||
ctvAutopilotStatus.setSelected(false);
|
||||
ctvAutopilotStatus.setFocusableInTouchMode(false);
|
||||
ctvAutopilotStatus.setClickable(false);
|
||||
}else {
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon);
|
||||
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
|
||||
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv));
|
||||
ctvAutopilotStatus.setFocusableInTouchMode(false);
|
||||
ctvAutopilotStatus.setClickable(false);
|
||||
ctvAutopilotStatus.setSelected(false);
|
||||
}
|
||||
UiThreadHandler.postDelayed(new Runnable() {
|
||||
@@ -368,14 +385,18 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
return;
|
||||
}
|
||||
if (isAnimateRunning){
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(autopilotStatus);
|
||||
stopAnimAndUpdateBtnStatus();
|
||||
}else {
|
||||
setAutopilotBtnStatus(autopilotStatus);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void stopAnimAndUpdateBtnStatus(){
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏【自动驾驶】按钮
|
||||
*/
|
||||
@@ -395,22 +416,6 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
});
|
||||
}
|
||||
|
||||
public void hidPanel() {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
flStationPanelContainer.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
public void showPanel() {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
flStationPanelContainer.setVisibility(View.VISIBLE);
|
||||
});
|
||||
}
|
||||
|
||||
public View getPanelView() {
|
||||
return panelView;
|
||||
}
|
||||
|
||||
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() {
|
||||
return null;
|
||||
}
|
||||
@@ -442,7 +447,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_tv));
|
||||
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
|
||||
ctvAutopilotStatus.setSelected(false);
|
||||
ctvAutopilotStatus.setFocusableInTouchMode(true);
|
||||
ctvAutopilotStatus.setClickable(true);
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_loading_autopilot_icon);
|
||||
if (autopilotLoadingAnimator == null) {
|
||||
autopilotLoadingAnimator = ObjectAnimator.ofFloat(ctvAutopilotStatusIv, "rotation", 0f, 360f);
|
||||
|
||||
@@ -3,18 +3,23 @@ package com.mogo.och.bus.fragment;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.temp.EventLogout;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerSmpManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
@@ -24,14 +29,21 @@ import com.mogo.och.bus.R;
|
||||
import com.mogo.och.bus.bean.BusStationBean;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
import com.mogo.och.bus.presenter.BusPresenter;
|
||||
import com.mogo.och.bus.ui.BusStationCommonItem;
|
||||
import com.mogo.och.bus.ui.BusSwitchLineActivity;
|
||||
import com.mogo.och.bus.view.SlidePanelView;
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
import com.mogo.och.common.module.biz.provider.LoginService;
|
||||
import com.mogo.och.common.module.utils.BlinkAnimationUtil;
|
||||
import com.mogo.och.common.module.utils.OCHThreadPoolManager;
|
||||
import com.mogo.och.common.module.wigets.MarqueeTextView;
|
||||
import com.mogo.och.common.module.wigets.OCHCommitDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
|
||||
/**
|
||||
* 网约车小巴界面
|
||||
@@ -40,69 +52,81 @@ import mogo.telematics.pad.MessagePad;
|
||||
*/
|
||||
public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
implements SlidePanelView.OnSlidePanelMoveToEndListener, View.OnClickListener {
|
||||
private static final String TAG = "BusFragment";
|
||||
public static final String TAG = "BusFragment";
|
||||
|
||||
private TextView mCurrentStationName;
|
||||
private TextView mNextStationName;
|
||||
private TextView mCurrentTag;
|
||||
private TextView mNextTag;
|
||||
private TextView mSwitchLine; //切换路线
|
||||
private TextView mLineName;
|
||||
private int mCurrentStation = 0;
|
||||
|
||||
private View mBus;
|
||||
private MarqueeTextView mLineName;
|
||||
private TextView mTaskTime;
|
||||
private Group groupStationsPanel;
|
||||
private ConstraintLayout noDataView;
|
||||
|
||||
private BusStationBean startStation = null;
|
||||
private BusStationBean endStation = null;
|
||||
private BusStationCommonItem firstStationItem;
|
||||
private BusStationCommonItem secondStationItem;
|
||||
private BusStationCommonItem thirdStationItem;
|
||||
|
||||
private LoginService loginService;
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return "BusFragment";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
loginService = (LoginService) ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation();
|
||||
if(loginService!=null){
|
||||
loginService.registerFragment(this, getPresenter());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
loginService.unRegisterFragment();
|
||||
loginService = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
super.initViews();
|
||||
mBus = findViewById(R.id.module_och_bus_tag);
|
||||
mCurrentStationName = findViewById(R.id.module_och_bus_current_station);
|
||||
mCurrentTag = findViewById(R.id.module_och_bus_current_station_anchor);
|
||||
mNextStationName = findViewById(R.id.module_och_bus_order_end_station);
|
||||
mNextTag = findViewById(R.id.module_och_bus_next_station_anchor);
|
||||
|
||||
mSwitchLine = findViewById(R.id.switch_line_btn);
|
||||
mSwitchLine.setTag(0);
|
||||
mLineName = findViewById(R.id.module_och_bus_line_name);
|
||||
|
||||
if (DebugConfig.isDebug()) {
|
||||
mBus.setOnClickListener(view -> {
|
||||
ToastUtils.showShort("重置了车站状态");
|
||||
mPresenter.queryBusRoutes();
|
||||
});
|
||||
|
||||
//debug下调用测试面板
|
||||
mCurrentStationName.setOnLongClickListener(v -> {
|
||||
debugTestBar();
|
||||
showHideTestBar();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
firstStationItem = findViewById(R.id.bus_panel_first_station);
|
||||
secondStationItem = findViewById(R.id.bus_panel_second_station);
|
||||
thirdStationItem = findViewById(R.id.bus_panel_third_station);
|
||||
mTaskTime = findViewById(R.id.bus_task_time_tv);
|
||||
groupStationsPanel = findViewById(R.id.group_stations_panel);
|
||||
noDataView = findViewById(R.id.no_line_data_view);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
// 初始化的时候设置 UI 按钮状态
|
||||
switch (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()) {
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
|
||||
hideAutopilotBiz();
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE:
|
||||
showAutopilotBiz();
|
||||
onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE);
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
|
||||
showAutopilotBiz();
|
||||
onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
showAutopilotBiz();
|
||||
|
||||
mSwitchLine.setOnClickListener(this);
|
||||
|
||||
mLineName.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
showHideTestBar();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void changeOverview(EventLogout eventLogout){
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG,"changeOverview Event消息去登出");
|
||||
mPresenter.logout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onArriveStation() {
|
||||
mPresenter.onAutopilotArriveAtStation(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,124 +145,237 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据站点列表信息刷新车站面板,滑块面板
|
||||
*
|
||||
* @param stationList 车站列表信息
|
||||
* @param currentStation 当前站点
|
||||
* @param nextStation 下个站点
|
||||
* @param isArrived 是否都站
|
||||
*/
|
||||
public void refreshBusStations(String lineName,List<BusStationBean> stationList
|
||||
, int currentStation, int nextStation, boolean isArrived) {
|
||||
mCurrentStation = currentStation;
|
||||
public void hideStationsPanel(){
|
||||
groupStationsPanel.setVisibility(View.GONE);
|
||||
noDataView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void showStationsPanel(){
|
||||
groupStationsPanel.setVisibility(View.VISIBLE);
|
||||
noDataView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void updateLineEmptyUI(){
|
||||
setArrivedClikable(false);
|
||||
showOrHideSwitchLineBtn(true);
|
||||
hideStationsPanel();
|
||||
hideSlidePanel();
|
||||
resetStationBlinkAnim();
|
||||
}
|
||||
|
||||
private void resetStationBlinkAnim() {
|
||||
BlinkAnimationUtil.clearAnimation(firstStationItem.getCircleImageView());
|
||||
BlinkAnimationUtil.clearAnimation(secondStationItem.getCircleImageView());
|
||||
BlinkAnimationUtil.clearAnimation(thirdStationItem.getCircleImageView());
|
||||
}
|
||||
|
||||
public void updateBusTaskStatus(String lineName, String lineTime,
|
||||
List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived){
|
||||
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (stationList == null) {
|
||||
// 获取小巴数据失败
|
||||
return;
|
||||
}
|
||||
|
||||
showStationsPanel();
|
||||
showOrHideSwitchLineBtn(false);
|
||||
|
||||
mLineName.setText(lineName);
|
||||
mTaskTime.setText(getString(R.string.bus_line_time_tag)+ lineTime);
|
||||
// 渲染小巴路线数据
|
||||
renderCurrentStationStatus(lineName,stationList, currentStation, nextStation, isArrived);
|
||||
updateBusStationStatus(stationList,arrivingOrArrivedIndex,isArrived);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新刷新站点信息 isArrived 是否到站
|
||||
*/
|
||||
private void renderCurrentStationStatus(String lineName,List<BusStationBean> stationList, int currentStation
|
||||
, int nextStation, boolean isArrived) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "MapMaker ", "currentStation=" + currentStation + ",nextStation=" + nextStation + "isArrived=" + isArrived);
|
||||
String currentStationName = null;
|
||||
String nextStationName = null;
|
||||
|
||||
boolean isArriveEndStation = false;
|
||||
boolean isArriveAtStation = false;
|
||||
boolean isArriveAtStartStation = false;
|
||||
|
||||
mLineName.setText(lineName);
|
||||
|
||||
// 获取当前站点的名称
|
||||
currentStationName = stationList.get(currentStation).getName();
|
||||
private void updateBusStationStatus(List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived) {
|
||||
|
||||
startStation = stationList.get(0);
|
||||
endStation = stationList.get(stationList.size() - 1);
|
||||
|
||||
// 是否到达起点
|
||||
if (currentStation == 0) {
|
||||
isArriveAtStartStation = true;
|
||||
mCurrentTag.setText(getResources().getString(R.string.bus_arrive_to_end_start));
|
||||
if (arrivingOrArrivedIndex == stationList.size() - 1 && isArrived){
|
||||
//切换路线和结束路线按钮切换
|
||||
showSlidePanel("单程结束");
|
||||
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
|
||||
, startStation.getLon(),R.raw.star_marker);
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
} else if (currentStation > 0 && currentStation < stationList.size() - 1) {// 是否到达站点
|
||||
isArriveAtStation = true;
|
||||
mCurrentTag.setText(getResources().getString(R.string.bus_arrive_to_current_tag));
|
||||
mNextTag.setText(getResources().getString(R.string.bus_arrive_to_next_tag));
|
||||
}else if (arrivingOrArrivedIndex == 0 && isArrived){
|
||||
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
|
||||
, startStation.getLon(),R.raw.star_marker);
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
} else if (currentStation == stationList.size() - 1) {// 是否到达终点
|
||||
isArriveEndStation = true;
|
||||
nextStationName = "--";
|
||||
mNextTag.setText(getResources().getString(R.string.bus_arrive_to_end_end));
|
||||
showSlidePanel("滑动出发");
|
||||
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
|
||||
, startStation.getLon(),R.raw.star_marker);
|
||||
|
||||
if (isArrived) {
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
} else {
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_START_MAP_MAKER,
|
||||
startStation.getLat(), startStation.getLon(),R.raw.star_marker);
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER,
|
||||
endStation.getLat(), endStation.getLon(),R.raw.end_marker);
|
||||
}else{
|
||||
if (isArrived){
|
||||
// 重置滑动按钮文字
|
||||
showSlidePanel("滑动出发");
|
||||
}
|
||||
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
|
||||
, startStation.getLon(),R.raw.star_marker);
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
}
|
||||
|
||||
// 获取下一站点名称
|
||||
if (nextStation > currentStation && nextStation <= stationList.size() - 1) {
|
||||
nextStationName = stationList.get(nextStation).getName();
|
||||
}
|
||||
|
||||
// 是否到达终点
|
||||
if ( nextStation == stationList.size() - 1 || nextStation == -1) {
|
||||
mNextTag.setText(getResources().getString(R.string.bus_arrive_to_end_end));
|
||||
if (stationList.size() > 2){ //只有两个站点
|
||||
updateMoreThanTwoStationsUI(stationList,arrivingOrArrivedIndex,isArrived);
|
||||
}else {
|
||||
mNextTag.setText(getResources().getString(R.string.bus_arrive_to_next_tag));
|
||||
updateTwoStationsUI(stationList,arrivingOrArrivedIndex,isArrived);
|
||||
}
|
||||
|
||||
if (currentStation == 0 && isArrived){
|
||||
showOrHideSwitchLineBtn(true);
|
||||
}else {
|
||||
showOrHideSwitchLineBtn(false);
|
||||
}
|
||||
|
||||
// 重置滑动按钮文字
|
||||
if (isArriveEndStation) {
|
||||
showSlidePanle("单程结束");
|
||||
} else if (isArriveAtStartStation) {
|
||||
showSlidePanle("滑动出发");
|
||||
} else if (isArriveAtStation) {
|
||||
showSlidePanle("滑动出发");
|
||||
}
|
||||
|
||||
mCurrentStationName.setText(currentStationName);
|
||||
mNextStationName.setText(nextStationName);
|
||||
updateBusTestBarInfo();
|
||||
}
|
||||
|
||||
private void showOrHideSwitchLineBtn(boolean isShow) {
|
||||
if (isShow){
|
||||
mSwitchLine.setVisibility(View.VISIBLE);
|
||||
/**
|
||||
* 有两个以上站点的路线
|
||||
* @param stationList
|
||||
* @param arrivingOrArrivedIndex
|
||||
* @param isArrived
|
||||
*/
|
||||
private void updateMoreThanTwoStationsUI(List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived) {
|
||||
secondStationItem.setStationTag("");
|
||||
secondStationItem.showOrHideStationArrowBg(true);
|
||||
thirdStationItem.setStationTag("");
|
||||
secondStationItem.setVisibility(View.VISIBLE);
|
||||
thirdStationItem.showOrHideStationArrowBg(false);
|
||||
|
||||
if (arrivingOrArrivedIndex == 0 || arrivingOrArrivedIndex -1 == 0
|
||||
|| (arrivingOrArrivedIndex -2 == 0 && stationList.size() == 3)){
|
||||
firstStationItem.setStationTag(getResources().getString(R.string.bus_station_txt_tag_start));
|
||||
}else {
|
||||
mSwitchLine.setVisibility(View.GONE);
|
||||
firstStationItem.setStationTag("");
|
||||
}
|
||||
|
||||
if (arrivingOrArrivedIndex + 1 == stationList.size() - 1 || arrivingOrArrivedIndex == stationList.size() - 1
|
||||
|| (arrivingOrArrivedIndex == 0 && arrivingOrArrivedIndex + 2 == stationList.size() - 1)){ //确认是否显示 "终"
|
||||
thirdStationItem.setStationTag(getResources().getString(R.string.bus_station_txt_tag_end));
|
||||
}else {
|
||||
thirdStationItem.setStationTag("");
|
||||
}
|
||||
|
||||
//圆点: 0:灰色 过站 1:绿色 到站或者即将到站 2:蓝色:未到站
|
||||
if (arrivingOrArrivedIndex == 0 && isArrived){
|
||||
firstStationItem.setStationNameColor(getResources().getColor(R.color.bus_line_station_color_selected));
|
||||
secondStationItem.setStationNameColor(getResources().getColor(R.color.bus_arrived_station_name_text_color));
|
||||
thirdStationItem.setStationNameColor(getResources().getColor(R.color.bus_arrived_station_name_text_color));
|
||||
|
||||
firstStationItem.setStationName(stationList.get(0).getName());
|
||||
secondStationItem.setStationName(stationList.get(1).getName());
|
||||
thirdStationItem.setStationName(stationList.get(2).getName());
|
||||
|
||||
firstStationItem.setStationPointBg(1);
|
||||
secondStationItem.setStationPointBg(2);
|
||||
thirdStationItem.setStationPointBg(2);
|
||||
|
||||
firstStationItem.setStationArrowBg(2);
|
||||
secondStationItem.setStationArrowBg(2);
|
||||
|
||||
}else if (arrivingOrArrivedIndex == stationList.size() - 1){
|
||||
firstStationItem.setStationNameColor(getResources().getColor(R.color.bus_station_tag_txt_un_color));
|
||||
secondStationItem.setStationNameColor(getResources().getColor(R.color.bus_station_tag_txt_un_color));
|
||||
thirdStationItem.setStationNameColor(getResources().getColor(R.color.bus_line_station_color_selected));
|
||||
|
||||
firstStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -2).getName());
|
||||
secondStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -1).getName());
|
||||
thirdStationItem.setStationName(stationList.get(arrivingOrArrivedIndex).getName());
|
||||
|
||||
firstStationItem.setStationPointBg(0);
|
||||
secondStationItem.setStationPointBg(0);
|
||||
thirdStationItem.setStationPointBg(1);
|
||||
|
||||
firstStationItem.setStationArrowBg(0);
|
||||
if (isArrived){
|
||||
secondStationItem.setStationArrowBg(0);
|
||||
}else {
|
||||
secondStationItem.setStationArrowBg(1);
|
||||
}
|
||||
|
||||
}else {
|
||||
firstStationItem.setStationNameColor(getResources().getColor(R.color.bus_station_tag_txt_un_color));
|
||||
secondStationItem.setStationNameColor(getResources().getColor(R.color.bus_line_station_color_selected));
|
||||
thirdStationItem.setStationNameColor(getResources().getColor(R.color.bus_arrived_station_name_text_color));
|
||||
|
||||
firstStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -1).getName());
|
||||
secondStationItem.setStationName(stationList.get(arrivingOrArrivedIndex).getName());
|
||||
thirdStationItem.setStationName(stationList.get(arrivingOrArrivedIndex + 1).getName());
|
||||
|
||||
firstStationItem.setStationPointBg(0);
|
||||
secondStationItem.setStationPointBg(1);
|
||||
thirdStationItem.setStationPointBg(2);
|
||||
|
||||
secondStationItem.setStationArrowBg(2);
|
||||
if (isArrived){
|
||||
firstStationItem.setStationArrowBg(0);
|
||||
}else {
|
||||
firstStationItem.setStationArrowBg(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 只有两个站点的路线
|
||||
* @param stationList
|
||||
* @param arrivingOrArrivedIndex
|
||||
* @param isArrived
|
||||
*/
|
||||
private void updateTwoStationsUI(List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived) {
|
||||
|
||||
secondStationItem.setVisibility(View.GONE);
|
||||
secondStationItem.showOrHideStationArrowBg(false);
|
||||
thirdStationItem.showOrHideStationArrowBg(false);
|
||||
|
||||
firstStationItem.setStationTag(getResources().getString(R.string.bus_station_txt_tag_start));
|
||||
thirdStationItem.setStationTag(getResources().getString(R.string.bus_station_txt_tag_end));
|
||||
|
||||
firstStationItem.setStationName(stationList.get(0).getName());
|
||||
thirdStationItem.setStationName(stationList.get(1).getName());
|
||||
|
||||
//圆点: 0:灰色 过站 1:绿色 到站或者即将到站 2:蓝色:未到站
|
||||
if (arrivingOrArrivedIndex == 0 && isArrived){//到站
|
||||
firstStationItem.setStationNameColor(getResources().getColor(R.color.bus_line_station_color_selected));
|
||||
thirdStationItem.setStationNameColor(getResources().getColor(R.color.bus_arrived_station_name_text_color));
|
||||
firstStationItem.setStationPointBg(1);
|
||||
firstStationItem.setStationArrowBg(2);
|
||||
thirdStationItem.setStationPointBg(0);
|
||||
|
||||
}else {
|
||||
firstStationItem.setStationNameColor(getResources().getColor(R.color.bus_station_tag_txt_un_color));
|
||||
thirdStationItem.setStationNameColor(getResources().getColor(R.color.bus_line_station_color_selected));
|
||||
if (isArrived){ //到终点
|
||||
firstStationItem.setStationPointBg(0);
|
||||
firstStationItem.setStationArrowBg(0);
|
||||
thirdStationItem.setStationPointBg(1);
|
||||
|
||||
}else { //到终点途中
|
||||
firstStationItem.setStationPointBg(0);
|
||||
firstStationItem.setStationArrowBg(1);
|
||||
thirdStationItem.setStationPointBg(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showOrHideSwitchLineBtn(boolean isShow) {
|
||||
if (isShow){//显示切换路线
|
||||
mSwitchLine.setTag(0);
|
||||
mSwitchLine.setText(getResources().getString(R.string.bus_switch_line_btn));
|
||||
}else {//显示结束路线
|
||||
mSwitchLine.setTag(1);
|
||||
mSwitchLine.setText(getResources().getString(R.string.bus_close_line_btn));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +406,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
if (isAnimateRunning){
|
||||
stopAutopilotAnimation();
|
||||
}
|
||||
mPresenter.autoDriveToNextStation(false);
|
||||
mPresenter.autoDriveToNextStation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,40 +420,19 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChangeOperationStatus() {
|
||||
super.onChangeOperationStatus();
|
||||
mPresenter.onChangeOperationStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改经营状态
|
||||
*
|
||||
* @param launch true-收车,false-出车
|
||||
*/
|
||||
public void changeOperationStatus(boolean launch) {
|
||||
isOperationStatus = launch;
|
||||
if (launch) {
|
||||
// 出车的时候重制站点状态
|
||||
mPresenter.queryBusRoutes();
|
||||
tvOperationStatus.setText("收车");
|
||||
showPanel();
|
||||
} else {
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已收车");
|
||||
tvOperationStatus.setText("出车");
|
||||
hideSlidePanel();
|
||||
hidPanel();
|
||||
|
||||
//移除起点终点
|
||||
if (null != startStation) {
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
|
||||
, startStation.getLon(),R.raw.star_marker);
|
||||
}
|
||||
if (null != endStation) {
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
}
|
||||
public void clearBusStationsMarkers(){
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG,"clearBusStationsMarkers()");
|
||||
if (null != startStation) {
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
|
||||
, startStation.getLon(),R.raw.star_marker);
|
||||
}
|
||||
if (null != endStation) {
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
}
|
||||
|
||||
//清除鹰眼右下角小地图轨迹
|
||||
CallerSmpManager.clearPolyline();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,7 +472,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
IMogoMarker marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) .addMarker(uuid, options);
|
||||
CenterLine centerLine = CallerHDMapManager.INSTANCE.getCenterLineInfo(
|
||||
longi,lat,-1);
|
||||
if (null != centerLine){ // 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致
|
||||
if (null != centerLine && marker != null) { // 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致 地图未初始化会返回空
|
||||
marker.setRotateAngle(centerLine.getAngle().floatValue());
|
||||
}
|
||||
}
|
||||
@@ -392,12 +508,30 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning1));
|
||||
return;
|
||||
}
|
||||
if (mCurrentStation > 0) {
|
||||
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning2));
|
||||
return;
|
||||
if ((int)mSwitchLine.getTag() == 0){//切换路线
|
||||
Intent intent = new Intent(getContext(), BusSwitchLineActivity.class);
|
||||
startActivity(intent);
|
||||
}else {//结束任务
|
||||
OCHCommitDialog.Builder builder = new OCHCommitDialog.Builder();
|
||||
OCHCommitDialog closeLineConfirmDialog = builder
|
||||
.title(getString(R.string.bus_dialog_title))
|
||||
.tips(getString(R.string.bus_dialog_tips))
|
||||
.confirmStr(getString(R.string.bus_dialog_confirm))
|
||||
.cancelStr(getString(R.string.bus_dialog_cancel))
|
||||
.build(getContext());
|
||||
closeLineConfirmDialog.setClickListener(new OCHCommitDialog.ClickListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
mPresenter.abortTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
closeLineConfirmDialog.dismiss();
|
||||
}
|
||||
});
|
||||
closeLineConfirmDialog.show();
|
||||
}
|
||||
Intent intent = new Intent(getContext(), BusSwitchLineActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,16 @@ import android.content.Context;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.SharedPrefs;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.och.bus.bean.BusQueryLineTaskResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.bus.bean.BusRoutesResponse;
|
||||
import com.mogo.och.bus.callback.IBusLinesCallback;
|
||||
import com.mogo.och.bus.net.BusServiceManager;
|
||||
import com.mogo.och.bus.net.IBusServiceCallback;
|
||||
import com.mogo.och.bus.ui.BusSwitchLineActivity;
|
||||
import com.mogo.och.bus.util.BusSendTripInfoManager;
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -39,7 +43,7 @@ public class BusLineModel {
|
||||
mBusLinesCallback = callback;
|
||||
}
|
||||
public void queryBusLines(){
|
||||
BusServiceManager.getInstance().queryBusLines(mContext, new IBusServiceCallback<BusQueryLinesResponse>() {
|
||||
BusServiceManager.queryBusLines(mContext, new OchCommonServiceCallback<BusQueryLinesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusQueryLinesResponse data) {
|
||||
if (null == data && mBusLinesCallback != null) {
|
||||
@@ -53,7 +57,7 @@ public class BusLineModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
@@ -63,21 +67,52 @@ public class BusLineModel {
|
||||
});
|
||||
}
|
||||
|
||||
public void commitSwitchLineId(int lineId){
|
||||
BusServiceManager.getInstance().resetStationStatus(mContext,lineId, new IBusServiceCallback<BusRoutesResponse>() {
|
||||
/**
|
||||
* 通过线路id 查询线路排班表
|
||||
* @param lineId
|
||||
* @param position 位置
|
||||
*/
|
||||
public void queryBusLineTasksById(int lineId, int position,boolean autoRefresh){
|
||||
BusServiceManager.queryBusTaskByLineId(mContext, String.valueOf(lineId),new OchCommonServiceCallback<BusQueryLineTaskResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusQueryLineTaskResponse data) {
|
||||
if (null == data && mBusLinesCallback != null) {
|
||||
mBusLinesCallback.onBusLineTasks(null,position,autoRefresh);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mBusLinesCallback != null){
|
||||
mBusLinesCallback.onBusLineTasks(data,position,autoRefresh);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
ToastUtils.showShort("查询所有绑定路线失败:"+failMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void commitSwitchLineId(int taskId,int lineId){
|
||||
BusServiceManager.switchLine(mContext,taskId, new OchCommonServiceCallback<BusRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusRoutesResponse o) {
|
||||
SharedPrefs.getInstance(mContext).putInt(BusSwitchLineActivity.LASTCOMMITLINEID,lineId);
|
||||
if (mBusLinesCallback != null){
|
||||
mBusLinesCallback.onChangeLineIdSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
ToastUtils.showShort("切换路线失败:"+failMsg);
|
||||
ToastUtils.showShort("选择任务失败:"+failMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
package com.mogo.och.bus.net;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean;
|
||||
import com.mogo.och.bus.bean.BusRoutesResponse;
|
||||
import com.mogo.och.bus.bean.CarHeartbeatReqBean;
|
||||
import com.mogo.och.bus.bean.BusOperationStatusRequest;
|
||||
import com.mogo.och.bus.bean.BusOperationStatusResponse;
|
||||
import com.mogo.och.bus.bean.BusOrdersResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryLineStationsRequest;
|
||||
import com.mogo.och.bus.bean.BusResetDrivingLineRequest;
|
||||
import com.mogo.och.bus.bean.BusUpdateSiteStatusRequest;
|
||||
import com.mogo.och.bus.bean.QueryLeaveAwayPassengersRequest;
|
||||
import com.mogo.och.bus.bean.QueryLeaveAwayPassengersResponse;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
import com.mogo.och.bus.model.BusOrderModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
public class BusServiceManager {
|
||||
|
||||
private static final String TAG = BusServiceManager.class.getSimpleName();
|
||||
|
||||
private final IBusApiService mService;
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final BusServiceManager INSTANCE = new BusServiceManager();
|
||||
}
|
||||
|
||||
public static BusServiceManager getInstance(){
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private BusServiceManager(){
|
||||
mService = MoGoRetrofitFactory.getInstance(BusConst.getBaseUrl()).create(IBusApiService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小巴车线路
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryBusRoutes(Context context, IBusServiceCallback<BusRoutesResponse> callback) {
|
||||
//获取当前高德坐标
|
||||
|
||||
mService.querySiteByCoordinate(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new BusQueryLineStationsRequest(BusOrderModel.getInstance().mLongitude
|
||||
, BusOrderModel.getInstance().mLatitude,true))
|
||||
.subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( getSubscribeImpl(context,callback,"querySiteByCoordinate"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置线路站点
|
||||
* @param context
|
||||
* @param lineId
|
||||
* @param callback
|
||||
*/
|
||||
public void resetStationStatus(Context context, int lineId, IBusServiceCallback<BusRoutesResponse> callback){
|
||||
mService.resetStationStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),new BusResetDrivingLineRequest(lineId))
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"debugResetStationStatus"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 离站上报
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
public void leaveStation(Context context, int seq, int siteId, IBusServiceCallback<BusRoutesResponse> callback){
|
||||
mService.leaveStation(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusUpdateSiteStatusRequest(seq,siteId, BusOrderModel.getInstance().mLongitude
|
||||
, BusOrderModel.getInstance().mLatitude))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"leaveStation"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 到站更新站点状态
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
public void arriveSiteStation(Context context, int seq, int siteId, IBusServiceCallback<BaseData> callback){
|
||||
mService.arriveSiteStation(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusUpdateSiteStatusRequest(seq,siteId
|
||||
, BusOrderModel.getInstance().mLongitude, BusOrderModel.getInstance().mLatitude))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"leaveStation"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询下车乘客
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
public void queryStationLeaveAwayPassengers(Context context, int seq, int siteId
|
||||
, IBusServiceCallback<QueryLeaveAwayPassengersResponse> callback){
|
||||
mService.queryStationLeaveAwayPassengers( MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),new QueryLeaveAwayPassengersRequest(seq,siteId))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryStationLeaveAwayPassengers"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 收车
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void stopTakeOrder(Context context, IBusServiceCallback<BaseData> callback){
|
||||
mService.stopTakeOrder(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusOperationStatusRequest(BusOrderModel.getInstance().mLongitude
|
||||
, BusOrderModel.getInstance().mLatitude))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"stopTakeOrder"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 出车
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void startTakeOrder(Context context, IBusServiceCallback<BaseData> callback){
|
||||
mService.startTakeOrder(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusOperationStatusRequest(BusOrderModel.getInstance().mLongitude
|
||||
, BusOrderModel.getInstance().mLatitude))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"startTakeOrder"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出车/收车状态
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOperationStatus(Context context, IBusServiceCallback<BusOperationStatusResponse> callback){
|
||||
mService.queryOperationStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryOperationStatus"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小巴车订单
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryBusOrders(Context context, IBusServiceCallback<BusOrdersResponse> callback){
|
||||
mService.queryBusOrders(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryBusOrders"));
|
||||
}
|
||||
|
||||
public void queryBusLines(Context context, IBusServiceCallback<BusQueryLinesResponse> callback){
|
||||
mService.queryBusLines(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryBusLines"));
|
||||
}
|
||||
|
||||
public void updateOrderRoute(Context context,int lineId, int startSiteId, int endSiteId
|
||||
, List< BusRoutePlanningUpdateReqBean.Result > points
|
||||
, IBusServiceCallback<BaseData> callback){
|
||||
mService.updateOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusRoutePlanningUpdateReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
,lineId,startSiteId,endSiteId, points))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"updateOrderRoute"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
|
||||
* @param context
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @param callback
|
||||
*/
|
||||
public void runCarHeartbeat(Context context, double lon, double lat,
|
||||
IBusServiceCallback<BaseData> callback) {
|
||||
mService.runCarHeartbeat(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),new CarHeartbeatReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), lon, lat))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "runCarHeartbeat"));
|
||||
}
|
||||
|
||||
private <T extends BaseData> SubscribeImpl getSubscribeImpl(Context context, IBusServiceCallback<T> callback, String apiName){
|
||||
return new SubscribeImpl<T>(RequestOptions.create(context)){
|
||||
@Override
|
||||
public void onSuccess(T o) {
|
||||
super.onSuccess(o);
|
||||
CallerLogger.INSTANCE.e(M_BUS + TAG,apiName + ": onSuccess() " + o.msg);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
CallerLogger.INSTANCE.e(M_BUS + TAG,apiName + ": onError() " +"msg="+ message+" code="+code);
|
||||
if (callback != null) {
|
||||
callback.onFail("msg="+ message+" code="+code);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
CallerLogger.INSTANCE.e(M_BUS + TAG,apiName + ": onError() " +" e="+e.getMessage());
|
||||
if (callback != null) {
|
||||
callback.onFail(e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.mogo.och.bus.net
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.och.bus.constant.BusConst.Companion.getBaseUrl
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.och.bus.bean.*
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl
|
||||
import com.mogo.och.common.module.biz.network.interceptor.transformTry
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
object BusServiceManager {
|
||||
|
||||
private val mService: IBusApiService = MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
|
||||
IBusApiService::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 查询小巴车当前任务
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusRoutes(context: Context, callback: OchCommonServiceCallback<BusRoutesResponse>?) {
|
||||
//获取当前高德坐标
|
||||
mService.queryBusRoutes(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusQueryLineStationsRequest()
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusRoutes"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置线路站点
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun switchLine(
|
||||
context: Context,
|
||||
taskId: Int,
|
||||
callback: OchCommonServiceCallback<BusRoutesResponse>?
|
||||
) {
|
||||
mService.switchLine(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusResetDrivingLineRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "switchLine"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 中断当前任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun abortTask(context: Context, taskId: Int, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
mService.abortTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "abortTask"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常结束任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun endTask(context: Context, taskId: Int, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
mService.endTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "endTask"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 离站上报
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun leaveStation(
|
||||
context: Context,
|
||||
seq: Int,
|
||||
siteId: Int,
|
||||
taskId: Int,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.leaveStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "leaveStation"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 到站更新站点状态
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun arriveSiteStation(
|
||||
context: Context, seq: Int, siteId: Int, taskId: Int,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.arriveSiteStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询下车乘客
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryStationLeaveAwayPassengers(
|
||||
context: Context,
|
||||
seq: Int,
|
||||
siteId: Int,
|
||||
callback: OchCommonServiceCallback<QueryLeaveAwayPassengersResponse>?
|
||||
) {
|
||||
mService.queryStationLeaveAwayPassengers(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
QueryLeaveAwayPassengersRequest(seq, siteId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryStationLeaveAwayPassengers"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前到站点核销乘客
|
||||
* @param context
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryStationWriteOffPassengers(
|
||||
context: Context,
|
||||
taskId: Int,
|
||||
siteId: Int,
|
||||
prePassengerTime: Long,
|
||||
callback: OchCommonServiceCallback<BusQueryWriteOffPassengersResponse>?
|
||||
) {
|
||||
mService.queryWriteOffPassengers(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusWriteOffPassengersQueryRequest(taskId, siteId, prePassengerTime)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryStationWriteOffPassengers"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小巴车订单
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusOrders(context: Context, callback: OchCommonServiceCallback<BusOrdersResponse>?) {
|
||||
mService.queryBusOrders(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusOrders"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun queryBusLines(context: Context, callback: OchCommonServiceCallback<BusQueryLinesResponse>?) {
|
||||
mService.queryBusLines(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
context: Context,
|
||||
lineId: String?,
|
||||
callback: OchCommonServiceCallback<BusQueryLineTaskResponse>?
|
||||
) {
|
||||
mService.queryBusTaskByLineId(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
lineId
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun updateOrderRoute(
|
||||
context: Context,
|
||||
lineId: Int,
|
||||
startSiteId: Int,
|
||||
endSiteId: Int,
|
||||
points: List<BusRoutePlanningUpdateReqBean.Result?>?,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.updateOrderRoute(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusRoutePlanningUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, lineId, startSiteId, endSiteId, points
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "updateOrderRoute"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
|
||||
* @param context
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun runCarHeartbeat(
|
||||
context: Context, lon: Double, lat: Double,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.runCarHeartbeat(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
CarHeartbeatReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, lon, lat
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "runCarHeartbeat"))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.mogo.och.bus.net;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.och.bus.bean.BusOperationStatusRequest;
|
||||
import com.mogo.och.bus.bean.BusCloseTaskRequest;
|
||||
import com.mogo.och.bus.bean.BusOrdersResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryWriteOffPassengersResponse;
|
||||
import com.mogo.och.bus.bean.BusWriteOffPassengersQueryRequest;
|
||||
import com.mogo.och.bus.bean.BusQueryLineTaskResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean;
|
||||
import com.mogo.och.bus.bean.BusRoutesResponse;
|
||||
import com.mogo.och.bus.bean.CarHeartbeatReqBean;
|
||||
import com.mogo.och.bus.bean.BusQueryLineStationsRequest;
|
||||
import com.mogo.och.bus.bean.BusOperationStatusResponse;
|
||||
import com.mogo.och.bus.bean.QueryLeaveAwayPassengersRequest;
|
||||
import com.mogo.och.bus.bean.QueryLeaveAwayPassengersResponse;
|
||||
import com.mogo.och.bus.bean.BusResetDrivingLineRequest;
|
||||
@@ -39,19 +41,16 @@ public interface IBusApiService {
|
||||
// @POST( "/autopilot-car-hailing/line/v2/lineDataWithDriver/query" )
|
||||
@POST( "/autopilot-car-hailing/line/v2/driver/bus/lineDataWithDriver/query" )
|
||||
// @POST( "/mock/268/autopilot-car-hailing/bus/api/lineDataWithDriver/query" )
|
||||
Observable<BusRoutesResponse> querySiteByCoordinate(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request);
|
||||
Observable<BusRoutesResponse> queryBusRoutes(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request);
|
||||
|
||||
/**
|
||||
* 重置巴士路线: 点击小巴车tab 或者出车后会使用
|
||||
*
|
||||
* @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的
|
||||
* @return 返回值是重置后的车站列表
|
||||
* 开始路线
|
||||
*/
|
||||
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
|
||||
// @POST( "/autopilot-car-hailing/car/v2/bus/drivingLine/reset" )
|
||||
@POST( "/autopilot-car-hailing/car/v2/driver/bus/drivingLine/reset" )
|
||||
// @POST( "/mock/268/autopilot-car-hailing/bus/api/drivingLine/reset" )
|
||||
Observable<BusRoutesResponse> resetStationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request);
|
||||
@POST( "/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startTask" )
|
||||
Observable<BusRoutesResponse> switchLine(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request);
|
||||
|
||||
/**
|
||||
* 离站,通知服务器
|
||||
@@ -60,9 +59,10 @@ public interface IBusApiService {
|
||||
*/
|
||||
@Headers({"Content-Type:application/json;charset=UTF-8"})
|
||||
// @POST("/autopilot-car-hailing/car/v2/bus/driving/away")
|
||||
@POST("/autopilot-car-hailing/car/v2/driver/bus/driving/away")
|
||||
// @POST("/autopilot-car-hailing/car/v2/driver/bus/driving/away")
|
||||
@POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/leave")
|
||||
// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/away")
|
||||
Observable<BusRoutesResponse> leaveStation(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusUpdateSiteStatusRequest request);
|
||||
Observable<BaseData> leaveStation(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusUpdateSiteStatusRequest request);
|
||||
|
||||
/**
|
||||
* 到站 更新到站信息
|
||||
@@ -71,7 +71,8 @@ public interface IBusApiService {
|
||||
*/
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
// @POST("/autopilot-car-hailing/order/v2/bus/driving/attachSite")
|
||||
@POST("/autopilot-car-hailing/order/v2/driver/bus/driving/attachSite")
|
||||
// @POST("/autopilot-car-hailing/order/v2/driver/bus/driving/attachSite")
|
||||
@POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/arrive")
|
||||
// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/attachSite")
|
||||
Observable< BaseData > arriveSiteStation(@Header ("appId") String appId,@Header("ticket") String ticket,@Body BusUpdateSiteStatusRequest request);
|
||||
|
||||
@@ -87,39 +88,6 @@ public interface IBusApiService {
|
||||
// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/siteArrivedOrders")
|
||||
Observable< QueryLeaveAwayPassengersResponse > queryStationLeaveAwayPassengers(@Header ("appId") String appId,@Header("ticket") String ticket,@Body QueryLeaveAwayPassengersRequest request);
|
||||
|
||||
/**
|
||||
* 出车
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
// @POST("/autopilot-car-hailing/car/v2/bus/startTakeOrder")
|
||||
@POST("/autopilot-car-hailing/car/v2/driver/bus/startTakeOrder")
|
||||
// @POST("/mock/268/autopilot-car-hailing/bus/api/startTakeOrder")
|
||||
Observable<BaseData> startTakeOrder(@Header ("appId") String appId,@Header("ticket") String ticket,@Body BusOperationStatusRequest request);
|
||||
|
||||
/**
|
||||
* 收车
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
// @POST("/autopilot-car-hailing/car/v2/bus/stopTakeOrder")
|
||||
@POST("/autopilot-car-hailing/car/v2/driver/bus/stopTakeOrder")
|
||||
// @POST("/mock/268/autopilot-car-hailing/bus/api/stopTakeOrder")
|
||||
Observable<BaseData> stopTakeOrder(@Header ("appId") String appId,@Header("ticket") String ticket,@Body BusOperationStatusRequest request);
|
||||
|
||||
/**
|
||||
* 查询小巴出车/收车状态
|
||||
* @param sn
|
||||
* @return
|
||||
*/
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
// @GET("/autopilot-car-hailing/car/v2/bus/takeOrderStatus/query")
|
||||
@GET("/autopilot-car-hailing/car/v2/driver/bus/takeOrderStatus/query")
|
||||
// @GET("/mock/268/autopilot-car-hailing/bus/api/takeOrderStatus/query")
|
||||
Observable<BusOperationStatusResponse> queryOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
|
||||
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
// @GET("/autopilot-car-hailing/order/v2/bus/servicingOrders/query")
|
||||
@GET("/autopilot-car-hailing/order/v2/driver/bus/servicingOrders/query")
|
||||
@@ -143,12 +111,54 @@ public interface IBusApiService {
|
||||
* @param sn
|
||||
* @return
|
||||
*/
|
||||
// @GET("/autopilot-car-hailing/line/v2/driver/bindLine/query")
|
||||
@GET("/autopilot-car-hailing/line/v2/driver/bus/bindLine/query")
|
||||
Observable<BusQueryLinesResponse> queryBusLines(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
|
||||
|
||||
/**
|
||||
* 查询路线当天的任务
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param lineId 线路id
|
||||
* @return
|
||||
*/
|
||||
@GET("/autopilot-car-hailing/line/v2/driver/bus/task/query")
|
||||
Observable<BusQueryLineTaskResponse> queryBusTaskByLineId(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("lineId") String lineId);
|
||||
|
||||
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
@POST( "/autopilot-car-hailing/location/v2/driver/bus/saveLineCoordinate" )
|
||||
Observable<BaseData> updateOrderRoute(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusRoutePlanningUpdateReqBean data);
|
||||
|
||||
/**
|
||||
* 中止任务
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/abortTask")
|
||||
Observable<BaseData> abortTask(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusCloseTaskRequest data);
|
||||
|
||||
/**
|
||||
* 任务正常跑完结束
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
@POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endTask")
|
||||
Observable<BaseData> endTask(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusCloseTaskRequest data);
|
||||
|
||||
/**
|
||||
* 任务正常跑完结束
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
@POST("/autopilot-car-hailing/operation/v1/driver/order/verificationResult")
|
||||
Observable<BusQueryWriteOffPassengersResponse> queryWriteOffPassengers(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusWriteOffPassengersQueryRequest data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mogo.och.bus.net;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
public interface IBusServiceCallback< T >{
|
||||
void onSuccess(T o);
|
||||
|
||||
void onFail(String failMsg);
|
||||
|
||||
default void onError() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,18 +7,26 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.bus.bean.BusQueryLineTaskResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.bus.callback.IBusLinesCallback;
|
||||
import com.mogo.och.bus.model.BusLineModel;
|
||||
import com.mogo.och.bus.model.BusOrderModel;
|
||||
import com.mogo.och.bus.ui.BusSwitchLineView;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/2/9
|
||||
*/
|
||||
public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IBusLinesCallback {
|
||||
|
||||
private Disposable subscribe;
|
||||
|
||||
public BusLinePresenter(BusSwitchLineView view) {
|
||||
super(view);
|
||||
BusLineModel.getInstance().init();
|
||||
@@ -53,6 +61,7 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
|
||||
@Override
|
||||
public void onChangeLineIdSuccess() {
|
||||
BusOrderModel.getInstance().clearBusStationDatas();
|
||||
runOnUIThread(() -> mView.onChangeLineIdSuccess());
|
||||
}
|
||||
|
||||
@@ -60,8 +69,21 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
BusLineModel.getInstance().queryBusLines();
|
||||
}
|
||||
|
||||
public void commitSwitchLineId(int lineId){
|
||||
BusLineModel.getInstance().commitSwitchLineId(lineId);
|
||||
public void queryBusLineTasks(int lineId, int position,boolean close){
|
||||
if(subscribe!=null&&!subscribe.isDisposed()){
|
||||
subscribe.dispose();
|
||||
}
|
||||
if(close){
|
||||
return;
|
||||
}
|
||||
BusLineModel.getInstance().queryBusLineTasksById(lineId,position,false);
|
||||
subscribe = Observable.interval(3, TimeUnit.MINUTES).subscribe(aLong -> {
|
||||
BusLineModel.getInstance().queryBusLineTasksById(lineId,position,true);
|
||||
});
|
||||
}
|
||||
|
||||
public void commitSwitchLineId(int taskId,int lineId){
|
||||
BusLineModel.getInstance().commitSwitchLineId(taskId,lineId);
|
||||
}
|
||||
|
||||
public void removeListener(){
|
||||
@@ -75,5 +97,14 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
@Override
|
||||
public void onDestroy(@NonNull LifecycleOwner owner) {
|
||||
super.onDestroy(owner);
|
||||
if(subscribe!=null&&!subscribe.isDisposed()){
|
||||
subscribe.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBusLineTasks(BusQueryLineTaskResponse o, int position,boolean autoRefresh) {
|
||||
mView.onBusLineTasks(o,position,autoRefresh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.mogo.och.bus.presenter;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
|
||||
import static com.mogo.och.bus.constant.BusConst.LOOP_DELAY_500;
|
||||
import static com.mogo.och.bus.constant.BusConst.LOOP_PASSENGER_5S;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
@@ -31,6 +33,28 @@ public class BusModelLoopManager {
|
||||
}
|
||||
|
||||
private Disposable mHeartbeatDisposable; //心跳轮询
|
||||
private Disposable mQueryPassengerDisposable; //查询核销乘客
|
||||
|
||||
public void startQueryPassengerWriteOffLoop() {
|
||||
if (mQueryPassengerDisposable != null && !mQueryPassengerDisposable.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.i(M_BUS + TAG, "startQueryPassengerWriteOffLoop()");
|
||||
mQueryPassengerDisposable = Observable.interval(LOOP_DELAY_500,
|
||||
LOOP_PASSENGER_5S, TimeUnit.MILLISECONDS)
|
||||
.map((aLong -> aLong + 1))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> BusOrderModel.getInstance().queryPassengerWriteOff());
|
||||
}
|
||||
|
||||
public void stopQueryPassengerWriteOffLoop() {
|
||||
if (mQueryPassengerDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_BUS + TAG, "stopQueryPassengerWriteOffLoop()");
|
||||
mQueryPassengerDisposable.dispose();
|
||||
mQueryPassengerDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void startHeartbeatLoop() {
|
||||
if (mHeartbeatDisposable != null && !mHeartbeatDisposable.isDisposed()) {
|
||||
|
||||
@@ -9,21 +9,32 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.bus.R;
|
||||
import com.mogo.och.bus.bean.BusStationBean;
|
||||
import com.mogo.och.bus.callback.ICarOperationStatusCallback;
|
||||
import com.mogo.och.bus.bean.WriteOffPassenger;
|
||||
import com.mogo.och.bus.callback.IBusADASStatusCallback;
|
||||
import com.mogo.och.bus.callback.IBusControllerStatusCallback;
|
||||
import com.mogo.och.bus.callback.IPassengerCallback;
|
||||
import com.mogo.och.bus.callback.IRefreshBusStationsCallback;
|
||||
import com.mogo.och.bus.callback.ISlidePannelHideCallback;
|
||||
import com.mogo.och.bus.fragment.BusFragment;
|
||||
import com.mogo.och.bus.model.BusOrderModel;
|
||||
import com.mogo.och.bus.util.BusTrajectoryManager;
|
||||
import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean;
|
||||
import com.mogo.och.common.module.biz.callback.ILoginCallback;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.utils.SoundPoolHelper;
|
||||
import com.mogo.och.common.module.voice.VoiceNotice;
|
||||
import com.zhidao.socket.utils.LoginStatusUtil;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -40,27 +51,26 @@ import system_master.SystemStatusInfo;
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class BusPresenter extends Presenter<BusFragment>
|
||||
implements ICarOperationStatusCallback, IRefreshBusStationsCallback, ISlidePannelHideCallback
|
||||
, IMoGoAutopilotStatusListener, IBusControllerStatusCallback {
|
||||
implements IRefreshBusStationsCallback, ISlidePannelHideCallback
|
||||
, IMoGoAutopilotStatusListener, IBusControllerStatusCallback, ILoginCallback, IPassengerCallback, IBusADASStatusCallback {
|
||||
|
||||
private static final String TAG = "BusPresenter";
|
||||
|
||||
private int currentAutopilotStatus = -1;
|
||||
private List<BusStationBean> mStationList = new ArrayList<>();
|
||||
private int mCurrentStation = 0;
|
||||
private boolean isRestartAutopilot = false;
|
||||
|
||||
public BusPresenter(BusFragment view) {
|
||||
super(view);
|
||||
//2021.11.1 鹰眼架构整合,由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
BusOrderModel.getInstance().init();
|
||||
OCHAdasAbilityManager.getInstance().init(AbsMogoApplication.getApp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NonNull LifecycleOwner owner) {
|
||||
super.onCreate(owner);
|
||||
BusOrderModel.getInstance().queryOperationStatus();
|
||||
BusOrderModel.getInstance().queryBusRoutes();
|
||||
initModelListener();
|
||||
}
|
||||
@@ -73,86 +83,85 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
}
|
||||
|
||||
public void initModelListener() {
|
||||
BusOrderModel.getInstance().setCarOperationStatusCallback(this);
|
||||
BusOrderModel.getInstance().setRefreshBusStationsCallback(this);
|
||||
BusOrderModel.getInstance().setSlidePannelHideCallback(this);
|
||||
BusOrderModel.getInstance().setSlidePanelHideCallback(this);
|
||||
BusOrderModel.getInstance().setControllerStatusCallback(this);
|
||||
BusOrderModel.getInstance().setPassengerCallback(this);
|
||||
BusOrderModel.getInstance().setAdasStatusCallback(this);
|
||||
}
|
||||
|
||||
public void releaseListener() {
|
||||
BusOrderModel.getInstance().setCarOperationStatusCallback(null);
|
||||
BusOrderModel.getInstance().setRefreshBusStationsCallback(null);
|
||||
BusOrderModel.getInstance().setSlidePannelHideCallback(null);
|
||||
BusOrderModel.getInstance().setSlidePanelHideCallback(null);
|
||||
BusOrderModel.getInstance().setControllerStatusCallback(null);
|
||||
BusOrderModel.getInstance().setPassengerCallback(null);
|
||||
BusOrderModel.getInstance().setAdasStatusCallback(null);
|
||||
OCHAdasAbilityManager.getInstance().release();
|
||||
}
|
||||
|
||||
public void queryBusRoutes() {
|
||||
BusOrderModel.getInstance().queryBusRoutes();
|
||||
public void abortTask() {
|
||||
BusOrderModel.getInstance().abortTask();
|
||||
}
|
||||
|
||||
public void debugResetStationStatus() {
|
||||
BusOrderModel.getInstance().debugResetStationStatus();
|
||||
}
|
||||
|
||||
public void autoDriveToNextStation(boolean isRestart) {
|
||||
public void autoDriveToNextStation() {
|
||||
currentAutopilotStatus = -1;
|
||||
BusOrderModel.getInstance().autoDriveToNextStation(isRestart);
|
||||
isRestartAutopilot = false;
|
||||
BusOrderModel.getInstance().autoDriveToNextStation();
|
||||
// isRestartAutopilot = false;
|
||||
}
|
||||
|
||||
public void restartAutopilot() {
|
||||
if (BusOrderModel.getInstance().isGoingToNextStation()){
|
||||
currentAutopilotStatus = -1;
|
||||
BusOrderModel.getInstance().restartAutopilot();
|
||||
isRestartAutopilot = true;
|
||||
// isRestartAutopilot = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void onChangeOperationStatus() {
|
||||
BusOrderModel.getInstance().onChangeOperationStatus();
|
||||
// 登出
|
||||
public void logout() {
|
||||
BusOrderModel.getInstance().logout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeOperationStatus(boolean changeStatus) {
|
||||
if (mView != null) {
|
||||
runOnUIThread(() -> mView.changeOperationStatus(changeStatus));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshBusStations(String lineName,List<BusStationBean> stationList
|
||||
, int currentStation, int nextStation, boolean isArrived) {
|
||||
public void updateBusTaskStatus(String lineName,String lineTime,
|
||||
List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived) {
|
||||
mStationList.clear();
|
||||
mStationList.addAll(stationList);
|
||||
mCurrentStation = currentStation;
|
||||
// functionDemoModeChange();
|
||||
if (arrivingOrArrivedIndex == 0 || isArrived){
|
||||
mCurrentStation = arrivingOrArrivedIndex;
|
||||
}else {
|
||||
mCurrentStation = arrivingOrArrivedIndex -1;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel =", " mCurrentStation =" + mCurrentStation);
|
||||
if (mView != null) {
|
||||
runOnUIThread(() -> mView.refreshBusStations(lineName,
|
||||
stationList, currentStation, nextStation, isArrived));
|
||||
runOnUIThread(() -> mView.updateBusTaskStatus(lineName,lineTime,
|
||||
stationList, arrivingOrArrivedIndex, isArrived));
|
||||
}
|
||||
}
|
||||
|
||||
private void functionDemoModeChange() {
|
||||
// CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel ="," functionDemoModeChange ="+mCurrentStation);
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& ((mCurrentStation > 0 && mCurrentStation < mStationList.size() - 1)
|
||||
|| ((mCurrentStation == 0 || mCurrentStation == mStationList.size() - 1)
|
||||
&& BusOrderModel.getInstance().isGoingToNextStation()))) {
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING));
|
||||
}
|
||||
@Override
|
||||
public void updateEmptyUi() {
|
||||
runOnUIThread(() -> mView.updateLineEmptyUI());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBusStationsMarkers() {
|
||||
runOnUIThread(() -> mView.clearBusStationsMarkers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideSlidePanel() {
|
||||
if (mView != null) {
|
||||
runOnUIThread(() -> mView.hideSlidePanel());
|
||||
runOnUIThread(()-> mView.setArrivedClikable(true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(MessagePad.ArrivalNotification arrivalNotification) {
|
||||
CallerLogger.INSTANCE.e( M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive");
|
||||
BusOrderModel.getInstance().onArriveAt(arrivalNotification);
|
||||
}
|
||||
|
||||
@@ -169,62 +178,51 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
switch (state) {
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE:
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
if (currentAutopilotStatus == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {//2-->1语音提示
|
||||
// AIAssist.getInstance( getContext() ).speakTTSVoice( "已进入人工驾驶模式" );
|
||||
}
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE;
|
||||
// 设置UI【自动驾驶】按钮是否展示
|
||||
runOnUIThread(() -> mView.onAutopilotEnableChange(true));
|
||||
if (BusOrderModel.getInstance().isGoingToNextStation()) {
|
||||
runOnUIThread(() -> mView.hideSlidePanel());
|
||||
}
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation > 0 && mCurrentStation < mStationList.size() - 1)
|
||||
|| (
|
||||
(mCurrentStation == 0 || mCurrentStation == mStationList.size() - 1)
|
||||
&& BusOrderModel.getInstance().isGoingToNextStation()
|
||||
)
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
}
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& BusOrderModel.getInstance().isGoingToNextStation()
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE;
|
||||
}
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING;
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
BusOrderModel.getInstance().triggerStartServiceEvent(
|
||||
isRestartAutopilot, true);
|
||||
BusOrderModel.getInstance().isRestartAutopilot(), true);
|
||||
}
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
if (currentAutopilotStatus == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {//2-->0语音提示
|
||||
// AIAssist.getInstance( getContext() ).speakTTSVoice( "自动驾驶已停止,请人工接管" );
|
||||
}
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE;
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation > 0 && mCurrentStation < mStationList.size() - 1)
|
||||
|| (
|
||||
(mCurrentStation == 0 || mCurrentStation == mStationList.size() - 1)
|
||||
&& BusOrderModel.getInstance().isGoingToNextStation()
|
||||
)
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
runOnUIThread(() -> {
|
||||
mView.onAutopilotStatusChanged(currentAutopilotStatus);
|
||||
});
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& BusOrderModel.getInstance().isGoingToNextStation()
|
||||
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE;
|
||||
}
|
||||
runOnUIThread(() -> {
|
||||
mView.onAutopilotStatusChanged(currentAutopilotStatus);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
runOnUIThread(() -> mView.onAutopilotEnableChange(false));
|
||||
@@ -285,4 +283,40 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void loginSuccess(DriverStatusQueryRespBean data) {
|
||||
if(LoginStatusUtil.isLogin()){
|
||||
BusOrderModel.getInstance().startOrStopOrderLoop(true);
|
||||
}else {
|
||||
BusTrajectoryManager.getInstance().stopTrajReqLoop();
|
||||
BusOrderModel.getInstance().startOrStopOrderLoop(false);
|
||||
BusTrajectoryManager.getInstance().stopTrajReqLoop();
|
||||
clearBusStationsMarkers();
|
||||
mView.hideSlidePanel();
|
||||
BusOrderModel.getInstance().closeBeautificationMode();
|
||||
}
|
||||
BusOrderModel.getInstance().queryBusRoutes();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginFail(boolean isLogin) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playPassenger(WriteOffPassenger passenger) {
|
||||
int passengerNum = passenger.passengerSize;
|
||||
if (passengerNum > 1){ //多人播报 "x人" ---》x人核验通过
|
||||
VoiceNotice.showNotice(passengerNum+"人核验通过", AIAssist.LEVEL3);
|
||||
}else { //是 1 播放 "滴" 2022.11.09 改为: "核验通过"
|
||||
// mView.playDI();
|
||||
VoiceNotice.showNotice("核验通过", AIAssist.LEVEL3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartAdasFailure() {
|
||||
runOnUIThread(() -> mView.stopAnimAndUpdateBtnStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.mogo.och.bus.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.mogo.och.bus.R
|
||||
import com.mogo.och.common.module.utils.BlinkAnimationUtil
|
||||
import kotlinx.android.synthetic.main.bus_stations_common_item.view.*
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/9/15
|
||||
*/
|
||||
class BusStationCommonItem @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr){
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.bus_stations_common_item,this,true)
|
||||
}
|
||||
|
||||
fun setStationName(name: String){
|
||||
busStationNameTv.text = name
|
||||
}
|
||||
|
||||
fun setStationNameColor(color: Int){
|
||||
busStationNameTv.setTextColor(color)
|
||||
}
|
||||
|
||||
fun setStationPointBg(type: Int) { // 0:灰色 过站 1:绿色 到站或者即将到站 2:蓝色:未到站
|
||||
BlinkAnimationUtil.clearAnimation(busCircleIv)
|
||||
when (type) {
|
||||
0 -> {
|
||||
busCircleIvBg.visibility = GONE
|
||||
busCircleIv.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.icon_point_grey_bus
|
||||
)
|
||||
)
|
||||
}
|
||||
1 -> {
|
||||
busCircleIvBg.visibility = VISIBLE
|
||||
busCircleIv.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.icon_point_green_bus
|
||||
)
|
||||
)
|
||||
BlinkAnimationUtil.setAnimation(busCircleIv)
|
||||
}
|
||||
2 -> {
|
||||
busCircleIvBg.visibility = GONE
|
||||
busCircleIv.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.icon_point_blue_bus
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun getCircleImageView() : ImageView{
|
||||
return busCircleIv
|
||||
}
|
||||
|
||||
fun setStationArrowBg(type: Int){// 0:灰色 过站 1:绿色 前往下一站 2:蓝色 未到站
|
||||
when(type){
|
||||
0 -> busArrowBg.setImageResource(R.drawable.icon_arrow_grey_bus)
|
||||
1 -> busArrowBg.setImageResource(R.drawable.icon_arrow_green_bus)
|
||||
2 -> busArrowBg.setImageResource(R.drawable.icon_arrow_blue_bus)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun setStationTag(tag: String){ // 0:起 1:终
|
||||
if (tag.isNullOrEmpty()){
|
||||
busTagTxt.visibility = GONE
|
||||
}else{
|
||||
busTagTxt.text = tag
|
||||
busTagTxt.visibility = VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
fun showOrHideStationArrowBg(isShow:Boolean){
|
||||
if (isShow){
|
||||
busArrowBg.visibility = VISIBLE
|
||||
}else{
|
||||
busArrowBg.visibility = GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,299 +0,0 @@
|
||||
package com.mogo.och.bus.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.commons.mvp.MvpActivity;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.och.bus.R;
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.bus.presenter.BusLinePresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/2/8
|
||||
*/
|
||||
public class BusSwitchLineActivity extends MvpActivity<BusSwitchLineView, BusLinePresenter>
|
||||
implements View.OnClickListener, BusSwitchLineView {
|
||||
|
||||
private ImageView mClose;
|
||||
private ConstraintLayout mNoDatasView;
|
||||
private RecyclerView mLinesListView;
|
||||
private TextView mLineCommitBtn;
|
||||
private SwitchLineAdapter mAdapter;
|
||||
private List<BusQueryLinesResponse.Result> mData = new ArrayList<>();
|
||||
private int mSelectLineId = -1;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_bus_switch_line;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected BusLinePresenter createPresenter() {
|
||||
return new BusLinePresenter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
initWH();
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initDatas();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化view
|
||||
*/
|
||||
private void initView() {
|
||||
mClose = findViewById(R.id.switch_line_close);
|
||||
mClose.setOnClickListener(this);
|
||||
mNoDatasView = findViewById(R.id.no_order_data_view);
|
||||
|
||||
mLineCommitBtn = findViewById(R.id.switch_line_btn_commit);
|
||||
mLineCommitBtn.setOnClickListener(this);
|
||||
|
||||
mLinesListView = findViewById(R.id.switch_line_rv);
|
||||
mLinesListView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mAdapter = new SwitchLineAdapter(getApplicationContext(),mData);
|
||||
mLinesListView.setAdapter(mAdapter);
|
||||
//设置item 点击事件
|
||||
mAdapter.setOnLineItemClickListener(new LineItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(int position) {
|
||||
if (mData.size() > position && !TextUtils.isEmpty(mData.get(position).startSiteName )
|
||||
&& !TextUtils.isEmpty(mData.get(position).endSiteName)){
|
||||
mSelectLineId = mData.get(position).lineId;
|
||||
}else {
|
||||
mSelectLineId = -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局宽高
|
||||
*/
|
||||
private void initWH() {
|
||||
|
||||
Window window = getWindow();
|
||||
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
WindowManager windowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
|
||||
Point point = new Point();
|
||||
windowManager.getDefaultDisplay().getSize(point);//用于获取屏幕高度
|
||||
|
||||
params.width = (int)(point.x * 0.375);
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
window.setAttributes(params);
|
||||
window.setGravity(Gravity.LEFT|Gravity.BOTTOM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
private void initDatas() {
|
||||
mPresenter.queryBusLines();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询返回绑定路线集合
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void onBusLinesChange(BusQueryLinesResponse data){
|
||||
if (null == data){
|
||||
showNoData(true);
|
||||
return;
|
||||
}
|
||||
if (data.data != null && data.data.size() > 0){
|
||||
showNoData(false);
|
||||
mData.clear();
|
||||
mData.addAll(data.data);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
changeCommitBtnBg();
|
||||
}else {
|
||||
showNoData(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据路线选中情况设置提交按钮样式
|
||||
*/
|
||||
private void changeCommitBtnBg() {
|
||||
for (int i=0; i<mData.size();i++){
|
||||
if (mData.get(i).choose == 1){
|
||||
mLineCommitBtn.setBackgroundResource(R.drawable.bus_switch_line_btn_commit);
|
||||
mLineCommitBtn.setTextColor(getResources().getColor(R.color.bus_white));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeLineIdSuccess(){
|
||||
ToastUtils.showLong(getResources().getString(R.string.bus_change_line_commit_tip_s));
|
||||
mPresenter.queryBusRoutes();
|
||||
if (mAdapter != null){
|
||||
mAdapter.setOnLineItemClickListener(null);
|
||||
}
|
||||
mPresenter.removeListener();
|
||||
finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* 有无数据UI显示
|
||||
* @param b
|
||||
*/
|
||||
private void showNoData(boolean b) {
|
||||
if (b){
|
||||
mLinesListView.setVisibility(View.GONE);
|
||||
mLineCommitBtn.setVisibility(View.GONE);
|
||||
mNoDatasView.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
mLinesListView.setVisibility(View.VISIBLE);
|
||||
mLineCommitBtn.setVisibility(View.VISIBLE);
|
||||
mNoDatasView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//关闭dialog
|
||||
if (v.getId() == R.id.switch_line_close){
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
//切换路线提交
|
||||
if (v.getId() == R.id.switch_line_btn_commit){
|
||||
if (mSelectLineId > -1){
|
||||
mPresenter.commitSwitchLineId(mSelectLineId);
|
||||
}else {
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 路线列表adapter
|
||||
*/
|
||||
static class SwitchLineAdapter extends RecyclerView.Adapter<SwitchLineViewHolder>{
|
||||
|
||||
private Context mContext;
|
||||
private List<BusQueryLinesResponse.Result> mData;
|
||||
// RecyclerView设置点击事件
|
||||
private LineItemClickListener mItemClickListener ;
|
||||
private int clickPos = -1;
|
||||
|
||||
public SwitchLineAdapter(Context context, List<BusQueryLinesResponse.Result> data){
|
||||
mContext = context;
|
||||
mData = data;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SwitchLineViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.bus_switch_line_list_item
|
||||
,parent,false);
|
||||
SwitchLineViewHolder viewHolder = new SwitchLineViewHolder(view);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull SwitchLineViewHolder holder, int position) {
|
||||
BusQueryLinesResponse.Result line = mData.get(position);
|
||||
holder.lineName.setText(mContext.getString(R.string.bus_switch_line_name)+" "+line.name);
|
||||
holder.lineStartName.setText(mContext.getString(R.string.bus_line_start)+" "+line.startSiteName);
|
||||
holder.lineEndName.setText(mContext.getString(R.string.bus_line_end)+" "+line.endSiteName);
|
||||
|
||||
//设置item点击事件
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mItemClickListener != null){
|
||||
mItemClickListener.onItemClick(position);
|
||||
clickPos = position;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
//选中绑定
|
||||
if (clickPos > -1){
|
||||
if (clickPos == position){
|
||||
holder.selectIv.setImageResource(R.drawable.bus_selected_btn);
|
||||
}else {
|
||||
holder.selectIv.setImageResource(R.drawable.bus_unselect_btn);
|
||||
}
|
||||
}else {
|
||||
if (line.choose == 1){//1:绑定 2:未绑定 默认绑定
|
||||
if (mItemClickListener != null) {
|
||||
mItemClickListener.onItemClick(position);
|
||||
}
|
||||
holder.selectIv.setImageResource(R.drawable.bus_selected_btn);
|
||||
}else {
|
||||
holder.selectIv.setImageResource(R.drawable.bus_unselect_btn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mData.size();
|
||||
}
|
||||
public void setOnLineItemClickListener(LineItemClickListener itemClickListener){
|
||||
this.mItemClickListener = itemClickListener ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static class SwitchLineViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
private ImageView selectIv;
|
||||
private TextView lineName; //线路名称
|
||||
private TextView lineStartName; //起点
|
||||
private TextView lineEndName; //终点
|
||||
|
||||
public SwitchLineViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
selectIv = itemView.findViewById(R.id.switch_line_item_select_iv);
|
||||
lineName = itemView.findViewById(R.id.switch_line_name);
|
||||
lineStartName = itemView.findViewById(R.id.switch_line_start_station);
|
||||
lineEndName = itemView.findViewById(R.id.switch_line_end_station);
|
||||
}
|
||||
}
|
||||
|
||||
public interface LineItemClickListener {
|
||||
void onItemClick(int position) ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package com.mogo.och.bus.ui
|
||||
|
||||
import android.graphics.Point
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.PagerSnapHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.commons.mvp.MvpActivity
|
||||
import com.mogo.eagle.core.utilcode.util.SharedPrefs
|
||||
import com.mogo.och.bus.presenter.BusLinePresenter
|
||||
import com.mogo.och.bus.ui.adapter.SwitchLineAdapter
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse
|
||||
import com.mogo.och.bus.ui.adapter.OpenItemAnimator
|
||||
import com.mogo.module.common.view.SpacesItemDecoration
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.bus.R
|
||||
import com.mogo.och.bus.bean.BusQueryLineTaskResponse
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/2/8
|
||||
*/
|
||||
class BusSwitchLineActivity : MvpActivity<BusSwitchLineView?, BusLinePresenter?>(),
|
||||
View.OnClickListener, BusSwitchLineView {
|
||||
|
||||
companion object{
|
||||
const val LASTCOMMITLINEID = "lastcommitlineid"
|
||||
}
|
||||
|
||||
private lateinit var mClose: ImageView
|
||||
private lateinit var mNoDatasView: ConstraintLayout
|
||||
private lateinit var mLinesListView: RecyclerView
|
||||
private lateinit var mLineCommitBtn: TextView
|
||||
private lateinit var mAdapter: SwitchLineAdapter
|
||||
private lateinit var linearLayoutManager:LinearLayoutManager
|
||||
private val mData: MutableList<BusQueryLinesResponse.Result> = ArrayList()
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.activity_bus_switch_line
|
||||
}
|
||||
|
||||
override fun createPresenter(): BusLinePresenter {
|
||||
return BusLinePresenter(this)
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
initWH()
|
||||
initView()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
initDatas()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化view
|
||||
*/
|
||||
private fun initView() {
|
||||
mClose = findViewById(R.id.switch_line_close)
|
||||
mClose.setOnClickListener(this)
|
||||
mNoDatasView = findViewById(R.id.no_order_data_view)
|
||||
mLineCommitBtn = findViewById(R.id.switch_line_btn_commit)
|
||||
mLineCommitBtn.setOnClickListener(this)
|
||||
mLinesListView = findViewById(R.id.switch_line_rv)
|
||||
linearLayoutManager = LinearLayoutManager(this)
|
||||
mLinesListView.setLayoutManager(linearLayoutManager)
|
||||
mLinesListView.setItemAnimator(OpenItemAnimator())
|
||||
mAdapter = SwitchLineAdapter(applicationContext, mData)
|
||||
mLinesListView.addItemDecoration(SpacesItemDecoration(4))
|
||||
mLinesListView.setAdapter(mAdapter)
|
||||
//设置item 点击事件
|
||||
mAdapter.setOnLineItemClickListener(object :SwitchLineAdapter.LineItemClickListener{
|
||||
override fun onItemClick(position: Int, close: Boolean) {
|
||||
mPresenter?.queryBusLineTasks(mData[position].lineId, position, close)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局宽高
|
||||
*/
|
||||
private fun initWH() {
|
||||
val window = window
|
||||
val params = window.attributes
|
||||
val windowManager = getSystemService(WINDOW_SERVICE) as WindowManager
|
||||
val point = Point()
|
||||
windowManager.defaultDisplay.getSize(point) //用于获取屏幕高度
|
||||
params.width = (point.x * 0.375).toInt()
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
window.attributes = params
|
||||
window.setGravity(Gravity.START or Gravity.BOTTOM)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
private fun initDatas() {
|
||||
mPresenter?.queryBusLines()
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询返回绑定路线集合
|
||||
* @param data
|
||||
*/
|
||||
override fun onBusLinesChange(data: BusQueryLinesResponse?) {
|
||||
if (null == data) {
|
||||
showNoData(true)
|
||||
return
|
||||
}
|
||||
var lastCommitLineid = SharedPrefs.getInstance(this).getInt(LASTCOMMITLINEID, -1)
|
||||
if (data.data != null && data.data.size > 0) {
|
||||
showNoData(false)
|
||||
mData.clear()
|
||||
mData.addAll(data.data)
|
||||
mAdapter.notifyDataSetChanged()
|
||||
if(lastCommitLineid>0){
|
||||
mData.forEachIndexed { index, line ->
|
||||
if(line.lineId==lastCommitLineid){
|
||||
line.open = true
|
||||
mPresenter?.queryBusLineTasks(line.lineId,index,false)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showNoData(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChangeLineIdSuccess() {
|
||||
ToastUtils.showLong(resources.getString(R.string.bus_change_line_commit_tip_s))
|
||||
mPresenter?.queryBusRoutes()
|
||||
mAdapter.setOnLineItemClickListener(null)
|
||||
mPresenter?.removeListener()
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onBusLineTasks(lineTaskInfo: BusQueryLineTaskResponse?, position: Int,autoRefresh:Boolean) {
|
||||
val result = mData[position]
|
||||
if (result.taskList == null) {
|
||||
result.taskList = ArrayList()
|
||||
}
|
||||
if (lineTaskInfo == null) {
|
||||
result.haveTask = true
|
||||
// 打开操作
|
||||
mAdapter.notifyItemChanged(position)
|
||||
} else {
|
||||
if (lineTaskInfo.data == null || lineTaskInfo.data.isEmpty()) {
|
||||
result.haveTask = true
|
||||
lineTaskInfo.data = ArrayList()
|
||||
}
|
||||
if (lineTaskInfo.data.size != result.taskList.size) { // 不相等有变动 重新赋值
|
||||
result.taskList.clear()
|
||||
result.taskList.addAll(lineTaskInfo.data)
|
||||
if(autoRefresh) {
|
||||
mAdapter.checkTaskId = -1
|
||||
mAdapter.checkLineId = -1
|
||||
lineTaskInfo.data.forEach {
|
||||
if (it.id == mAdapter.checkTaskId) {
|
||||
mAdapter.checkTaskId = it.id
|
||||
mAdapter.checkLineId = result.lineId
|
||||
}
|
||||
}
|
||||
}
|
||||
// 打开操作
|
||||
mAdapter.notifyItemChanged(position)
|
||||
linearLayoutManager.stackFromEnd = (position==mData.size-1||position==mData.size-2)&&mData.size>6
|
||||
mLinesListView.smoothScrollToPosition(position)
|
||||
}else if(lineTaskInfo.data.isEmpty()){
|
||||
mAdapter.notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 有无数据UI显示
|
||||
* @param b
|
||||
*/
|
||||
private fun showNoData(b: Boolean) {
|
||||
if (b) {
|
||||
mLinesListView.visibility = View.GONE
|
||||
mLineCommitBtn.visibility = View.GONE
|
||||
mNoDatasView.visibility = View.VISIBLE
|
||||
} else {
|
||||
mLinesListView.visibility = View.VISIBLE
|
||||
mLineCommitBtn.visibility = View.VISIBLE
|
||||
mNoDatasView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
//关闭dialog
|
||||
if (v.id == R.id.switch_line_close) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
//切换路线提交
|
||||
if (v.id == R.id.switch_line_btn_commit) {
|
||||
if(mAdapter.checkLineId!=-1&&mAdapter.checkTaskId!=-1){
|
||||
mPresenter?.commitSwitchLineId(mAdapter.checkTaskId,mAdapter.checkLineId)
|
||||
}else{
|
||||
ToastUtils.showLong("请选择任务")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
mPresenter!!.removeListener()
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.bus.ui;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.och.bus.bean.BusQueryLineTaskResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
|
||||
/**
|
||||
@@ -11,5 +12,7 @@ public interface BusSwitchLineView extends IView {
|
||||
|
||||
void onBusLinesChange(BusQueryLinesResponse data);
|
||||
void onChangeLineIdSuccess();
|
||||
|
||||
void onBusLineTasks(BusQueryLineTaskResponse o, int position,boolean autoRefresh);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,655 @@
|
||||
package com.mogo.och.bus.ui.adapter;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.view.View;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This implementation of {@link RecyclerView.ItemAnimator} provides basic
|
||||
* animations on remove, add, and move events that happen to the items in
|
||||
* a RecyclerView. RecyclerView uses a DefaultItemAnimator by default.
|
||||
*
|
||||
* @see RecyclerView#setItemAnimator(RecyclerView.ItemAnimator)
|
||||
*/
|
||||
public class OpenItemAnimator extends DefaultItemAnimator {
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private static TimeInterpolator sDefaultInterpolator;
|
||||
|
||||
private ArrayList<RecyclerView.ViewHolder> mPendingRemovals = new ArrayList<>();
|
||||
private ArrayList<RecyclerView.ViewHolder> mPendingAdditions = new ArrayList<>();
|
||||
private ArrayList<MoveInfo> mPendingMoves = new ArrayList<>();
|
||||
private ArrayList<ChangeInfo> mPendingChanges = new ArrayList<>();
|
||||
|
||||
ArrayList<ArrayList<RecyclerView.ViewHolder>> mAdditionsList = new ArrayList<>();
|
||||
ArrayList<ArrayList<MoveInfo>> mMovesList = new ArrayList<>();
|
||||
ArrayList<ArrayList<ChangeInfo>> mChangesList = new ArrayList<>();
|
||||
|
||||
ArrayList<RecyclerView.ViewHolder> mAddAnimations = new ArrayList<>();
|
||||
ArrayList<RecyclerView.ViewHolder> mMoveAnimations = new ArrayList<>();
|
||||
ArrayList<RecyclerView.ViewHolder> mRemoveAnimations = new ArrayList<>();
|
||||
ArrayList<RecyclerView.ViewHolder> mChangeAnimations = new ArrayList<>();
|
||||
|
||||
private static class MoveInfo {
|
||||
public RecyclerView.ViewHolder holder;
|
||||
public int fromX, fromY, toX, toY;
|
||||
|
||||
MoveInfo(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
|
||||
this.holder = holder;
|
||||
this.fromX = fromX;
|
||||
this.fromY = fromY;
|
||||
this.toX = toX;
|
||||
this.toY = toY;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ChangeInfo {
|
||||
public RecyclerView.ViewHolder oldHolder, newHolder;
|
||||
public int fromX, fromY, toX, toY;
|
||||
private ChangeInfo(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder) {
|
||||
this.oldHolder = oldHolder;
|
||||
this.newHolder = newHolder;
|
||||
}
|
||||
|
||||
ChangeInfo(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder,
|
||||
int fromX, int fromY, int toX, int toY) {
|
||||
this(oldHolder, newHolder);
|
||||
this.fromX = fromX;
|
||||
this.fromY = fromY;
|
||||
this.toX = toX;
|
||||
this.toY = toY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChangeInfo{"
|
||||
+ "oldHolder=" + oldHolder
|
||||
+ ", newHolder=" + newHolder
|
||||
+ ", fromX=" + fromX
|
||||
+ ", fromY=" + fromY
|
||||
+ ", toX=" + toX
|
||||
+ ", toY=" + toY
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runPendingAnimations() {
|
||||
boolean removalsPending = !mPendingRemovals.isEmpty();
|
||||
boolean movesPending = !mPendingMoves.isEmpty();
|
||||
boolean changesPending = !mPendingChanges.isEmpty();
|
||||
boolean additionsPending = !mPendingAdditions.isEmpty();
|
||||
if (!removalsPending && !movesPending && !additionsPending && !changesPending) {
|
||||
// nothing to animate
|
||||
return;
|
||||
}
|
||||
// First, remove stuff
|
||||
for (RecyclerView.ViewHolder holder : mPendingRemovals) {
|
||||
animateRemoveImpl(holder);
|
||||
}
|
||||
mPendingRemovals.clear();
|
||||
// Next, move stuff
|
||||
if (movesPending) {
|
||||
final ArrayList<MoveInfo> moves = new ArrayList<>();
|
||||
moves.addAll(mPendingMoves);
|
||||
mMovesList.add(moves);
|
||||
mPendingMoves.clear();
|
||||
Runnable mover = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (MoveInfo moveInfo : moves) {
|
||||
animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY,
|
||||
moveInfo.toX, moveInfo.toY);
|
||||
}
|
||||
moves.clear();
|
||||
mMovesList.remove(moves);
|
||||
}
|
||||
};
|
||||
if (removalsPending) {
|
||||
View view = moves.get(0).holder.itemView;
|
||||
ViewCompat.postOnAnimationDelayed(view, mover, getRemoveDuration());
|
||||
} else {
|
||||
mover.run();
|
||||
}
|
||||
}
|
||||
// Next, change stuff, to run in parallel with move animations
|
||||
if (changesPending) {
|
||||
final ArrayList<ChangeInfo> changes = new ArrayList<>();
|
||||
changes.addAll(mPendingChanges);
|
||||
mChangesList.add(changes);
|
||||
mPendingChanges.clear();
|
||||
Runnable changer = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (ChangeInfo change : changes) {
|
||||
animateChangeImpl(change);
|
||||
}
|
||||
changes.clear();
|
||||
mChangesList.remove(changes);
|
||||
}
|
||||
};
|
||||
if (removalsPending) {
|
||||
RecyclerView.ViewHolder holder = changes.get(0).oldHolder;
|
||||
ViewCompat.postOnAnimationDelayed(holder.itemView, changer, getRemoveDuration());
|
||||
} else {
|
||||
changer.run();
|
||||
}
|
||||
}
|
||||
// Next, add stuff
|
||||
if (additionsPending) {
|
||||
final ArrayList<RecyclerView.ViewHolder> additions = new ArrayList<>();
|
||||
additions.addAll(mPendingAdditions);
|
||||
mAdditionsList.add(additions);
|
||||
mPendingAdditions.clear();
|
||||
Runnable adder = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (RecyclerView.ViewHolder holder : additions) {
|
||||
animateAddImpl(holder);
|
||||
}
|
||||
additions.clear();
|
||||
mAdditionsList.remove(additions);
|
||||
}
|
||||
};
|
||||
if (removalsPending || movesPending || changesPending) {
|
||||
long removeDuration = removalsPending ? getRemoveDuration() : 0;
|
||||
long moveDuration = movesPending ? getMoveDuration() : 0;
|
||||
long changeDuration = changesPending ? getChangeDuration() : 0;
|
||||
long totalDelay = removeDuration + Math.max(moveDuration, changeDuration);
|
||||
View view = additions.get(0).itemView;
|
||||
ViewCompat.postOnAnimationDelayed(view, adder, totalDelay);
|
||||
} else {
|
||||
adder.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean animateRemove(final RecyclerView.ViewHolder holder) {
|
||||
resetAnimation(holder);
|
||||
mPendingRemovals.add(holder);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
|
||||
final View view = holder.itemView;
|
||||
final ViewPropertyAnimator animation = view.animate();
|
||||
mRemoveAnimations.add(holder);
|
||||
animation.setDuration(getRemoveDuration()).alpha(0).setListener(
|
||||
new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
dispatchRemoveStarting(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
animation.setListener(null);
|
||||
view.setAlpha(1);
|
||||
dispatchRemoveFinished(holder);
|
||||
mRemoveAnimations.remove(holder);
|
||||
dispatchFinishedWhenDone();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean animateAdd(final RecyclerView.ViewHolder holder) {
|
||||
resetAnimation(holder);
|
||||
holder.itemView.setAlpha(0);
|
||||
mPendingAdditions.add(holder);
|
||||
return true;
|
||||
}
|
||||
|
||||
void animateAddImpl(final RecyclerView.ViewHolder holder) {
|
||||
final View view = holder.itemView;
|
||||
final ViewPropertyAnimator animation = view.animate();
|
||||
mAddAnimations.add(holder);
|
||||
animation.alpha(1).setDuration(getAddDuration())
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
dispatchAddStarting(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
view.setAlpha(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
animation.setListener(null);
|
||||
dispatchAddFinished(holder);
|
||||
mAddAnimations.remove(holder);
|
||||
dispatchFinishedWhenDone();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean animateMove(final RecyclerView.ViewHolder holder, int fromX, int fromY,
|
||||
int toX, int toY) {
|
||||
final View view = holder.itemView;
|
||||
fromX += (int) holder.itemView.getTranslationX();
|
||||
fromY += (int) holder.itemView.getTranslationY();
|
||||
resetAnimation(holder);
|
||||
int deltaX = toX - fromX;
|
||||
int deltaY = toY - fromY;
|
||||
if (deltaX == 0 && deltaY == 0) {
|
||||
dispatchMoveFinished(holder);
|
||||
return false;
|
||||
}
|
||||
if (deltaX != 0) {
|
||||
view.setTranslationX(-deltaX);
|
||||
}
|
||||
if (deltaY != 0) {
|
||||
view.setTranslationY(-deltaY);
|
||||
}
|
||||
mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
|
||||
return true;
|
||||
}
|
||||
|
||||
void animateMoveImpl(final RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
|
||||
final View view = holder.itemView;
|
||||
final int deltaX = toX - fromX;
|
||||
final int deltaY = toY - fromY;
|
||||
if (deltaX != 0) {
|
||||
view.animate().translationX(0);
|
||||
}
|
||||
if (deltaY != 0) {
|
||||
view.animate().translationY(0);
|
||||
}
|
||||
// TODO: make EndActions end listeners instead, since end actions aren't called when
|
||||
// vpas are canceled (and can't end them. why?)
|
||||
// need listener functionality in VPACompat for this. Ick.
|
||||
final ViewPropertyAnimator animation = view.animate();
|
||||
mMoveAnimations.add(holder);
|
||||
animation.setDuration(getMoveDuration()).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
dispatchMoveStarting(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
if (deltaX != 0) {
|
||||
view.setTranslationX(0);
|
||||
}
|
||||
if (deltaY != 0) {
|
||||
view.setTranslationY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
animation.setListener(null);
|
||||
dispatchMoveFinished(holder);
|
||||
mMoveAnimations.remove(holder);
|
||||
dispatchFinishedWhenDone();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder,
|
||||
int fromX, int fromY, int toX, int toY) {
|
||||
if (oldHolder == newHolder) {
|
||||
// Don't know how to run change animations when the same view holder is re-used.
|
||||
// run a move animation to handle position changes.
|
||||
return animateMove(oldHolder, fromX, fromY, toX, toY);
|
||||
}
|
||||
final float prevTranslationX = oldHolder.itemView.getTranslationX();
|
||||
final float prevTranslationY = oldHolder.itemView.getTranslationY();
|
||||
final float prevAlpha = oldHolder.itemView.getAlpha();
|
||||
resetAnimation(oldHolder);
|
||||
int deltaX = (int) (toX - fromX - prevTranslationX);
|
||||
int deltaY = (int) (toY - fromY - prevTranslationY);
|
||||
// recover prev translation state after ending animation
|
||||
oldHolder.itemView.setTranslationX(prevTranslationX);
|
||||
oldHolder.itemView.setTranslationY(prevTranslationY);
|
||||
oldHolder.itemView.setAlpha(prevAlpha);
|
||||
if (newHolder != null) {
|
||||
// carry over translation values
|
||||
resetAnimation(newHolder);
|
||||
newHolder.itemView.setTranslationX(-deltaX);
|
||||
newHolder.itemView.setTranslationY(-deltaY);
|
||||
newHolder.itemView.setAlpha(0);
|
||||
}
|
||||
mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
|
||||
return true;
|
||||
}
|
||||
|
||||
void animateChangeImpl(final ChangeInfo changeInfo) {
|
||||
final RecyclerView.ViewHolder holder = changeInfo.oldHolder;
|
||||
final View view = holder == null ? null : holder.itemView;
|
||||
final RecyclerView.ViewHolder newHolder = changeInfo.newHolder;
|
||||
final View newView = newHolder != null ? newHolder.itemView : null;
|
||||
if (view != null) {
|
||||
final ViewPropertyAnimator oldViewAnim = view.animate().setDuration(
|
||||
getChangeDuration());
|
||||
mChangeAnimations.add(changeInfo.oldHolder);
|
||||
oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
|
||||
oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
|
||||
oldViewAnim.alpha(0).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
dispatchChangeStarting(changeInfo.oldHolder, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
oldViewAnim.setListener(null);
|
||||
view.setAlpha(1);
|
||||
view.setTranslationX(0);
|
||||
view.setTranslationY(0);
|
||||
dispatchChangeFinished(changeInfo.oldHolder, true);
|
||||
mChangeAnimations.remove(changeInfo.oldHolder);
|
||||
dispatchFinishedWhenDone();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
if (newView != null) {
|
||||
final ViewPropertyAnimator newViewAnimation = newView.animate();
|
||||
mChangeAnimations.add(changeInfo.newHolder);
|
||||
newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration())
|
||||
.alpha(1).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
dispatchChangeStarting(changeInfo.newHolder, false);
|
||||
}
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
newViewAnimation.setListener(null);
|
||||
newView.setAlpha(1);
|
||||
newView.setTranslationX(0);
|
||||
newView.setTranslationY(0);
|
||||
dispatchChangeFinished(changeInfo.newHolder, false);
|
||||
mChangeAnimations.remove(changeInfo.newHolder);
|
||||
dispatchFinishedWhenDone();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
private void endChangeAnimation(List<ChangeInfo> infoList, RecyclerView.ViewHolder item) {
|
||||
for (int i = infoList.size() - 1; i >= 0; i--) {
|
||||
ChangeInfo changeInfo = infoList.get(i);
|
||||
if (endChangeAnimationIfNecessary(changeInfo, item)) {
|
||||
if (changeInfo.oldHolder == null && changeInfo.newHolder == null) {
|
||||
infoList.remove(changeInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void endChangeAnimationIfNecessary(ChangeInfo changeInfo) {
|
||||
if (changeInfo.oldHolder != null) {
|
||||
endChangeAnimationIfNecessary(changeInfo, changeInfo.oldHolder);
|
||||
}
|
||||
if (changeInfo.newHolder != null) {
|
||||
endChangeAnimationIfNecessary(changeInfo, changeInfo.newHolder);
|
||||
}
|
||||
}
|
||||
private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, RecyclerView.ViewHolder item) {
|
||||
boolean oldItem = false;
|
||||
if (changeInfo.newHolder == item) {
|
||||
changeInfo.newHolder = null;
|
||||
} else if (changeInfo.oldHolder == item) {
|
||||
changeInfo.oldHolder = null;
|
||||
oldItem = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
item.itemView.setAlpha(1);
|
||||
item.itemView.setTranslationX(0);
|
||||
item.itemView.setTranslationY(0);
|
||||
dispatchChangeFinished(item, oldItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endAnimation(RecyclerView.ViewHolder item) {
|
||||
final View view = item.itemView;
|
||||
// this will trigger end callback which should set properties to their target values.
|
||||
view.animate().cancel();
|
||||
// TODO if some other animations are chained to end, how do we cancel them as well?
|
||||
for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
|
||||
MoveInfo moveInfo = mPendingMoves.get(i);
|
||||
if (moveInfo.holder == item) {
|
||||
view.setTranslationY(0);
|
||||
view.setTranslationX(0);
|
||||
dispatchMoveFinished(item);
|
||||
mPendingMoves.remove(i);
|
||||
}
|
||||
}
|
||||
endChangeAnimation(mPendingChanges, item);
|
||||
if (mPendingRemovals.remove(item)) {
|
||||
view.setAlpha(1);
|
||||
dispatchRemoveFinished(item);
|
||||
}
|
||||
if (mPendingAdditions.remove(item)) {
|
||||
view.setAlpha(1);
|
||||
dispatchAddFinished(item);
|
||||
}
|
||||
|
||||
for (int i = mChangesList.size() - 1; i >= 0; i--) {
|
||||
ArrayList<ChangeInfo> changes = mChangesList.get(i);
|
||||
endChangeAnimation(changes, item);
|
||||
if (changes.isEmpty()) {
|
||||
mChangesList.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = mMovesList.size() - 1; i >= 0; i--) {
|
||||
ArrayList<MoveInfo> moves = mMovesList.get(i);
|
||||
for (int j = moves.size() - 1; j >= 0; j--) {
|
||||
MoveInfo moveInfo = moves.get(j);
|
||||
if (moveInfo.holder == item) {
|
||||
view.setTranslationY(0);
|
||||
view.setTranslationX(0);
|
||||
dispatchMoveFinished(item);
|
||||
moves.remove(j);
|
||||
if (moves.isEmpty()) {
|
||||
mMovesList.remove(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
|
||||
ArrayList<RecyclerView.ViewHolder> additions = mAdditionsList.get(i);
|
||||
if (additions.remove(item)) {
|
||||
view.setAlpha(1);
|
||||
dispatchAddFinished(item);
|
||||
if (additions.isEmpty()) {
|
||||
mAdditionsList.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// animations should be ended by the cancel above.
|
||||
//noinspection PointlessBooleanExpression,ConstantConditions
|
||||
if (mRemoveAnimations.remove(item) && DEBUG) {
|
||||
throw new IllegalStateException("after animation is cancelled, item should not be in "
|
||||
+ "mRemoveAnimations list");
|
||||
}
|
||||
|
||||
//noinspection PointlessBooleanExpression,ConstantConditions
|
||||
if (mAddAnimations.remove(item) && DEBUG) {
|
||||
throw new IllegalStateException("after animation is cancelled, item should not be in "
|
||||
+ "mAddAnimations list");
|
||||
}
|
||||
|
||||
//noinspection PointlessBooleanExpression,ConstantConditions
|
||||
if (mChangeAnimations.remove(item) && DEBUG) {
|
||||
throw new IllegalStateException("after animation is cancelled, item should not be in "
|
||||
+ "mChangeAnimations list");
|
||||
}
|
||||
|
||||
//noinspection PointlessBooleanExpression,ConstantConditions
|
||||
if (mMoveAnimations.remove(item) && DEBUG) {
|
||||
throw new IllegalStateException("after animation is cancelled, item should not be in "
|
||||
+ "mMoveAnimations list");
|
||||
}
|
||||
dispatchFinishedWhenDone();
|
||||
}
|
||||
|
||||
private void resetAnimation(RecyclerView.ViewHolder holder) {
|
||||
if (sDefaultInterpolator == null) {
|
||||
sDefaultInterpolator = new ValueAnimator().getInterpolator();
|
||||
}
|
||||
holder.itemView.animate().setInterpolator(sDefaultInterpolator);
|
||||
endAnimation(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return (!mPendingAdditions.isEmpty()
|
||||
|| !mPendingChanges.isEmpty()
|
||||
|| !mPendingMoves.isEmpty()
|
||||
|| !mPendingRemovals.isEmpty()
|
||||
|| !mMoveAnimations.isEmpty()
|
||||
|| !mRemoveAnimations.isEmpty()
|
||||
|| !mAddAnimations.isEmpty()
|
||||
|| !mChangeAnimations.isEmpty()
|
||||
|| !mMovesList.isEmpty()
|
||||
|| !mAdditionsList.isEmpty()
|
||||
|| !mChangesList.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the state of currently pending and running animations. If there are none
|
||||
* pending/running, call {@link #dispatchAnimationsFinished()} to notify any
|
||||
* listeners.
|
||||
*/
|
||||
void dispatchFinishedWhenDone() {
|
||||
if (!isRunning()) {
|
||||
dispatchAnimationsFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endAnimations() {
|
||||
int count = mPendingMoves.size();
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
MoveInfo item = mPendingMoves.get(i);
|
||||
View view = item.holder.itemView;
|
||||
view.setTranslationY(0);
|
||||
view.setTranslationX(0);
|
||||
dispatchMoveFinished(item.holder);
|
||||
mPendingMoves.remove(i);
|
||||
}
|
||||
count = mPendingRemovals.size();
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
RecyclerView.ViewHolder item = mPendingRemovals.get(i);
|
||||
dispatchRemoveFinished(item);
|
||||
mPendingRemovals.remove(i);
|
||||
}
|
||||
count = mPendingAdditions.size();
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
RecyclerView.ViewHolder item = mPendingAdditions.get(i);
|
||||
item.itemView.setAlpha(1);
|
||||
dispatchAddFinished(item);
|
||||
mPendingAdditions.remove(i);
|
||||
}
|
||||
count = mPendingChanges.size();
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
endChangeAnimationIfNecessary(mPendingChanges.get(i));
|
||||
}
|
||||
mPendingChanges.clear();
|
||||
if (!isRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int listCount = mMovesList.size();
|
||||
for (int i = listCount - 1; i >= 0; i--) {
|
||||
ArrayList<MoveInfo> moves = mMovesList.get(i);
|
||||
count = moves.size();
|
||||
for (int j = count - 1; j >= 0; j--) {
|
||||
MoveInfo moveInfo = moves.get(j);
|
||||
RecyclerView.ViewHolder item = moveInfo.holder;
|
||||
View view = item.itemView;
|
||||
view.setTranslationY(0);
|
||||
view.setTranslationX(0);
|
||||
dispatchMoveFinished(moveInfo.holder);
|
||||
moves.remove(j);
|
||||
if (moves.isEmpty()) {
|
||||
mMovesList.remove(moves);
|
||||
}
|
||||
}
|
||||
}
|
||||
listCount = mAdditionsList.size();
|
||||
for (int i = listCount - 1; i >= 0; i--) {
|
||||
ArrayList<RecyclerView.ViewHolder> additions = mAdditionsList.get(i);
|
||||
count = additions.size();
|
||||
for (int j = count - 1; j >= 0; j--) {
|
||||
RecyclerView.ViewHolder item = additions.get(j);
|
||||
View view = item.itemView;
|
||||
view.setAlpha(1);
|
||||
dispatchAddFinished(item);
|
||||
additions.remove(j);
|
||||
if (additions.isEmpty()) {
|
||||
mAdditionsList.remove(additions);
|
||||
}
|
||||
}
|
||||
}
|
||||
listCount = mChangesList.size();
|
||||
for (int i = listCount - 1; i >= 0; i--) {
|
||||
ArrayList<ChangeInfo> changes = mChangesList.get(i);
|
||||
count = changes.size();
|
||||
for (int j = count - 1; j >= 0; j--) {
|
||||
endChangeAnimationIfNecessary(changes.get(j));
|
||||
if (changes.isEmpty()) {
|
||||
mChangesList.remove(changes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cancelAll(mRemoveAnimations);
|
||||
cancelAll(mMoveAnimations);
|
||||
cancelAll(mAddAnimations);
|
||||
cancelAll(mChangeAnimations);
|
||||
|
||||
dispatchAnimationsFinished();
|
||||
}
|
||||
|
||||
void cancelAll(List<RecyclerView.ViewHolder> viewHolders) {
|
||||
for (int i = viewHolders.size() - 1; i >= 0; i--) {
|
||||
viewHolders.get(i).itemView.animate().cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* If the payload list is not empty, DefaultItemAnimator returns <code>true</code>.
|
||||
* When this is the case:
|
||||
* <ul>
|
||||
* <li>If you override {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)}, both
|
||||
* ViewHolder arguments will be the same instance.
|
||||
* </li>
|
||||
* <li>
|
||||
* If you are not overriding {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)},
|
||||
* then DefaultItemAnimator will call {@link #animateMove(RecyclerView.ViewHolder, int, int, int, int)} and
|
||||
* run a move animation instead.
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder,
|
||||
@NonNull List<Object> payloads) {
|
||||
return !payloads.isEmpty() || super.canReuseUpdatedViewHolder(viewHolder, payloads);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.mogo.och.bus.ui.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.och.bus.R
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse
|
||||
import com.mogo.och.bus.ui.adapter.SwitchLineAdapter.SwitchLineViewHolder
|
||||
import kotlin.text.StringBuilder
|
||||
|
||||
/**
|
||||
* 路线列表adapter
|
||||
*/
|
||||
class SwitchLineAdapter(
|
||||
private val mContext: Context,
|
||||
private val mData: List<BusQueryLinesResponse.Result>
|
||||
) : RecyclerView.Adapter<SwitchLineViewHolder>() {
|
||||
companion object{
|
||||
const val TAG = "SwitchLineAdapter"
|
||||
}
|
||||
// RecyclerView设置点击事件
|
||||
private var mItemClickListener: LineItemClickListener? = null
|
||||
var checkLineId:Int = -1
|
||||
var checkTaskId:Int = -1
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): SwitchLineViewHolder {
|
||||
val view = LayoutInflater.from(mContext).inflate(
|
||||
R.layout.bus_switch_line_list_item, parent, false
|
||||
)
|
||||
return SwitchLineViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: SwitchLineViewHolder, position: Int) {
|
||||
val currentPosition = holder.bindingAdapterPosition
|
||||
val line = mData[currentPosition]
|
||||
if(line.name!=null&&line.name.length>10){
|
||||
line.name = line.name.substring(0,10)+"…"
|
||||
}
|
||||
holder.lineName.text = line.name
|
||||
val sb = StringBuilder()
|
||||
if (line.endSiteName!=null&&line.endSiteName.length>10) {
|
||||
sb.append(line.endSiteName.substring(0,5))
|
||||
sb.append("…")
|
||||
sb.append(line.endSiteName.substring(line.endSiteName.length-5,line.endSiteName.length))
|
||||
}else{
|
||||
sb.append(line.endSiteName)
|
||||
}
|
||||
val string = mContext.getString(R.string.bus_line_goto_end, sb.toString())
|
||||
holder.lineEndName.text = string
|
||||
holder.rvLineTask.layoutManager = GridLayoutManager(mContext, 3)
|
||||
val switchLineTaskAdapter = SwitchLineTaskAdapter(
|
||||
mContext,
|
||||
checkTaskId,
|
||||
line.taskList,
|
||||
object : SwitchLineTaskAdapter.TaskItemClickListener {
|
||||
override fun onItemClick(position: Int,isCheck:Boolean) {
|
||||
if(isCheck) {
|
||||
checkLineId = line.lineId
|
||||
checkTaskId = line.taskList[position].id
|
||||
}else{
|
||||
checkLineId=-1
|
||||
checkTaskId=-1
|
||||
}
|
||||
}
|
||||
})
|
||||
holder.rvLineTask.adapter = switchLineTaskAdapter
|
||||
holder.rvLineTask.isFocusableInTouchMode = false
|
||||
holder.actvShowMore.visibility = View.VISIBLE
|
||||
|
||||
if(line.open){
|
||||
if(line.taskList==null||line.taskList.isEmpty()){
|
||||
holder.actvShowMore.text = mContext.getString(R.string.bus_switch_line_no_task)
|
||||
holder.actvShowMore.setTextColor(ContextCompat.getColor(mContext,R.color.bus_color_4dffffff))
|
||||
holder.vLineTask.visibility = View.GONE
|
||||
holder.rvLineTask.visibility = View.GONE
|
||||
holder.selectIv.visibility = View.INVISIBLE
|
||||
holder.itemView.setBackgroundResource(R.drawable.bus_shape_select_line_item_bg_normal)
|
||||
}else {
|
||||
holder.actvShowMore.text = mContext.getString(R.string.bus_switch_line_select_task)
|
||||
holder.actvShowMore.setTextColor(ContextCompat.getColor(mContext,android.R.color.white))
|
||||
holder.vLineTask.visibility = View.VISIBLE
|
||||
holder.rvLineTask.visibility = View.VISIBLE
|
||||
holder.selectIv.visibility = View.VISIBLE
|
||||
holder.itemView.setBackgroundResource(R.drawable.bus_shape_select_line_item_bg_selected)
|
||||
holder.selectIv.apply {
|
||||
pivotX = 9.5f
|
||||
pivotY = 17f
|
||||
rotation = 90f
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(line.haveTask){
|
||||
holder.actvShowMore.text = mContext.getString(R.string.bus_switch_line_no_task)
|
||||
holder.actvShowMore.setTextColor(ContextCompat.getColor(mContext,R.color.bus_color_4dffffff))
|
||||
holder.vLineTask.visibility = View.GONE
|
||||
holder.rvLineTask.visibility = View.GONE
|
||||
holder.selectIv.visibility = View.INVISIBLE
|
||||
holder.itemView.setBackgroundResource(R.drawable.bus_shape_select_line_item_bg_normal)
|
||||
}else {
|
||||
holder.actvShowMore.text = mContext.getString(R.string.bus_switch_line_select_task)
|
||||
holder.actvShowMore.setTextColor(ContextCompat.getColor(mContext,android.R.color.white))
|
||||
holder.vLineTask.visibility = View.GONE
|
||||
holder.rvLineTask.visibility = View.GONE
|
||||
holder.selectIv.visibility = View.VISIBLE
|
||||
holder.itemView.setBackgroundResource(R.drawable.bus_shape_select_line_item_bg_normal)
|
||||
holder.selectIv.apply {
|
||||
pivotX = 9.5f
|
||||
pivotY = 17f
|
||||
rotation = 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//设置item点击事件
|
||||
holder.itemView.setOnClickListener {
|
||||
if(holder.actvShowMore.text==mContext.getString(R.string.bus_switch_line_no_task)){
|
||||
return@setOnClickListener
|
||||
}
|
||||
mData.forEachIndexed { index, result ->
|
||||
if(result.open){
|
||||
result.open = false;
|
||||
notifyItemChanged(index)
|
||||
if(result.taskList!=null) {
|
||||
result.taskList.clear()
|
||||
}
|
||||
if(index==currentPosition){// 点击当前已经打开的item 去关闭定时网络请求
|
||||
mItemClickListener?.onItemClick(currentPosition,true)
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
}
|
||||
mItemClickListener?.onItemClick(currentPosition,false)
|
||||
line.open = holder.rvLineTask.visibility == View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return mData.size
|
||||
}
|
||||
|
||||
fun setOnLineItemClickListener(itemClickListener: LineItemClickListener?) {
|
||||
mItemClickListener = itemClickListener
|
||||
}
|
||||
|
||||
class SwitchLineViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val selectIv: ImageView
|
||||
val lineName: AppCompatTextView//线路名称
|
||||
val lineEndName: AppCompatTextView //终点
|
||||
val actvShowMore: AppCompatTextView //选择时间
|
||||
val rvLineTask: RecyclerView// 排班时间
|
||||
val vLineTask: View// 白色分割线
|
||||
|
||||
init {
|
||||
selectIv = itemView.findViewById(R.id.switch_line_item_select_iv)
|
||||
lineName = itemView.findViewById(R.id.switch_line_name)
|
||||
lineEndName = itemView.findViewById(R.id.switch_line_end_station)
|
||||
rvLineTask = itemView.findViewById(R.id.rv_line_task_list)
|
||||
vLineTask = itemView.findViewById(R.id.v_line_task)
|
||||
actvShowMore = itemView.findViewById(R.id.actv_show_more)
|
||||
}
|
||||
}
|
||||
|
||||
interface LineItemClickListener {
|
||||
fun onItemClick(position: Int,close:Boolean)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.och.bus.ui.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.och.bus.R
|
||||
import com.mogo.och.bus.bean.BusQueryLineTaskResponse
|
||||
import com.mogo.och.bus.ui.adapter.SwitchLineTaskAdapter.SwitchLineTaskViewHolder
|
||||
|
||||
/**
|
||||
* 路线列表adapter
|
||||
*/
|
||||
class SwitchLineTaskAdapter(
|
||||
private val mContext: Context,
|
||||
private var checkTaskId:Int,
|
||||
private val mData: List<BusQueryLineTaskResponse.Result>?,
|
||||
private val mTaskItemClickListener: TaskItemClickListener?
|
||||
) : RecyclerView.Adapter<SwitchLineTaskViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SwitchLineTaskViewHolder {
|
||||
val view = LayoutInflater.from(mContext).inflate(
|
||||
R.layout.bus_switch_line_list_task_item, parent, false
|
||||
)
|
||||
return SwitchLineTaskViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: SwitchLineTaskViewHolder, position: Int) {
|
||||
val currentPosition = holder.bindingAdapterPosition
|
||||
val task = mData!![currentPosition]
|
||||
val taskStartTime = TimeUtils.millis2String(task.taskStartTime, "HH:mm")
|
||||
holder.lineTask.text = taskStartTime
|
||||
if(checkTaskId==task.id){
|
||||
holder.lineTask.setBackgroundResource(R.drawable.bus_shape_select_line_item_time_bg_selected)
|
||||
}else{
|
||||
holder.lineTask.setBackgroundResource(R.drawable.bus_shape_select_line_item_time_bg)
|
||||
}
|
||||
holder.lineTask.setOnClickListener {
|
||||
if(checkTaskId==task.id){
|
||||
checkTaskId = -1
|
||||
mTaskItemClickListener?.onItemClick(currentPosition,false)
|
||||
}else {
|
||||
resetOther()
|
||||
checkTaskId = task.id
|
||||
mTaskItemClickListener?.onItemClick(currentPosition,true)
|
||||
}
|
||||
notifyItemChanged(currentPosition)
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetOther() {
|
||||
mData?.forEachIndexed { index, result ->
|
||||
if(result.id==checkTaskId){
|
||||
checkTaskId = -1
|
||||
notifyItemChanged(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return mData?.size ?: 0
|
||||
}
|
||||
|
||||
class SwitchLineTaskViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val lineTask: TextView // 时间
|
||||
init {
|
||||
lineTask = itemView.findViewById(R.id.actv_line_task)
|
||||
}
|
||||
}
|
||||
|
||||
interface TaskItemClickListener {
|
||||
fun onItemClick(position: Int,isCheck:Boolean)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.och.bus.util;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
@@ -8,12 +9,12 @@ import com.mogo.eagle.core.data.app.AppConfigInfo;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.analytics.AnalyticsManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.DateTimeUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* OCH Bus埋点工具
|
||||
@@ -30,18 +31,35 @@ public class BusAnalyticsManager {
|
||||
return BusAnalyticsManager.SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String mStartAutopilotKey;
|
||||
private HashMap<String, Object> mStartAutopilotParams = new HashMap<>();
|
||||
|
||||
private Runnable startAutopilotRunnable = () -> {
|
||||
// 15s内未开启,上报失败埋点
|
||||
triggerStartAutopilotFailureEvent("15s后app等待超时");
|
||||
};
|
||||
|
||||
public void triggerStartAutopilotFailureEventByAdas(String failMsg){
|
||||
removeWaitingCallback();
|
||||
triggerStartAutopilotFailureEvent(failMsg);
|
||||
}
|
||||
|
||||
private void triggerStartAutopilotFailureEvent(String failMsg){
|
||||
CallerLogger.INSTANCE.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg );
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_MSG,
|
||||
failMsg);
|
||||
AnalyticsManager.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
};
|
||||
}
|
||||
|
||||
private void removeWaitingCallback() {
|
||||
if (startAutopilotRunnable != null &&
|
||||
UiThreadHandler.getsUiHandler().hasCallbacks(startAutopilotRunnable)) {
|
||||
UiThreadHandler.removeCallbacks(startAutopilotRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发'开启自动驾驶'埋点流程
|
||||
@@ -69,14 +87,38 @@ public class BusAnalyticsManager {
|
||||
|
||||
if (send) {
|
||||
// 开启成功,上报埋点
|
||||
if (startAutopilotRunnable != null &&
|
||||
UiThreadHandler.getsUiHandler().hasCallbacks(startAutopilotRunnable)) {
|
||||
UiThreadHandler.removeCallbacks(startAutopilotRunnable);
|
||||
}
|
||||
removeWaitingCallback();
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT, true);
|
||||
AnalyticsManager.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
} else {
|
||||
UiThreadHandler.postDelayed(startAutopilotRunnable, BusConst.LOOP_PERIOD_15S);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发"无法开启自驾已知异常"埋点
|
||||
* @param startName
|
||||
* @param endName
|
||||
* @param lineId
|
||||
*/
|
||||
public void triggerUnableStartAPReasonEvent(String startName, String endName, int lineId,
|
||||
String reason) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
String plateNum = AppConfigInfo.INSTANCE.getPlateNumber();
|
||||
String dateTime = DateTimeUtils.getTimeText(
|
||||
System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss);
|
||||
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
|
||||
params.put(BusConst.EVENT_PARAM_SN, sn);
|
||||
params.put(BusConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum);
|
||||
params.put(BusConst.EVENT_PARAM_ENV_ONLINE,
|
||||
DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false);
|
||||
params.put(BusConst.EVENT_PARAM_TIME, dateTime);
|
||||
params.put(BusConst.EVENT_PARAM_START_NAME, startName);
|
||||
params.put(BusConst.EVENT_PARAM_END_NAME, endName);
|
||||
params.put(BusConst.EVENT_PARAM_LINE_ID, lineId);
|
||||
params.put(BusConst.EVENT_PARAM_UNABLE_START_REASON, reason);
|
||||
AnalyticsManager.INSTANCE.track(BusConst.EVENT_KEY_AP_UNABLE_START_REASON, params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.och.bus.util
|
||||
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/10/24
|
||||
*/
|
||||
object BusSendTripInfoManager{
|
||||
|
||||
const val START_TRIP = 1
|
||||
const val END_TRIP = 2
|
||||
const val LEAVE_STATION = 3
|
||||
const val ARRIVE_STATION = 4
|
||||
|
||||
/**
|
||||
* 行程信息
|
||||
* @param type 事件类型, 1:行程开始, 2:行程结束, 3:出站, 4:进站, 5:城市占道施工预警
|
||||
* @param lineName 路线名, for type 1, 2
|
||||
* @param departureStopName 出站站点名, for type 3, 4
|
||||
* @param arrivalStopName 下一站到达站点名, for type 3, 4
|
||||
* @param isLastStop 是否终点站(下一站或者要到达站)
|
||||
* @return
|
||||
*/
|
||||
fun sendBusTripInfo(type: Int, lineName: String,
|
||||
departureStopName: String,
|
||||
arrivalStopName: String,
|
||||
isLastStop: Boolean) {
|
||||
d(SceneConstant.M_BUS + "BusSendTripInfoManager", "type: "+ type
|
||||
+", lineName: "+ lineName +", departureStopName: "+ departureStopName
|
||||
+ ", arrivalStopName: "+arrivalStopName+", isLastStop: "+isLastStop)
|
||||
CallerAutoPilotManager.sendTripInfo(type,lineName,departureStopName, arrivalStopName, isLastStop)
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.och.bus.bean.BusRoutesResult;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
import com.mogo.och.bus.model.BusOrderModel;
|
||||
import com.zhidao.socket.utils.LoginStatusUtil;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BusTrajectoryManager {
|
||||
*/
|
||||
public void syncTrajectoryInfo() {
|
||||
BusRoutesResult routesResult = BusOrderModel.getInstance().getBusRoutesResult();
|
||||
if (BusOrderModel.getInstance().isWorking() && routesResult != null
|
||||
if (LoginStatusUtil.isLogin() && routesResult != null
|
||||
&& BusOrderModel.getInstance().getCurrentStationIndex() == 0
|
||||
&& !BusOrderModel.getInstance().isGoingToNextStation()) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "syncTrajectoryInfo() start.");
|
||||
|
||||
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1440/bus_no_line_icon.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1440/icon_arrow_blue_bus.png
Executable file
|
After Width: | Height: | Size: 377 B |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1440/icon_arrow_green_bus.png
Executable file
|
After Width: | Height: | Size: 400 B |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1440/icon_arrow_grey_bus.png
Executable file
|
After Width: | Height: | Size: 402 B |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1440/icon_no_bus_line.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1440/icon_point_blue_bus.png
Executable file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1440/icon_point_green_bus.png
Executable file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1440/icon_point_grey_bus.png
Executable file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/bus_no_line_icon.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/icon_arrow_blue_bus.png
Executable file
|
After Width: | Height: | Size: 377 B |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/icon_arrow_green_bus.png
Executable file
|
After Width: | Height: | Size: 400 B |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/icon_arrow_grey_bus.png
Executable file
|
After Width: | Height: | Size: 402 B |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/icon_no_bus_line.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/icon_point_blue_bus.png
Executable file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/icon_point_green_bus.png
Executable file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi-2560x1600/icon_point_grey_bus.png
Executable file
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 491 B |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi/bus_no_line_icon.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi/icon_arrow_blue_bus.png
Executable file
|
After Width: | Height: | Size: 377 B |
BIN
OCH/mogo-och-bus/src/main/res/drawable-xhdpi/icon_arrow_green_bus.png
Executable file
|
After Width: | Height: | Size: 400 B |