Merge remote-tracking branch 'origin/dev_robotaxi-d-app-module_2120_221017_2.12.0' into dev_robotaxi-d-app-module_2120_221017_2.12.0

# Conflicts:
#	OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/model/TaxiPassengerModel.java
This commit is contained in:
wangmingjun
2022-10-24 18:37:39 +08:00
48 changed files with 1871 additions and 1684 deletions

View File

@@ -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;
@@ -14,6 +15,7 @@ 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;
@@ -58,9 +60,11 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
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.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 (position == mStations.size() - 1){
@@ -77,22 +81,26 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
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);
}
}
}
@@ -103,7 +111,7 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
}
}
class StationViewHolder extends RecyclerView.ViewHolder{
public TextView stationName;
public MarqueeTextView stationName;
public ImageView stationCircle;
public ImageView curArrowBg;
public ImageView stationStationTag;

View File

@@ -39,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;
@@ -129,8 +129,8 @@ public class BusPassengerModel {
}
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;
@@ -149,8 +149,8 @@ public class BusPassengerModel {
}
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

View File

@@ -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() {
}
}

View File

@@ -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);
}
}
};
}
}

View File

@@ -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"))
}
}

View File

@@ -26,6 +26,7 @@ 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 +50,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;

View File

@@ -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

View File

@@ -3,7 +3,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
<com.mogo.och.common.module.wigets.MarqueeTextView
android:id="@+id/bus_p_station"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -17,6 +18,8 @@
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"/>

View File

@@ -35,6 +35,7 @@ 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;
@@ -53,7 +54,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
public static final String TAG = "BusFragment";
private TextView mSwitchLine; //切换路线
private TextView mLineName;
private MarqueeTextView mLineName;
private TextView mTaskTime;
private Group groupStationsPanel;
private ConstraintLayout noDataView;

View File

@@ -11,8 +11,8 @@ 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.common.module.biz.network.OchCommonServiceCallback;
/**
* @author: wangmingjun
@@ -42,7 +42,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) {
@@ -56,7 +56,7 @@ public class BusLineModel {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort("网络异常,请稍后重试");
}else {
@@ -72,7 +72,7 @@ public class BusLineModel {
* @param position 位置
*/
public void queryBusLineTasksById(int lineId, int position,boolean autoRefresh){
BusServiceManager.getInstance().queryBusTaskByLineId(mContext, String.valueOf(lineId),new IBusServiceCallback<BusQueryLineTaskResponse>() {
BusServiceManager.queryBusTaskByLineId(mContext, String.valueOf(lineId),new OchCommonServiceCallback<BusQueryLineTaskResponse>() {
@Override
public void onSuccess(BusQueryLineTaskResponse data) {
if (null == data && mBusLinesCallback != null) {
@@ -86,7 +86,7 @@ public class BusLineModel {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort("网络异常,请稍后重试");
}else {
@@ -97,7 +97,7 @@ public class BusLineModel {
}
public void commitSwitchLineId(int taskId,int lineId){
BusServiceManager.getInstance().switchLine(mContext,taskId, new IBusServiceCallback<BusRoutesResponse>() {
BusServiceManager.switchLine(mContext,taskId, new OchCommonServiceCallback<BusRoutesResponse>() {
@Override
public void onSuccess(BusRoutesResponse o) {
SharedPrefs.getInstance(mContext).putInt(BusSwitchLineActivity.LASTCOMMITLINEID,lineId);
@@ -107,7 +107,7 @@ public class BusLineModel {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort("网络异常,请稍后重试");
}else {

View File

@@ -47,11 +47,11 @@ import com.mogo.och.bus.callback.IRefreshBusStationsCallback;
import com.mogo.och.bus.callback.ISlidePannelHideCallback;
import com.mogo.och.bus.constant.BusConst;
import com.mogo.och.bus.net.BusServiceManager;
import com.mogo.och.bus.net.IBusServiceCallback;
import com.mogo.och.bus.presenter.BusModelLoopManager;
import com.mogo.och.bus.util.BusAnalyticsManager;
import com.mogo.och.bus.util.BusTrajectoryManager;
import com.mogo.och.common.module.biz.constant.OchCommonConst;
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
import com.mogo.och.common.module.biz.provider.LoginService;
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
@@ -256,15 +256,15 @@ public class BusOrderModel {
BusStationBean currentStation = stationList.get( backgroundCurrentStationIndex);
BusStationBean nextStation = stationList.get( backgroundCurrentStationIndex +1);
BusServiceManager.getInstance().updateOrderRoute(mContext, currentLineId, currentStation.getSiteId()
, nextStation.getSiteId(), points, new IBusServiceCallback<BaseData>() {
BusServiceManager.updateOrderRoute(mContext, currentLineId, currentStation.getSiteId()
, nextStation.getSiteId(), points, new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData o) {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
if (isGoingToNextStation){//重试
updateOrderRoute();
}
@@ -362,7 +362,7 @@ public class BusOrderModel {
*/
public void queryBusRoutes() {
CallerLogger.INSTANCE.d(M_BUS + TAG, "查询小巴路线");
BusServiceManager.getInstance().queryBusRoutes(mContext, new IBusServiceCallback<BusRoutesResponse>() {
BusServiceManager.queryBusRoutes(mContext, new OchCommonServiceCallback<BusRoutesResponse>() {
@Override
public void onSuccess(BusRoutesResponse data) {
if ( data == null
@@ -383,7 +383,7 @@ public class BusOrderModel {
updateBusStatus( data.getResult());
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
// 重复请求小巴路线,直至成功
//改为任务,为空不再去一直取
// queryBusStationDelay();
@@ -449,8 +449,8 @@ public class BusOrderModel {
*/
public void abortTask() {
CallerLogger.INSTANCE.d( M_BUS + TAG, "结束当前路线abortTask");
BusServiceManager.getInstance().abortTask(mContext, currentTaskId
, new IBusServiceCallback<BaseData>() {
BusServiceManager.abortTask(mContext, currentTaskId
, new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData o) {
CallerLogger.INSTANCE.d(M_BUS + TAG, "abortTask success: " + o);
@@ -462,7 +462,7 @@ public class BusOrderModel {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
ToastUtils.showShort(failMsg);
}
});
@@ -531,11 +531,11 @@ public class BusOrderModel {
CallerLogger.INSTANCE.e( M_BUS + TAG, "数组越界" );
return;
}
BusServiceManager.getInstance().queryStationWriteOffPassengers(mContext,
BusServiceManager.queryStationWriteOffPassengers(mContext,
currentTaskId,
stationList.get(backgroundCurrentStationIndex).getSiteId(),
prePassengerWriteOffTime,
new IBusServiceCallback<BusQueryWriteOffPassengersResponse>(){
new OchCommonServiceCallback<BusQueryWriteOffPassengersResponse>(){
@Override
public void onSuccess(BusQueryWriteOffPassengersResponse o) {
@@ -547,7 +547,7 @@ public class BusOrderModel {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
}
});
@@ -587,11 +587,11 @@ public class BusOrderModel {
String arriveStation = stationList.get(arrivedStationIndex).getName();
CallerLogger.INSTANCE.d(M_BUS + TAG,"arriveSiteStation-currentStationIndex = "+ arrivedStationIndex);
BusServiceManager.getInstance().arriveSiteStation(mContext ,
BusServiceManager.arriveSiteStation(mContext ,
stationList.get(arrivedStationIndex).getSeq(),
stationList.get(arrivedStationIndex).getSiteId(),
currentTaskId ,
new IBusServiceCallback<BaseData>() {
new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData o) {
CallerLogger.INSTANCE.d(M_BUS + TAG,"行程日志-arriveSiteStation success");
@@ -606,7 +606,7 @@ public class BusOrderModel {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
isArrivedStation = false;
isGoingToNextStation = true;
if (ToastUtilsOch.isCustomFastClick(5000)){
@@ -630,11 +630,11 @@ public class BusOrderModel {
nextStationName = stationList.get(backgroundCurrentStationIndex + 1).getName();
}
String finalNextStationName = nextStationName;
BusServiceManager.getInstance().leaveStation(mContext,
BusServiceManager.leaveStation(mContext,
stationList.get(backgroundCurrentStationIndex).getSeq(),
stationList.get(backgroundCurrentStationIndex).getSiteId(),
currentTaskId,
new IBusServiceCallback<BaseData>() {
new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData o) {
isArrivedStation = false;
@@ -646,7 +646,7 @@ public class BusOrderModel {
leaveTTSTips(finalNextStationName);
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort("网络异常,请稍后重试");
}else{
@@ -831,8 +831,8 @@ public class BusOrderModel {
*/
private void endTask() {
CallerLogger.INSTANCE.d( M_BUS + TAG, "任务正常走完endTask()");
BusServiceManager.getInstance().endTask(mContext, currentTaskId
, new IBusServiceCallback<BaseData>() {
BusServiceManager.endTask(mContext, currentTaskId
, new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData o) {
CallerLogger.INSTANCE.d(M_BUS + TAG, "endTask success: " + o);
@@ -845,7 +845,7 @@ public class BusOrderModel {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
ToastUtils.showShort(failMsg);
}
});
@@ -896,15 +896,15 @@ public class BusOrderModel {
// 车机端上传心跳数据(只在出车状态时上传)
public void runCarHeartbeat() {
BusServiceManager.getInstance().runCarHeartbeat(mContext, mLongitude, mLatitude,
new IBusServiceCallback<BaseData>() {
BusServiceManager.runCarHeartbeat(mContext, mLongitude, mLatitude,
new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
}
@Override
public void onFail(String failMsg) {
public void onFail(int code, String failMsg) {
}
});

View File

@@ -1,270 +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.BusCloseTaskRequest;
import com.mogo.och.bus.bean.BusQueryLineTaskResponse;
import com.mogo.och.bus.bean.BusQueryLinesResponse;
import com.mogo.och.bus.bean.BusQueryWriteOffPassengersResponse;
import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean;
import com.mogo.och.bus.bean.BusRoutesResponse;
import com.mogo.och.bus.bean.BusWriteOffPassengersQueryRequest;
import com.mogo.och.bus.bean.CarHeartbeatReqBean;
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.queryBusRoutes(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
, new BusQueryLineStationsRequest())
.subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() )
.subscribe( getSubscribeImpl(context,callback,"queryBusRoutes"));
}
/**
* 重置线路站点
* @param context
* @param taskId
* @param callback
*/
public void switchLine(Context context, int taskId, IBusServiceCallback<BusRoutesResponse> callback){
mService.switchLine(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken(),new BusResetDrivingLineRequest(taskId))
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"switchLine"));
}
/**
* 中断当前任务
* @param context
* @param taskId
* @param callback
*/
public void abortTask(Context context, int taskId, IBusServiceCallback<BaseData> callback){
mService.abortTask(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new BusCloseTaskRequest(taskId))
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"abortTask"));
}
/**
* 正常结束任务
* @param context
* @param taskId
* @param callback
*/
public void endTask(Context context, int taskId, IBusServiceCallback<BaseData> callback){
mService.endTask(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new BusCloseTaskRequest(taskId))
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"endTask"));
}
/**
* 离站上报
* @param context
* @param seq
* @param siteId
* @param callback
*/
public void leaveStation(Context context, int seq, int siteId,int taskId, IBusServiceCallback<BaseData> callback){
mService.leaveStation(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new BusUpdateSiteStatusRequest(taskId,siteId,seq))
.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,int taskId,
IBusServiceCallback<BaseData> callback){
mService.arriveSiteStation(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new BusUpdateSiteStatusRequest(taskId,siteId,seq))
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe(getSubscribeImpl(context,callback,"arriveSiteStation"));
}
/**
* 查询下车乘客
* @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 siteId
* @param callback
*/
public void queryStationWriteOffPassengers(Context context,int taskId,int siteId,long prePassengerTime
, IBusServiceCallback<BusQueryWriteOffPassengersResponse> callback){
mService.queryWriteOffPassengers( MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new BusWriteOffPassengersQueryRequest(taskId,siteId,prePassengerTime))
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe(getSubscribeImpl(context,callback,"queryStationWriteOffPassengers"));
}
/**
* 查询小巴车订单
* @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 queryBusTaskByLineId(Context context,String lineId,IBusServiceCallback<BusQueryLineTaskResponse> callback){
mService.queryBusTaskByLineId(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,lineId)
.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());
}
}
};
}
}

View File

@@ -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"))
}
}

View File

@@ -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() {
}
}

View File

@@ -10,15 +10,16 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
<com.mogo.och.common.module.wigets.MarqueeTextView
android:id="@+id/module_och_bus_line_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_68"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_64"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:text="--"
android:textColor="#FFF"
android:textSize="38px"

View File

@@ -10,58 +10,9 @@ class SimpleInterceptor: Interceptor {
val encodedPath = original.url().encodedPath()
Log.e("SimpleInterceptor",original.method()+ encodedPath+original.url().encodedQuery())
when (encodedPath) {
"/autopilot-car-hailing/operation/v1/driver/bus/loginStatus" -> {
val builder = Response.Builder()
val create:ResponseBody
if(first) {
create = ResponseBody.create(
MediaType.parse("application/json"),
"{\"code\":0,\"msg\":\"\",\"data\":{\"servingStatus\":0,\"driverStatus\":1,\"orderNo\":\"12111\",\"purpose\":1,\"sn\":\"fjsdlfjslf\",\"plateNumber\":\"车牌号\",\"phone\":\"18811539480\",\"lineId\":\"线路id\",\"taskId\":\"任务id\"}}"
)
first = false
}else{
create = ResponseBody.create(
MediaType.parse("application/json"),
"{\"code\":0,\"msg\":\"\",\"data\":{\"servingStatus\":0,\"driverStatus\":0,\"orderNo\":\"12111\",\"purpose\":1,\"sn\":\"fjsdlfjslf\",\"plateNumber\":\"车牌号\",\"phone\":\"18811539480\",\"lineId\":\"线路id\",\"taskId\":\"任务id\"}}"
)
first = true
}
builder.code(200)
builder.request(original)
builder.protocol(Protocol.HTTP_1_1)
builder.message("")
return builder.body(create).build()
}
"/autopilot-car-hailing/line/v2/driver/bus/task/query" -> {
val builder = Response.Builder()
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":0,\"msg\":\"\",\"data\":[{\"id\":1,\"taskStartTime\":1663722000000},{\"id\":2,\"taskStartTime\":1663725600000},{\"id\":3,\"taskStartTime\":1663729200000},{\"id\":4,\"taskStartTime\":1663732800000},{\"id\":5,\"taskStartTime\":1663736400000},{\"id\":6,\"taskStartTime\":1663740000000},{\"id\":7,\"taskStartTime\":1663743600000},{\"id\":8,\"taskStartTime\":1663747200000},{\"id\":9,\"taskStartTime\":1663750800000},{\"id\":10,\"taskStartTime\":1663754400000}]}")
builder.code(200)
builder.request(original)
builder.protocol(Protocol.HTTP_1_1)
builder.message("")
return builder.body(create).build()
}
"/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startTask" -> {
val builder = Response.Builder()
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":0,\"msg\":\"\",\"data\":null}")
builder.code(200)
builder.request(original)
builder.protocol(Protocol.HTTP_1_1)
builder.message("")
return builder.body(create).build()
}
"/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endOperation" -> {
val builder = Response.Builder()
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":0,\"msg\":\"\",\"data\":null}")
builder.code(200)
builder.request(original)
builder.protocol(Protocol.HTTP_1_1)
builder.message("")
return builder.body(create).build()
}
"/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startOperation" -> {
val builder = Response.Builder()
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":0,\"msg\":\"\",\"data\":null}")
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":100006,\"msg\":\"\",\"data\":null}")
builder.code(200)
builder.request(original)
builder.protocol(Protocol.HTTP_1_1)

View File

@@ -71,66 +71,70 @@ object OchCommonLoginModel{
* 获取手机验证码
*/
fun getPhoneCode(phone: String?) {
OchCommonServiceManager.getInstance().getPhoneCode(mContext, phone,
object : OchCommonServiceCallback<BaseData?> {
override fun onSuccess(data: BaseData?) {
if (null != data && 0 == data.code) {
// 获取验证码成功
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_get_code_success))
iTaxiLoginCallback?.getPhoneCodeSuccess()
} else {
if (data != null) {
ToastUtils.showShort(data.code)
mContext?.let {
OchCommonServiceManager.getPhoneCode(it, phone,
object : OchCommonServiceCallback<BaseData> {
override fun onSuccess(data: BaseData?) {
if (null != data && 0 == data.code) {
// 获取验证码成功
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_get_code_success))
iTaxiLoginCallback?.getPhoneCodeSuccess()
} else {
if (data != null) {
ToastUtils.showShort(data.code)
}
}
}
}
override fun onError() {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(mContext?.getString(R.string.network_error_tip))
} else {
ToastUtils.showShort(mContext?.getString(R.string.request_error_tip))
override fun onError() {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(mContext?.getString(R.string.network_error_tip))
} else {
ToastUtils.showShort(mContext?.getString(R.string.request_error_tip))
}
}
}
override fun onFail(code: Int, msg: String) {
ToastUtilsOch.showWithCodeMessage(code,msg)
}
})
override fun onFail(code: Int, msg: String) {
ToastUtilsOch.showWithCodeMessage(code,msg)
}
})
}
}
fun gotoLogin(phone: String, code: String) {
val location4Login = TaxiLoginReqBean.Location4Login(mLatitude, mLongitude)
OchCommonServiceManager.getInstance().gotoLoginBycode(mContext, phone, code, location4Login,
object : OchCommonServiceCallback<TaxiLoginRespBean?> {
override fun onSuccess(data: TaxiLoginRespBean?) {
if (null != data && 0 == data.code) {
// 获取验证码成功
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_login_success))
LoginStatusManager.setLoginStatus(TaxiLoginStatusEnum.Login)
mContext?.let {
SharedPrefs.getInstance(it).putString("och_account",phone)
}
iTaxiLoginCallback?.loginSuccess()
} else {
if (data != null) {
ToastUtils.showShort(data.code)
mContext?.let {
val location4Login = TaxiLoginReqBean.Location4Login(mLatitude, mLongitude)
OchCommonServiceManager.gotoLoginBycode(it, phone, code, location4Login,
object : OchCommonServiceCallback<TaxiLoginRespBean> {
override fun onSuccess(data: TaxiLoginRespBean?) {
if (null != data && 0 == data.code) {
// 获取验证码成功
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_login_success))
LoginStatusManager.setLoginStatus(TaxiLoginStatusEnum.Login)
mContext?.let {
SharedPrefs.getInstance(it).putString("och_account",phone)
}
iTaxiLoginCallback?.loginSuccess()
} else {
if (data != null) {
ToastUtils.showShort(data.code)
}
}
}
}
override fun onError() {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(mContext?.getString(R.string.network_error_tip))
} else {
ToastUtils.showShort(mContext?.getString(R.string.request_error_tip))
override fun onError() {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(mContext?.getString(R.string.network_error_tip))
} else {
ToastUtils.showShort(mContext?.getString(R.string.request_error_tip))
}
}
}
override fun onFail(code: Int, msg: String) {
ToastUtilsOch.showWithCodeMessage(code,msg)
}
})
override fun onFail(code: Int, msg: String) {
ToastUtilsOch.showWithCodeMessage(code,msg)
}
})
}
}
}

View File

@@ -53,7 +53,7 @@ public abstract class OchCommonLoginStatusModel {
* 8、登录页面关闭后查下状态
*/
public void queryCarStatus() {
OchCommonServiceManager.getInstance().queryDriverServiceStatus(mContext,
OchCommonServiceManager.queryDriverServiceStatus(mContext,
new OchCommonServiceCallback<DriverStatusQueryRespBean>() {
@Override
public void onSuccess(DriverStatusQueryRespBean data) {
@@ -93,7 +93,7 @@ public abstract class OchCommonLoginStatusModel {
// 登出
public void logout(double mLatitude,double mLongitude) {
TaxiLogoutReqBean.Location4Login location4Login = new TaxiLogoutReqBean.Location4Login(mLatitude, mLongitude);
OchCommonServiceManager.getInstance().logout(mContext,location4Login,
OchCommonServiceManager.logout(mContext,location4Login,
new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {

View File

@@ -1,187 +0,0 @@
package com.mogo.och.common.module.biz.network;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
import android.content.Context;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.debug.DebugConfig;
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.common.module.biz.bean.DriverStatusQueryRespBean;
import com.mogo.och.common.module.biz.bean.TaxiLoginReqBean;
import com.mogo.och.common.module.biz.bean.TaxiLoginRespBean;
import com.mogo.och.common.module.biz.bean.TaxiLoginSmsReqBean;
import com.mogo.och.common.module.biz.bean.TaxiLogoutReqBean;
import com.mogo.och.common.module.biz.constant.OchCommonConst;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by pangfan on 2021/8/19
*/
public class OchCommonServiceManager {
private static final String TAG = OchCommonServiceManager.class.getSimpleName();
private static final class SingletonHolder {
private static final OchCommonServiceManager INSTANCE = new OchCommonServiceManager();
}
public static OchCommonServiceManager getInstance() {
return SingletonHolder.INSTANCE;
}
private OchCommonServiceApiNew mOCHTaxiServiceApi;
private OchCommonServiceManager() {
if (mOCHTaxiServiceApi == null){
mOCHTaxiServiceApi = MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create(OchCommonServiceApiNew.class);
}
}
/**
* 获取手机验证码
* @param context
* @param callback
*/
public void getPhoneCode(Context context, String phone,
OchCommonServiceCallback<BaseData> callback) {
mOCHTaxiServiceApi.getPhoneCode(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new TaxiLoginSmsReqBean(phone))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "getPhoneCode"));
}
/**
* 通过验证码登录
* @param context
* @param callback
*/
public void gotoLoginBycode(Context context, String phone, String code,
TaxiLoginReqBean.Location4Login location4Login,
OchCommonServiceCallback<TaxiLoginRespBean> callback) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
Observable<TaxiLoginRespBean> taxiLoginRespBeanObservable = null;
switch (DebugConfig.getProductFlavor()) {
case "fPadLenovoOchTaxi": {//出租车司机
taxiLoginRespBeanObservable = mOCHTaxiServiceApi.gotoLoginBycode4Taxi(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new TaxiLoginReqBean(phone, code, sn, location4Login));
break;
}
case "fPadLenovoOchBus": {//小巴车司机
taxiLoginRespBeanObservable = mOCHTaxiServiceApi.gotoLoginBycode4Bus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new TaxiLoginReqBean(phone, code, sn, location4Login));
break;
}
}
if (taxiLoginRespBeanObservable != null) {
taxiLoginRespBeanObservable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "gotoLoginBycode"));
}
}
/**
* 登出
*/
public void logout(Context context, TaxiLogoutReqBean.Location4Login location4Login, OchCommonServiceCallback<BaseData> callback) {
Observable<BaseData> logout = null;
switch (DebugConfig.getProductFlavor()) {
case "fPadLenovoOchTaxi": {//出租车司机
logout = mOCHTaxiServiceApi.logout4Taxi(
MoGoAiCloudClientConfig.getInstance().getServiceAppId(),
MoGoAiCloudClientConfig.getInstance().getToken(),
new TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().getSn(), location4Login));
break;
}
case "fPadLenovoOchBus": {//小巴车司机
logout = mOCHTaxiServiceApi.logout4Bus(
MoGoAiCloudClientConfig.getInstance().getServiceAppId(),
MoGoAiCloudClientConfig.getInstance().getToken(),
new TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().getSn(), location4Login));
break;
}
}
if (logout != null) {
logout.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "logout"));
}
}
/**
* 接单状态和登录状态查询
*
* @param context
* @param callback
*/
public void queryDriverServiceStatus(Context context,
OchCommonServiceCallback<DriverStatusQueryRespBean> callback) {
if (MoGoAiCloudClientConfig.getInstance().getToken().isEmpty()) {
callback.onFail(OchCommonConst.WAIT_TAKEN, "等待令牌中请稍等");
MoGoAiCloudClient.getInstance().refreshToken();
return;
}
String flavor = "";
switch (DebugConfig.getProductFlavor()) {
case "fPadLenovoOchTaxi": {//出租车司机
flavor = "taxi";
break;
}
case "fPadLenovoOchBus": {//小巴车司机
flavor = "bus";
break;
}
case "fPadLenovoOchBusPassenger": {//小巴车乘客
flavor = "bus/passenger";
break;
}
}
mOCHTaxiServiceApi.queryDriverServiceStatusAndLoginStatus(flavor, MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, MoGoAiCloudClientConfig.getInstance().getSn())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryDriverServiceStatus"));
}
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
Context context, OchCommonServiceCallback<T> callback, String apiName) {
return new SubscribeImpl<T>(RequestOptions.create(context)) {
@Override
public void onSuccess(T o) {
super.onSuccess(o);
CallerLogger.INSTANCE.d(M_TAXI + TAG, apiName + ": onSuccess() " + o.msg);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(Throwable e) {
super.onError(e);
CallerLogger.INSTANCE.e(M_TAXI + 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_TAXI + TAG, String.format(apiName + ": onError() code = %d; message = %s;", code, message));
if (callback != null) {
callback.onFail(code, message);
}
}
};
}
}

View File

@@ -0,0 +1,154 @@
package com.mogo.och.common.module.biz.network
import android.content.Context
import com.mogo.och.common.module.biz.constant.OchCommonConst.Companion.getBaseUrl
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.och.common.module.biz.bean.TaxiLoginSmsReqBean
import com.mogo.och.common.module.biz.bean.TaxiLoginReqBean
import com.mogo.och.common.module.biz.bean.TaxiLoginRespBean
import com.mogo.och.common.module.biz.bean.TaxiLogoutReqBean
import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean
import com.mogo.och.common.module.biz.constant.OchCommonConst
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.BaseData
import com.mogo.eagle.core.network.MoGoRetrofitFactory
import com.mogo.och.common.module.biz.network.interceptor.transformTry
import io.reactivex.Observable
/**
* Created by pangfan on 2021/8/19
*/
object OchCommonServiceManager {
private const val TAG = "OchCommonServiceManager"
private val mOCHTaxiServiceApi: OchCommonServiceApiNew =
MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
OchCommonServiceApiNew::class.java
)
/**
* 获取手机验证码
* @param context
* @param callback
*/
@JvmStatic
fun getPhoneCode(
context: Context, phone: String?,
callback: OchCommonServiceCallback<BaseData>?
) {
mOCHTaxiServiceApi.getPhoneCode(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiLoginSmsReqBean(phone)
).transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "getPhoneCode"))
}
/**
* 通过验证码登录
* @param context
* @param callback
*/
@JvmStatic
fun gotoLoginBycode(
context: Context, phone: String?, code: String?,
location4Login: TaxiLoginReqBean.Location4Login?,
callback: OchCommonServiceCallback<TaxiLoginRespBean>?
) {
val sn = MoGoAiCloudClientConfig.getInstance().sn
var taxiLoginRespBeanObservable: Observable<TaxiLoginRespBean>? = null
when (DebugConfig.getProductFlavor()) {
"fPadLenovoOchTaxi" -> {
//出租车司机
taxiLoginRespBeanObservable = mOCHTaxiServiceApi.gotoLoginBycode4Taxi(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiLoginReqBean(phone, code, sn, location4Login)
).transformTry()
}
"fPadLenovoOchBus" -> {
//小巴车司机
taxiLoginRespBeanObservable = mOCHTaxiServiceApi.gotoLoginBycode4Bus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiLoginReqBean(phone, code, sn, location4Login)
).transformTry()
}
}
taxiLoginRespBeanObservable?.subscribe(OchCommonSubscribeImpl(context, callback, "gotoLoginBycode"))
}
/**
* 登出
*/
@JvmStatic
fun logout(
context: Context,
location4Login: TaxiLogoutReqBean.Location4Login?,
callback: OchCommonServiceCallback<BaseData>?
) {
var logout: Observable<BaseData>? = null
when (DebugConfig.getProductFlavor()) {
"fPadLenovoOchTaxi" -> {
//出租车司机
logout = mOCHTaxiServiceApi.logout4Taxi(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().sn, location4Login)
).transformTry()
}
"fPadLenovoOchBus" -> {
//小巴车司机
logout = mOCHTaxiServiceApi.logout4Bus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().sn, location4Login)
).transformTry()
}
}
logout?.subscribe(OchCommonSubscribeImpl(context, callback, "logout"))
}
/**
* 接单状态和登录状态查询
*
* @param context
* @param callback
*/
@JvmStatic
fun queryDriverServiceStatus(
context: Context,
callback: OchCommonServiceCallback<DriverStatusQueryRespBean>?
) {
if (MoGoAiCloudClientConfig.getInstance().token.isEmpty()) {
callback?.onFail(OchCommonConst.WAIT_TAKEN, "等待令牌中请稍等")
MoGoAiCloudClient.getInstance().refreshToken()
return
}
var flavor = ""
when (DebugConfig.getProductFlavor()) {
"fPadLenovoOchTaxi" -> {
//出租车司机
flavor = "taxi"
}
"fPadLenovoOchBus" -> {
//小巴车司机
flavor = "bus"
}
"fPadLenovoOchBusPassenger" -> {
//小巴车乘客
flavor = "bus/passenger"
}
}
mOCHTaxiServiceApi.queryDriverServiceStatusAndLoginStatus(
flavor,
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
MoGoAiCloudClientConfig.getInstance().sn
).transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverServiceStatus"))
}
}

View File

@@ -0,0 +1,36 @@
package com.mogo.och.common.module.biz.network
import com.mogo.eagle.core.data.BaseData
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.common.module.utils.CallerLoggerUtils.flavorTag
class OchCommonSubscribeImpl<T : BaseData>(
val context: Any,
val callback: OchCommonServiceCallback<T>?,
val apiName: String
) : SubscribeImpl<T>(RequestOptions.create(context)) {
companion object {
const val TAG = "OchCommonSubscribeImpl"
}
override fun onSuccess(o: T) {
super.onSuccess(o)
CallerLogger.d("$flavorTag$TAG", "$apiName: onSuccess() ${o.msg}")
callback?.onSuccess(o)
}
override fun onError(e: Throwable) {
super.onError(e)
CallerLogger.e("$flavorTag$TAG", "$apiName: onError() ${e.message}")
callback?.onError()
}
override fun onError(message: String, code: Int) {
super.onError(message, code)
CallerLogger.e("$flavorTag$TAG", "$apiName: onError() code = $code; message = $message")
callback?.onFail(code, message)
}
}

View File

@@ -0,0 +1,20 @@
package com.mogo.och.common.module.biz.network.interceptor
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.eagle.core.data.BaseData
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.functions.Function
class FRetryWithTime<T : BaseData> : Function<T, ObservableSource<T>> {
override fun apply(baseData: T): ObservableSource<T> {
baseData.let {
if (it.code == 100046 || it.code == 100045 || it.code == 100005 || it.code == 100006 || it.code == 520003) {
MoGoAiCloudClient.getInstance().refreshToken()
return Observable.error(OchCommonRetryException())
}
}
return Observable.just(baseData)
}
}

View File

@@ -0,0 +1,13 @@
package com.mogo.och.common.module.biz.network.interceptor
import io.reactivex.Observable
import com.mogo.eagle.core.data.BaseData
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
fun <T : BaseData> Observable<T>.transformTry():Observable<T> {
return flatMap(FRetryWithTime<T>())
.retryWhen(RetryWithTime())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
}

View File

@@ -0,0 +1,5 @@
package com.mogo.och.common.module.biz.network.interceptor;
public class OchCommonRetryException extends RuntimeException{
}

View File

@@ -0,0 +1,30 @@
package com.mogo.och.common.module.biz.network.interceptor
import com.mogo.eagle.core.utilcode.constant.TimeConstants
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.och.common.module.utils.CallerLoggerUtils.flavorTag
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.functions.Function
import java.util.concurrent.TimeUnit
class RetryWithTime : Function<Observable<Throwable?>, ObservableSource<Any?>> {
companion object {
private const val TAG = "RetryWithTime"
}
var current = -1
private var timeDelys = intArrayOf(3, 1, 2)
override fun apply(throwableObservable: Observable<Throwable?>): ObservableSource<Any?>? {
return throwableObservable.flatMap {
++current
CallerLogger.e("${flavorTag}${TAG}", " 时间:${TimeUtils.getStringByNow(0, TimeConstants.SEC)}")
if (it is OchCommonRetryException && current < timeDelys.size) {
Observable.timer(timeDelys[current].toLong(), TimeUnit.SECONDS)
} else {
Observable.error(it)
}
}
}
}

View File

@@ -0,0 +1,31 @@
package com.mogo.och.common.module.utils
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_TAXI
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_TAXI_P
object CallerLoggerUtils {
var flavorTag = when (DebugConfig.getProductFlavor()) {
"fPadLenovoOchTaxi" -> {
//出租车司机
M_TAXI
}
"fPadLenovoOchBus" -> {
//小巴车司机
M_BUS
}
"fPadLenovoOchTaxiPassenger" -> {
//出租车乘客
M_TAXI_P
}
"fPadLenovoOchBusPassenger" -> {
//小巴车乘客
M_BUS_P
}
else -> {
""
}
}
}

View File

@@ -0,0 +1,37 @@
package com.mogo.och.common.module.utils;
import android.text.TextUtils;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
public class FieldUtils {
public static Field getDeclaredField(final Class<?> cls, final String fieldName, final
boolean forceAccess) {
if (cls == null || TextUtils.isEmpty(fieldName)) {
return null;
}
try {
// only consider the specified class by using getDeclaredField()
final Field field = cls.getDeclaredField(fieldName);
if (!isAccessible(field)) {
if (forceAccess) {
field.setAccessible(true);
} else {
return null;
}
}
return field;
} catch (final Exception e) {
e.printStackTrace();
}
return null;
}
private static boolean isAccessible(final Member m) {
return m != null && Modifier.isPublic(m.getModifiers()) && !m.isSynthetic();
}
}

View File

@@ -0,0 +1,129 @@
package com.mogo.och.common.module.wigets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.ViewDebug;
import android.widget.TextView;
import com.mogo.och.common.module.R;
import com.mogo.och.common.module.utils.FieldUtils;
import java.lang.reflect.Field;
public class MarqueeTextView extends androidx.appcompat.widget.AppCompatTextView{
/**
* 上一次设置的时间,用于过滤多余操作
*/
private long mLastSetTime;
/**
* 自定义 gap
*/
private float mCustomGap = 0.3f;
/**
* 是否使用自定义 gap
*/
private boolean mUseCustomGap;
public MarqueeTextView(Context context) {
this(context, null);
}
public MarqueeTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MarqueeTextView);
mCustomGap = typedArray.getFloat(R.styleable.MarqueeTextView_customGap, mCustomGap);
mUseCustomGap = typedArray.getBoolean(R.styleable.MarqueeTextView_useCustomGap, false);
typedArray.recycle();
}
@Override
@ViewDebug.ExportedProperty(category = "focus")
public boolean isFocused() {
return true;
}
@Override
@ViewDebug.ExportedProperty
public boolean isSelected() {
return true;
}
@Override
public void invalidate() {
reflectToChangeGap();
super.invalidate();
}
private void reflectToChangeGap() {
if (!mUseCustomGap) {
return;
}
if (System.currentTimeMillis() - mLastSetTime < 1000) {
// 1s 内不重新设置,过滤多余操作
return;
}
try {
Class marqueClass = null;
Class[] innerClazz = TextView.class.getDeclaredClasses();
for (Class clazz : innerClazz) {
if ("Marquee".equals(clazz.getSimpleName())) {
marqueClass = clazz;
}
}
if (marqueClass == null) {
return;
}
Field field1 = FieldUtils.getDeclaredField(marqueClass, "mGhostStart", true);
if (field1 == null) {
return;
}
final int textWidth = getWidth() - getCompoundPaddingLeft() - getCompoundPaddingRight();
final float lineWidth = getLayout().getLineWidth(0);
final float gap = mCustomGap*textWidth;
float ghostStart = lineWidth - textWidth + gap;
float maxScroll = ghostStart + textWidth;
float ghostOffset = lineWidth + gap;
float maxFadeScroll = ghostStart + lineWidth + lineWidth;
final Field field = FieldUtils.getDeclaredField(TextView.class, "mMarquee", true);
if (field != null) {
Object mMarque = field.get(this);
if (mMarque != null) {
mLastSetTime = System.currentTimeMillis();
float mGhostStart = (float) field1.get(mMarque);
if (mGhostStart != ghostStart) {
// 需要设置的 mGhostStart 与当前 ghostStart 不相等时才去设置
Field field2 = FieldUtils.getDeclaredField(marqueClass, "mMaxScroll", true);
Field field3 = FieldUtils.getDeclaredField(marqueClass, "mGhostOffset", true);
Field field4 = FieldUtils.getDeclaredField(marqueClass, "mMaxFadeScroll", true);
if (field2 == null || field3 == null || field4 == null) {
return;
}
field1.set(mMarque, ghostStart);
field2.set(mMarque, maxScroll);
field3.set(mMarque, ghostOffset);
field4.set(mMarque, maxFadeScroll);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -52,4 +52,9 @@
<attr name="och_realtime_end_color" format="color" />
<attr name="och_realtime_radius" format="dimension" />
</declare-styleable>
<declare-styleable name="MarqueeTextView">
<attr name="customGap" format="float" />
<attr name="useCustomGap" format="boolean"/>
</declare-styleable>
</resources>

View File

@@ -34,6 +34,7 @@ import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
import com.mogo.och.common.module.utils.PinYinUtil;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerBaseRespBean;
@@ -53,7 +54,6 @@ import com.mogo.och.taxi.passenger.callback.ITaxiPassengerCommonValueCallback;
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerVeloctityCallback;
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum;
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceCallback;
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceManager;
import com.mogo.aicloud.services.socket.IMogoLifecycleListener;
import com.mogo.och.taxi.passenger.utils.TaxiPassengerAnalyticsManager;
@@ -290,8 +290,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
* 才更新最新进行中单到本地
*/
public void queryInAndWaitOrders() {
TaxiPassengerServiceManager.getInstance().queryOrdersInAndWaitService(mContext,
new TaxiPassengerServiceCallback<TaxiPassengerOrdersInServiceQueryRespBean>() {
TaxiPassengerServiceManager.queryOrdersInAndWaitService(mContext,
new OchCommonServiceCallback<TaxiPassengerOrdersInServiceQueryRespBean>() {
@Override
public void onSuccess(TaxiPassengerOrdersInServiceQueryRespBean data) {
if (data == null || data.data == null) {
@@ -348,8 +348,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
return;
}
final String orderNo = mCurrentOCHOrder.orderNo;
TaxiPassengerServiceManager.getInstance().queryOrderById(mContext, orderNo,
new TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRespBean>() {
TaxiPassengerServiceManager.queryOrderById(mContext, orderNo,
new OchCommonServiceCallback<TaxiPassengerOrderQueryRespBean>() {
@Override
public void onSuccess(TaxiPassengerOrderQueryRespBean data) {
if (data != null && data.data != null
@@ -718,7 +718,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
*/
public void queryOrderRemaining(){
if (mCurrentOCHOrder == null) return;
TaxiPassengerServiceManager.getInstance().queryOrderRemaining(mContext, mCurrentOCHOrder.orderNo, new TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRemainingResp>() {
TaxiPassengerServiceManager.queryOrderRemaining(mContext, mCurrentOCHOrder.orderNo, new OchCommonServiceCallback<TaxiPassengerOrderQueryRemainingResp>() {
@Override
public void onSuccess(TaxiPassengerOrderQueryRemainingResp data) {
if (data != null && data.data!=null){
@@ -739,7 +739,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
public void queryOrderRouteList() {
if (mCurrentOCHOrder == null) return;
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "--route--- queryOrderRouteList");
TaxiPassengerServiceManager.getInstance().queryOrderRouteList(mContext, mCurrentOCHOrder.orderNo, new TaxiPassengerServiceCallback<TaxiPassengerQueryOrderRouteResp>() {
TaxiPassengerServiceManager.queryOrderRouteList(mContext, mCurrentOCHOrder.orderNo, new OchCommonServiceCallback<TaxiPassengerQueryOrderRouteResp>() {
@Override
public void onSuccess(TaxiPassengerQueryOrderRouteResp data) {
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "--route---"+GsonUtil.jsonFromObject(data));
@@ -790,8 +790,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
public void checkPhoneAndUpdateStatus(String phoneTail,ITaxiPassengerCommonCallback commonCallback) {
if (mCurrentOCHOrder == null) return;
TaxiPassengerServiceManager.getInstance().checkPhoneAndUpdateOrderStatus(mContext, mCurrentOCHOrder.orderNo,
phoneTail, new TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean>() {
TaxiPassengerServiceManager.checkPhoneAndUpdateOrderStatus(mContext, mCurrentOCHOrder.orderNo,
phoneTail, new OchCommonServiceCallback<TaxiPassengerBaseRespBean>() {
@Override
public void onSuccess(TaxiPassengerBaseRespBean data) {
if (data != null && data.code == 0 && mCurrentOCHOrder != null){
@@ -824,8 +824,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
public void arrivedAndScore(TaxiPassengerScoreUpdateOrderReqBean taxiPassengerScoreUpdateOrderReqBean , ITaxiPassengerCommonValueCallback<Boolean> commonCallback) {
if (taxiPassengerScoreUpdateOrderReqBean.orderNo == null) return;
TaxiPassengerServiceManager.getInstance().arrivedAndScore(mContext,taxiPassengerScoreUpdateOrderReqBean,
new TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean>() {
TaxiPassengerServiceManager.arrivedAndScore(mContext,taxiPassengerScoreUpdateOrderReqBean,
new OchCommonServiceCallback<TaxiPassengerBaseRespBean>() {
@Override
public void onSuccess(TaxiPassengerBaseRespBean data) {
if(commonCallback!=null) {
@@ -854,8 +854,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
public void loopQueryPilotStatus(){
if (mCurrentOCHOrder == null) return;
TaxiPassengerServiceManager.getInstance().queryPilotStatus(mContext, mCurrentOCHOrder.orderNo,
new TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean>() {
TaxiPassengerServiceManager.queryPilotStatus(mContext, mCurrentOCHOrder.orderNo,
new OchCommonServiceCallback<TaxiPassengerBaseRespBean>() {
@Override
public void onSuccess(TaxiPassengerBaseRespBean data) {
if (data != null && data.code == 0 && data.data.equals(true)) {
@@ -898,9 +898,9 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
TaxiPassengerStartReqBean.Result result = new TaxiPassengerStartReqBean.Result();
result.lat = mLatitude;
result.lon = mLongitude;
TaxiPassengerServiceManager.getInstance().startServicePilotDone(mContext,
TaxiPassengerServiceManager.startServicePilotDone(mContext,
mCurrentOCHOrder.orderNo, result,
new TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean>(){
new OchCommonServiceCallback<TaxiPassengerBaseRespBean>(){
@Override
public void onSuccess(TaxiPassengerBaseRespBean data) {

View File

@@ -1,18 +0,0 @@
package com.mogo.och.taxi.passenger.network;
/**
* @author congtaowang
* @since 2021/1/15
*
* 修改订单状态回调接口
*/
public interface TaxiPassengerServiceCallback< T > {
void onSuccess(T data);
void onFail(int code, String msg);
default void onError() {
}
}

View File

@@ -1,208 +0,0 @@
package com.mogo.och.taxi.passenger.network;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
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.taxi.passenger.bean.TaxiPassengerAllStarWorld;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerBaseRespBean;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerCheckPhoneUpdateOrderReqBean;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryReqBean;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerQueryOrderRouteResp;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerScoreUpdateOrderReqBean;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerStartReqBean;
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
import com.mogo.commons.debug.DebugConfig;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by pangfan on 2021/8/19
*/
public class TaxiPassengerServiceManager {
private static final String TAG = TaxiPassengerServiceManager.class.getSimpleName();
private static final class SingletonHolder {
private static final TaxiPassengerServiceManager INSTANCE = new TaxiPassengerServiceManager();
}
public static TaxiPassengerServiceManager getInstance() {
return SingletonHolder.INSTANCE;
}
private TaxiPassengerServiceApi mOCHTaxiServiceApi;
private TaxiPassengerServiceManager() {
if (mOCHTaxiServiceApi == null){
mOCHTaxiServiceApi = MoGoRetrofitFactory.getInstance(TaxiPassengerConst.getBaseUrl()).create(TaxiPassengerServiceApi.class);
}
}
/**
* 获取司机端的sn
* @return
*/
private String getDriverAppSn(){
return CallerTelematicManager.INSTANCE.getServerToken();
}
/**
* 查询全部服务中/待服务订单列表
* @param context
* @param callback
*/
public void queryOrdersInAndWaitService(Context context,
TaxiPassengerServiceCallback<TaxiPassengerOrdersInServiceQueryRespBean> callback) {
mOCHTaxiServiceApi.queryOrdersInAndWaitService(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,getDriverAppSn()) //获取到司机端的sn
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrdersInAndWaitService"));
}
/**
* 查询订单剩余里程和时间
* @param context
* @param orderNo
* @param callback
*/
public void queryOrderRemaining(Context context, String orderNo, TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRemainingResp> callback){
mOCHTaxiServiceApi.queryOrderRemaining(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,orderNo)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrderRemaining"));
}
public void queryOrderRouteList(Context context, String orderNo, TaxiPassengerServiceCallback<TaxiPassengerQueryOrderRouteResp> callback){
mOCHTaxiServiceApi.queryOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,orderNo)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrderRouteList"));
}
/**
* 通过orderId查询订单信息用于本地已经有orderId时
* @param context
* @param orderNo
* @param callback
* @deprecated v2.1_0930需求中暂不再使用此接口
*/
public void queryOrderById(Context context, String orderNo,
TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRespBean> callback) {
mOCHTaxiServiceApi.queryOrderById(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiPassengerOrderQueryReqBean(getDriverAppSn(), orderNo))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrderById"));
}
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
Context context, TaxiPassengerServiceCallback<T> callback, String apiName) {
return new SubscribeImpl<T>(RequestOptions.create(context)) {
@Override
public void onSuccess(T o) {
super.onSuccess(o);
CallerLogger.INSTANCE.e(M_TAXI_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_TAXI_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_TAXI_P + TAG,String.format(apiName + ": onError() code = %d; message = %s;", code, message));
if (callback != null) {
callback.onFail(code, message);
}
}
};
}
public void checkPhoneAndUpdateOrderStatus(Context context, String orderNo,String phone ,TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean> callback){
mOCHTaxiServiceApi.checkPhoneAndUpdateOrderStatus(
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiPassengerCheckPhoneUpdateOrderReqBean(orderNo,phone))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"));
}
public void arrivedAndScore(Context context,TaxiPassengerScoreUpdateOrderReqBean taxiPassengerScoreUpdateOrderReqBean, TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean> callback){
mOCHTaxiServiceApi.arrivedAndScore(
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,taxiPassengerScoreUpdateOrderReqBean)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"));
}
public void getAllScoreWorld(Context context,TaxiPassengerServiceCallback<TaxiPassengerAllStarWorld> callback){
mOCHTaxiServiceApi.getWorldAllStar(
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "arrivedAndScore"));
}
public void queryPilotStatus(Context context, String orderNo
,TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean> callback){
mOCHTaxiServiceApi.queryPilotStatus(
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,orderNo)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryPilotStatus"));
}
public void startServicePilotDone(Context context,String orderNo,TaxiPassengerStartReqBean.Result loc
,TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean> callback){
mOCHTaxiServiceApi.startServicePilotDone(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiPassengerStartReqBean(getDriverAppSn()
,orderNo,loc))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"startServicePilotDone"));
}
public void getWorldByStar(Context context,String start,TaxiPassengerServiceCallback<TaxiPassengerAllStarWorld> callback){
mOCHTaxiServiceApi.getWorldByStar(
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken(),start)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"));
}
}

View File

@@ -0,0 +1,199 @@
package com.mogo.och.taxi.passenger.network
import android.content.Context
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst.Companion.getBaseUrl
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp
import com.mogo.och.taxi.passenger.bean.TaxiPassengerQueryOrderRouteResp
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryReqBean
import com.mogo.och.taxi.passenger.bean.TaxiPassengerBaseRespBean
import com.mogo.och.taxi.passenger.bean.TaxiPassengerCheckPhoneUpdateOrderReqBean
import com.mogo.och.taxi.passenger.bean.TaxiPassengerScoreUpdateOrderReqBean
import com.mogo.och.taxi.passenger.bean.TaxiPassengerAllStarWorld
import com.mogo.och.taxi.passenger.bean.TaxiPassengerStartReqBean
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 by pangfan on 2021/8/19
*/
object TaxiPassengerServiceManager {
private val mOCHTaxiServiceApi: TaxiPassengerServiceApi = MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
TaxiPassengerServiceApi::class.java
)
/**
* 获取司机端的sn
* @return
*/
private val driverAppSn: String
get() = getServerToken()
/**
* 查询全部服务中/待服务订单列表
* @param context
* @param callback
*/
@JvmStatic
fun queryOrdersInAndWaitService(
context: Context,
callback: OchCommonServiceCallback<TaxiPassengerOrdersInServiceQueryRespBean>?
) {
mOCHTaxiServiceApi.queryOrdersInAndWaitService(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
driverAppSn
) //获取到司机端的sn
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrdersInAndWaitService"))
}
/**
* 查询订单剩余里程和时间
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
fun queryOrderRemaining(
context: Context,
orderNo: String?,
callback: OchCommonServiceCallback<TaxiPassengerOrderQueryRemainingResp>?
) {
mOCHTaxiServiceApi.queryOrderRemaining(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
orderNo
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRemaining"))
}
@JvmStatic
fun queryOrderRouteList(
context: Context,
orderNo: String?,
callback: OchCommonServiceCallback<TaxiPassengerQueryOrderRouteResp>?
) {
mOCHTaxiServiceApi.queryOrderRoute(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
orderNo
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRouteList"))
}
/**
* 通过orderId查询订单信息用于本地已经有orderId时
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
@Deprecated("v2.1_0930需求中暂不再使用此接口")
fun queryOrderById(
context: Context, orderNo: String?,
callback: OchCommonServiceCallback<TaxiPassengerOrderQueryRespBean>?
) {
mOCHTaxiServiceApi.queryOrderById(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiPassengerOrderQueryReqBean(driverAppSn, orderNo)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderById"))
}
@JvmStatic
fun checkPhoneAndUpdateOrderStatus(
context: Context,
orderNo: String?,
phone: String?,
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
) {
mOCHTaxiServiceApi.checkPhoneAndUpdateOrderStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiPassengerCheckPhoneUpdateOrderReqBean(orderNo, phone)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
}
@JvmStatic
fun arrivedAndScore(
context: Context,
taxiPassengerScoreUpdateOrderReqBean: TaxiPassengerScoreUpdateOrderReqBean?,
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
) {
mOCHTaxiServiceApi.arrivedAndScore(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
taxiPassengerScoreUpdateOrderReqBean
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
}
@JvmStatic
fun getAllScoreWorld(
context: Context,
callback: OchCommonServiceCallback<TaxiPassengerAllStarWorld>?
) {
mOCHTaxiServiceApi.getWorldAllStar(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "arrivedAndScore"))
}
@JvmStatic
fun queryPilotStatus(
context: Context,
orderNo: String?,
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
) {
mOCHTaxiServiceApi.queryPilotStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
orderNo
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryPilotStatus"))
}
@JvmStatic
fun startServicePilotDone(
context: Context,
orderNo: String?,
loc: TaxiPassengerStartReqBean.Result?,
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
) {
mOCHTaxiServiceApi.startServicePilotDone(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiPassengerStartReqBean(
driverAppSn, orderNo, loc
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "startServicePilotDone"))
}
@JvmStatic
fun getWorldByStar(
context: Context,
start: String?,
callback: OchCommonServiceCallback<TaxiPassengerAllStarWorld>?
) {
mOCHTaxiServiceApi.getWorldByStar(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
start
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
}
}

View File

@@ -103,7 +103,7 @@ class TaxiPassengerCheckView :RelativeLayout, View.OnClickListener {
R.id.tv_taxi_passenger_number_second -> {selectIndex(1)}
R.id.tv_taxi_passenger_number_third -> {selectIndex(2)}
R.id.tv_taxi_passenger_number_fourth -> {selectIndex(3)}
R.id.tv_taxi_passenger_number_submit -> {checkAndCommit()}
R.id.tv_taxi_passenger_number_submit -> {clearNumber()}
else -> {}
}
}
@@ -130,9 +130,27 @@ class TaxiPassengerCheckView :RelativeLayout, View.OnClickListener {
index++
}
changeStyle()
numSelect.forEach {
if(it==null){
return
}
}
checkAndCommit()
}
}
private fun clearNumber(){
for(i in numSelect.indices){
numSelect[i] = null
}
numSelectTextView.forEach {
it?.text = ""
}
index = 0
changeStyle()
}
private fun deleteNumver() {
if (index in 0..3) {
if(numSelect[index]==null){

View File

@@ -25,13 +25,13 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.OverlayViewUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
import com.mogo.och.common.module.wigets.OCHBorderShadowLayout
import com.mogo.och.taxi.passenger.R
import com.mogo.och.taxi.passenger.bean.TaxiPassengerAllStarWorld
import com.mogo.och.taxi.passenger.bean.TaxiPassengerScoreUpdateOrderReqBean
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerCommonCallback
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerScoreCallback
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceCallback
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceManager
import com.mogo.och.taxi.passenger.ui.comment.adapter.CommentAdapter
import com.mogo.och.taxi.passenger.widget.ResizeAnimation
@@ -412,8 +412,8 @@ class TaxiPassengerArrivedView :RelativeLayout, View.OnClickListener {
}
private fun requestStarWord() {
TaxiPassengerServiceManager.getInstance().getAllScoreWorld(context,
object : TaxiPassengerServiceCallback<TaxiPassengerAllStarWorld?> {
TaxiPassengerServiceManager.getAllScoreWorld(context,
object : OchCommonServiceCallback<TaxiPassengerAllStarWorld> {
override fun onError() {
CallerLogger.e(
SceneConstant.M_TAXI_P + TAG,
@@ -436,8 +436,8 @@ class TaxiPassengerArrivedView :RelativeLayout, View.OnClickListener {
}
private fun requestStarWordByStar(start:Int) {
TaxiPassengerServiceManager.getInstance().getWorldByStar(context,start.toString(),
object : TaxiPassengerServiceCallback<TaxiPassengerAllStarWorld?> {
TaxiPassengerServiceManager.getWorldByStar(context,start.toString(),
object : OchCommonServiceCallback<TaxiPassengerAllStarWorld> {
override fun onError() {
CallerLogger.e(
SceneConstant.M_TAXI_P + TAG,

View File

@@ -189,7 +189,7 @@
android:layout_marginTop="@dimen/dp_14"
tools:text="蘑菇 3291号为您服务"
android:textColor="@color/taxi_p_check_keyboard_samll_mogo_color"
android:textSize="@dimen/dp_24"
android:textSize="24px"
app:layout_constraintStart_toStartOf="@+id/tv_small_mogo"
app:layout_constraintTop_toBottomOf="@+id/tv_small_mogo" />
@@ -198,12 +198,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_84"
android:layout_marginTop="@dimen/dp_129"
android:layout_marginTop="308px"
android:text="@string/taxi_p_check_input_phone_tail_title"
android:textColor="@color/taxi_p_check_keyboard_samll_mogo_color"
android:textSize="@dimen/sp_36"
android:textSize="@dimen/dp_36"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_taxi_number" />
app:layout_constraintTop_toTopOf="parent" />
<TextView
@@ -246,11 +246,12 @@
<TextView
android:id="@+id/tv_taxi_passenger_number_nine"
android:layout_marginEnd="@dimen/dp_30"
android:layout_marginBottom="@dimen/dp_98"
android:id="@+id/tv_taxi_passenger_number_back"
android:layout_marginEnd="@dimen/dp_39"
android:layout_marginBottom="@dimen/dp_80"
style="@style/och_check_number_keyboard"
android:text="9"
android:text="@string/tv_delete"
android:textSize="@dimen/dp_36"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_zero"
app:layout_constraintHorizontal_chainStyle="packed"
@@ -258,81 +259,87 @@
<TextView
android:id="@+id/tv_taxi_passenger_number_zero"
android:layout_marginEnd="@dimen/dp_30"
android:layout_marginEnd="@dimen/dp_39"
android:text="0"
style="@style/och_check_number_keyboard"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_back"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_nine"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_nine" />
<TextView
android:id="@+id/tv_taxi_passenger_number_back"
android:layout_marginEnd="@dimen/dp_30"
android:background="@drawable/bg_taxi_p_keyboard_background"
android:text="@string/tv_delete"
style="@style/och_check_number_keyboard"
android:textSize="@dimen/sp_36"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_submit"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_zero"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_nine" />
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_back"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_back" />
<TextView
android:id="@+id/tv_taxi_passenger_number_submit"
style="@style/och_check_number_keyboard"
android:background="@drawable/bg_taxi_p_keyboard_submit_background"
android:text="确定"
android:textColor="@color/taxi_autopilot_text_color_normal"
android:text="清空"
android:textSize="@dimen/sp_36"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_back"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_nine" />
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_zero"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_back" />
<TextView
android:id="@+id/tv_taxi_passenger_number_five"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_30"
android:layout_marginBottom="@dimen/dp_30"
android:text="5"
app:layout_constraintBottom_toTopOf="@id/tv_taxi_passenger_number_nine"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_six"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tv_taxi_passenger_number_six"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_30"
android:text="6"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_seven"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_five"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_five" />
<TextView
android:id="@+id/tv_taxi_passenger_number_seven"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_30"
android:background="@drawable/bg_taxi_p_keyboard_background"
android:layout_marginEnd="@dimen/dp_39"
android:layout_marginBottom="24px"
android:text="7"
app:layout_constraintBottom_toTopOf="@id/tv_taxi_passenger_number_back"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_eight"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_six"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_five" />
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tv_taxi_passenger_number_eight"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_39"
android:text="8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_nine"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_seven"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_five" />
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_seven" />
<TextView
android:id="@+id/tv_taxi_passenger_number_nine"
style="@style/och_check_number_keyboard"
android:text="9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_eight"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_seven" />
<TextView
android:id="@+id/tv_taxi_passenger_number_four"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_39"
android:layout_marginBottom="24px"
android:text="4"
app:layout_constraintBottom_toTopOf="@id/tv_taxi_passenger_number_seven"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_five"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tv_taxi_passenger_number_five"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_39"
android:text="5"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_six"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_four"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_four" />
<TextView
android:id="@+id/tv_taxi_passenger_number_six"
style="@style/och_check_number_keyboard"
android:text="6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_five"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_four" />
<TextView
android:id="@+id/tv_taxi_passenger_number_one"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_30"
android:layout_marginBottom="@dimen/dp_30"
android:layout_marginEnd="@dimen/dp_39"
android:layout_marginBottom="24px"
android:text="1"
app:layout_constraintBottom_toTopOf="@id/tv_taxi_passenger_number_five"
app:layout_constraintBottom_toTopOf="@id/tv_taxi_passenger_number_four"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_two"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" />
@@ -340,7 +347,7 @@
<TextView
android:id="@+id/tv_taxi_passenger_number_two"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_30"
android:layout_marginEnd="@dimen/dp_39"
android:text="2"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_three"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_one"
@@ -349,18 +356,9 @@
<TextView
android:id="@+id/tv_taxi_passenger_number_three"
style="@style/och_check_number_keyboard"
android:layout_marginEnd="@dimen/dp_30"
android:text="3"
app:layout_constraintEnd_toStartOf="@+id/tv_taxi_passenger_number_four"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_two"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_one" />
<TextView
android:id="@+id/tv_taxi_passenger_number_four"
style="@style/och_check_number_keyboard"
android:text="4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_three"
app:layout_constraintStart_toEndOf="@+id/tv_taxi_passenger_number_two"
app:layout_constraintTop_toTopOf="@+id/tv_taxi_passenger_number_one" />

View File

@@ -28,7 +28,7 @@
</style>
<style name="och_check_number_keyboard">
<item name="android:layout_width">@dimen/dp_150</item>
<item name="android:layout_width">@dimen/dp_212</item>
<item name="android:layout_height">@dimen/dp_80</item>
<item name="android:background">@drawable/bg_taxi_p_keyboard_background</item>
<item name="android:gravity">center</item>

View File

@@ -36,6 +36,7 @@ import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.och.common.module.biz.constant.LoginStatusManager;
import com.mogo.och.common.module.biz.constant.OchCommonConst;
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
import com.mogo.och.common.module.biz.provider.LoginService;
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
@@ -64,7 +65,6 @@ import com.mogo.och.taxi.constant.TaxiConst;
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum;
import com.mogo.och.taxi.constant.TaxiOrderTypeEnum;
import com.mogo.och.taxi.constant.TaxtServingStatusManager;
import com.mogo.och.taxi.network.TaxiServiceCallback;
import com.mogo.och.taxi.network.TaxiServiceManager;
import com.mogo.och.taxi.utils.TaxiAnalyticsManager;
import com.mogo.och.taxi.utils.OrderUtil;
@@ -272,8 +272,8 @@ public class TaxiModel {
loginService.queryLoginStatusByNet();
return;
}
TaxiServiceManager.getInstance().changeOrderServing(mContext,TaxtServingStatusManager.isOpeningOrderStatus(),
new TaxiServiceCallback<BaseData>() {
TaxiServiceManager.changeOrderServing(mContext,TaxtServingStatusManager.isOpeningOrderStatus(),
new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
if (null != data && 0 == data.code) {
@@ -305,8 +305,8 @@ public class TaxiModel {
* 才更新最新进行中单到本地
*/
public void queryInAndWaitOrders() {
TaxiServiceManager.getInstance().queryOrdersInAndWaitService(mContext,
new TaxiServiceCallback<OrdersInServiceQueryRespBean>() {
TaxiServiceManager.queryOrdersInAndWaitService(mContext,
new OchCommonServiceCallback<OrdersInServiceQueryRespBean>() {
@Override
public void onSuccess(OrdersInServiceQueryRespBean data) {
if (data == null || data.data == null) {
@@ -381,8 +381,8 @@ public class TaxiModel {
return;
}
final String orderNo = mCurrentOCHOrder.orderNo;
TaxiServiceManager.getInstance().queryOrderById(mContext, orderNo,
new TaxiServiceCallback<OrderQueryRespBean>() {
TaxiServiceManager.queryOrderById(mContext, orderNo,
new OchCommonServiceCallback<OrderQueryRespBean>() {
@Override
public void onSuccess(OrderQueryRespBean data) {
if (data != null && data.data != null
@@ -415,8 +415,8 @@ public class TaxiModel {
return;
}
final String orderNo = mCurrentOCHOrder.orderNo;
TaxiServiceManager.getInstance().cancelOrder(mContext, orderNo, reasonType, reason,
new TaxiServiceCallback<BaseData>() {
TaxiServiceManager.cancelOrder(mContext, orderNo, reasonType, reason,
new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
if (null != data && 0 == data.code
@@ -447,8 +447,8 @@ public class TaxiModel {
// 取消待服务中订单
public void cancelOrderById(final String orderNo, int reasonType, String reason) {
TaxiServiceManager.getInstance().cancelOrder(mContext, orderNo, reasonType, reason,
new TaxiServiceCallback<BaseData>() {
TaxiServiceManager.cancelOrder(mContext, orderNo, reasonType, reason,
new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
if (null != data && 0 == data.code) {
@@ -480,8 +480,8 @@ public class TaxiModel {
return;
}
final String orderNo = mCurrentOCHOrder.orderNo;
TaxiServiceManager.getInstance().queryOrderRouteInfo(mContext, orderNo,
new TaxiServiceCallback<OrderQueryRouteInfoRespBean>() {
TaxiServiceManager.queryOrderRouteInfo(mContext, orderNo,
new OchCommonServiceCallback<OrderQueryRouteInfoRespBean>() {
@Override
public void onSuccess(OrderQueryRouteInfoRespBean data) {
if (null != data && 0 == data.code
@@ -501,8 +501,8 @@ public class TaxiModel {
// 获取全部订单列表
public void queryOrdersList(int page, int size) {
TaxiServiceManager.getInstance().queryOrdersList(mContext, page, size,
new TaxiServiceCallback<OrdersListQueryRespBean>() {
TaxiServiceManager.queryOrdersList(mContext, page, size,
new OchCommonServiceCallback<OrdersListQueryRespBean>() {
@Override
public void onSuccess(OrdersListQueryRespBean data) {
if (null != data && 0 == data.code) {
@@ -534,8 +534,8 @@ public class TaxiModel {
* 注只有在本地缓存mNewBookingOrder为null时执行完抢单or司机关闭改单才更新新到待抢单
*/
public void queryNewBookingOrder() {
TaxiServiceManager.getInstance().queryNewBookingOrder(mContext,
new TaxiServiceCallback<OrdersNewBookingQueryRespBean>() {
TaxiServiceManager.queryNewBookingOrder(mContext,
new OchCommonServiceCallback<OrdersNewBookingQueryRespBean>() {
@Override
public void onSuccess(OrdersNewBookingQueryRespBean data) {
if (data != null && data.code == 0
@@ -562,8 +562,8 @@ public class TaxiModel {
// 仅限于获取到新待抢单且需要展示时查询该单信息queryOrderById接口可以查询属于该车的单、未派的单
private void queryNewBookingContent(final String orderNo) {
TaxiServiceManager.getInstance().queryOrderById(mContext, orderNo,
new TaxiServiceCallback<OrderQueryRespBean>() {
TaxiServiceManager.queryOrderById(mContext, orderNo,
new OchCommonServiceCallback<OrderQueryRespBean>() {
@Override
public void onSuccess(OrderQueryRespBean data) {
if (data != null && data.code == 0
@@ -593,8 +593,8 @@ public class TaxiModel {
return;
}
final String orderNo = mNewBookingOrder.orderNo;
TaxiServiceManager.getInstance().grabOrder(mContext, orderNo,
new TaxiServiceCallback<OrderGrabRespBean>() {
TaxiServiceManager.grabOrder(mContext, orderNo,
new OchCommonServiceCallback<OrderGrabRespBean>() {
@Override
public void onSuccess(OrderGrabRespBean data) {
if (data != null && data.code == 0
@@ -632,8 +632,8 @@ public class TaxiModel {
return;
}
final String orderNo = mNewBookingOrder.orderNo;
TaxiServiceManager.getInstance().queryOrderGrabStatus(mContext, orderNo,
new TaxiServiceCallback<OrderGrabStatusQueryRespBean>() {
TaxiServiceManager.queryOrderGrabStatus(mContext, orderNo,
new OchCommonServiceCallback<OrderGrabStatusQueryRespBean>() {
@Override
public void onSuccess(OrderGrabStatusQueryRespBean data) {
//TaxiModelLoopManager.getInstance().stopGrabResultLoop();
@@ -671,8 +671,8 @@ public class TaxiModel {
// 车机端上传心跳数据(只在出车状态时上传)
public void runCarHeartbeat() {
TaxiServiceManager.getInstance().runCarHeartbeat(mContext, mLongitude, mLatitude,
new TaxiServiceCallback<BaseData>() {
TaxiServiceManager.runCarHeartbeat(mContext, mLongitude, mLatitude,
new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
@@ -687,8 +687,8 @@ public class TaxiModel {
// 查询司机服务数据
public void queryDriverServiceData() {
TaxiServiceManager.getInstance().queryDriverServiceData(mContext,
new TaxiServiceCallback<DriverServiceDataRespBean>() {
TaxiServiceManager.queryDriverServiceData(mContext,
new OchCommonServiceCallback<DriverServiceDataRespBean>() {
@Override
public void onSuccess(DriverServiceDataRespBean data) {
if (data != null && data.code == 0
@@ -724,10 +724,10 @@ public class TaxiModel {
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
result.lat = mLatitude;
result.lon = mLongitude;
TaxiServiceManager.getInstance().confirmAutopilotConditionByDriver(mContext,
TaxiServiceManager.confirmAutopilotConditionByDriver(mContext,
mCurrentOCHOrder.orderNo,
result,
new TaxiServiceCallback<TaxiDataBaseRespBean>(){
new OchCommonServiceCallback<TaxiDataBaseRespBean>(){
@Override
public void onSuccess(TaxiDataBaseRespBean data) {
@@ -755,8 +755,8 @@ public class TaxiModel {
public void queryAutopilotStatus(){
if (mCurrentOCHOrder == null) return;
TaxiServiceManager.getInstance().queryAutopilotStatus(mContext, mCurrentOCHOrder.orderNo,
new TaxiServiceCallback<TaxiDataBaseRespBean>() {
TaxiServiceManager.queryAutopilotStatus(mContext, mCurrentOCHOrder.orderNo,
new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
@Override
public void onSuccess(TaxiDataBaseRespBean data) {
if (data != null && data.code == 0)
@@ -1278,8 +1278,8 @@ public class TaxiModel {
public void updateOrderRoute(List<MessagePad.Location> models) {
if (null == mCurrentOCHOrder) return;
List<OrderRouteUpdateReqBean.Result> points = coordinateConverterWgsToGcjList(mContext, models);
TaxiServiceManager.getInstance().updateOrderRoute(mContext, mCurrentOCHOrder.orderNo
, points, new TaxiServiceCallback<BaseData>() {
TaxiServiceManager.updateOrderRoute(mContext, mCurrentOCHOrder.orderNo
, points, new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
@@ -1404,8 +1404,8 @@ public class TaxiModel {
*/
private void queryOrderRouteList(String orderNo) {
if (mCurrentOCHOrder != null) {
TaxiServiceManager.getInstance().queryOrderRoute(mContext, orderNo,
new TaxiServiceCallback<QueryOrderRouteResp>() {
TaxiServiceManager.queryOrderRoute(mContext, orderNo,
new OchCommonServiceCallback<QueryOrderRouteResp>() {
@Override
public void onSuccess(QueryOrderRouteResp data) {
if (data != null && data.data != null && mRoutePoints.size() == 0) {
@@ -1450,8 +1450,8 @@ public class TaxiModel {
*/
public void reportOrderRemain(long lastSumLength, long duration) {// 米/秒
if (mCurrentOCHOrder == null) return;
TaxiServiceManager.getInstance().reportOrderRemain(mContext, mCurrentOCHOrder.orderNo
, lastSumLength, duration, new TaxiServiceCallback<BaseData>() {
TaxiServiceManager.reportOrderRemain(mContext, mCurrentOCHOrder.orderNo
, lastSumLength, duration, new OchCommonServiceCallback<BaseData>() {
@Override
public void onSuccess(BaseData data) {
@@ -1476,10 +1476,10 @@ public class TaxiModel {
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
result.lat = mLatitude;
result.lon = mLongitude;
TaxiServiceManager.getInstance().updatePassengerHasBoardedStatus(mContext
TaxiServiceManager.updatePassengerHasBoardedStatus(mContext
, mCurrentOCHOrder.orderNo
, result
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
@Override
public void onSuccess(TaxiDataBaseRespBean data) {
@@ -1498,10 +1498,10 @@ public class TaxiModel {
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
result.lat = mLatitude;
result.lon = mLongitude;
TaxiServiceManager.getInstance().startServicePilotDone(mContext
TaxiServiceManager.startServicePilotDone(mContext
, mCurrentOCHOrder.orderNo
, result
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
@Override
public void onSuccess(TaxiDataBaseRespBean data) {
@@ -1518,10 +1518,10 @@ public class TaxiModel {
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
result.lat = mLatitude;
result.lon = mLongitude;
TaxiServiceManager.getInstance().arrivedStartPoint(mContext
TaxiServiceManager.arrivedStartPoint(mContext
, mCurrentOCHOrder.orderNo
, result
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
@Override
public void onSuccess(TaxiDataBaseRespBean data) {
@@ -1539,10 +1539,10 @@ public class TaxiModel {
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
result.lat = mLatitude;
result.lon = mLongitude;
TaxiServiceManager.getInstance().arriveTerminal(mContext
TaxiServiceManager.arriveTerminal(mContext
, mCurrentOCHOrder.orderNo
, result
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
@Override
public void onSuccess(TaxiDataBaseRespBean data) {
@@ -1560,10 +1560,10 @@ public class TaxiModel {
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
result.lat = mLatitude;
result.lon = mLongitude;
TaxiServiceManager.getInstance().orderCompleted(mContext
TaxiServiceManager.orderCompleted(mContext
, mCurrentOCHOrder.orderNo
, result
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
@Override
public void onSuccess(TaxiDataBaseRespBean data) {
}

View File

@@ -1,18 +0,0 @@
package com.mogo.och.taxi.network;
/**
* @author congtaowang
* @since 2021/1/15
*
* 修改订单状态回调接口
*/
public interface TaxiServiceCallback< T > {
void onSuccess(T data);
void onFail(int code, String msg);
default void onError() {
}
}

View File

@@ -1,463 +0,0 @@
package com.mogo.och.taxi.network;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
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.taxi.bean.CarHeartbeatReqBean;
import com.mogo.och.taxi.bean.DriverServiceDataRespBean;
import com.mogo.och.taxi.bean.DriverStatusUpdateReqBean;
import com.mogo.och.taxi.bean.OrderCancelReqBean;
import com.mogo.och.taxi.bean.OrderGrabReqBean;
import com.mogo.och.taxi.bean.OrderGrabRespBean;
import com.mogo.och.taxi.bean.OrderGrabStatusQueryRespBean;
import com.mogo.och.taxi.bean.OrderQueryReqBean;
import com.mogo.och.taxi.bean.OrderQueryRespBean;
import com.mogo.och.taxi.bean.OrderQueryRouteInfoReqBean;
import com.mogo.och.taxi.bean.OrderQueryRouteInfoRespBean;
import com.mogo.och.taxi.bean.OrderRouteUpdateReqBean;
import com.mogo.och.taxi.bean.OrderStatusUpdateReqBean;
import com.mogo.och.taxi.bean.OrdersInServiceQueryRespBean;
import com.mogo.och.taxi.bean.OrdersListQueryReqBean;
import com.mogo.och.taxi.bean.OrdersListQueryRespBean;
import com.mogo.och.taxi.bean.OrdersNewBookingQueryRespBean;
import com.mogo.och.taxi.bean.QueryOrderRouteResp;
import com.mogo.och.taxi.bean.TaxiDataBaseRespBean;
import com.mogo.och.taxi.bean.TaxiOrPassengerReadyReqBean;
import com.mogo.och.taxi.bean.UpdateOrderDisAndTimeReqBean;
import com.mogo.och.taxi.constant.TaxiConst;
import java.util.List;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by pangfan on 2021/8/19
*/
public class TaxiServiceManager {
private static final String TAG = TaxiServiceManager.class.getSimpleName();
private static final class SingletonHolder {
private static final TaxiServiceManager INSTANCE = new TaxiServiceManager();
}
public static TaxiServiceManager getInstance() {
return SingletonHolder.INSTANCE;
}
private TaxiServiceApiNew mOCHTaxiServiceApi;
private TaxiServiceManager() {
if (mOCHTaxiServiceApi == null){
mOCHTaxiServiceApi = MoGoRetrofitFactory.getInstance(TaxiConst.getBaseUrl()).create(TaxiServiceApiNew.class);
}
}
/**
* 查询全部服务中/待服务订单列表
* @param context
* @param callback
*/
public void queryOrdersInAndWaitService(Context context,
TaxiServiceCallback<OrdersInServiceQueryRespBean> callback) {
mOCHTaxiServiceApi.queryOrdersInAndWaitService(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,MoGoAiCloudClientConfig.getInstance().getSn())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrdersInAndWaitService"));
}
/**
* 查询新到的预约单
* @param context
* @param callback
*/
public void queryNewBookingOrder(Context context,
TaxiServiceCallback<OrdersNewBookingQueryRespBean> callback) {
mOCHTaxiServiceApi.queryNewBookingOrder(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,MoGoAiCloudClientConfig.getInstance().getSn())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryNewBookingOrder"));
}
/**
* (预约单)执行抢单动作
* @param context
* @param orderNo
* @param callback
*/
public void grabOrder(Context context, String orderNo,
TaxiServiceCallback<OrderGrabRespBean> callback) {
mOCHTaxiServiceApi.grabOrder(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new OrderGrabReqBean(
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "grabOrder"));
}
/**
* (预约单)查询抢单结果
* @param context
* @param orderNo
* @param callback
*/
public void queryOrderGrabStatus(Context context, String orderNo,
TaxiServiceCallback<OrderGrabStatusQueryRespBean> callback) {
mOCHTaxiServiceApi.queryOrderGrabStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new OrderGrabReqBean(
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrderGrabStatus"));
}
/**
* 查询订单路径规划信息(到上车点、起始点间的距离和预估时间)
* @param context
* @param orderNo
* @param callback
*/
public void queryOrderRouteInfo(Context context, String orderNo,
TaxiServiceCallback<OrderQueryRouteInfoRespBean> callback) {
mOCHTaxiServiceApi.queryOrderRouteInfo(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new OrderQueryRouteInfoReqBean(
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrderRouteInfo"));
}
/**
* 通过orderId查询订单信息用于本地已经有orderId时
* @param context
* @param orderNo
* @param callback
* @deprecated v2.1_0930需求中暂不再使用此接口
*/
public void queryOrderById(Context context, String orderNo,
TaxiServiceCallback<OrderQueryRespBean> callback) {
mOCHTaxiServiceApi.queryOrderById(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new OrderQueryReqBean(
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrderById"));
}
/**
* 查询未完成态订单信息用于本地无orderId时
* 如果有多条,只会返回时间最近的一条
* @param context
* @param callback
* @deprecated v2.1_0930需求中暂不再使用此接口
*/
public void queryOrderInService(Context context,
TaxiServiceCallback<OrderQueryRespBean> callback) {
mOCHTaxiServiceApi.queryOrderInService(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,MoGoAiCloudClientConfig.getInstance().getSn())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrderInService"));
}
/**
* 司机取消订单
* @param context
* @param orderNo
* @param cancelType
* @param cancelReason
* @param callback
*/
public void cancelOrder(Context context, String orderNo, int cancelType, String cancelReason,
TaxiServiceCallback<BaseData> callback) {
mOCHTaxiServiceApi.cancelOrder(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new OrderCancelReqBean(
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo, cancelType, cancelReason))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "cancelOrder"));
}
/**
* 订单列表获取
* @param context
* @param page
* @param size
* @param callback
*/
public void queryOrdersList(Context context, int page, int size,
TaxiServiceCallback<OrdersListQueryRespBean> callback) {
mOCHTaxiServiceApi.queryOrdersList(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new OrdersListQueryReqBean(
MoGoAiCloudClientConfig.getInstance().getSn(), page, size))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryOrdersList"));
}
/**
* 订单状态更新
* @param context
* @param orderNo
* @param orderStatus
* @param callback
*/
public void updateOrderStatus(Context context, String orderNo, int orderStatus,
TaxiServiceCallback<BaseData> callback) {
mOCHTaxiServiceApi.updateOrderStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new OrderStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo, orderStatus))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "updateOrderStatus"));
}
/**
* 暂停接单
* @param context
* @param callback
*/
public void changeOrderServing(Context context,boolean isOrdering,
TaxiServiceCallback<BaseData> callback) {
Observable<BaseData> baseDataObservable = null;
if(isOrdering) {// 正在接单去暂停
baseDataObservable = mOCHTaxiServiceApi.stopOrderServing(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new DriverStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().getSn()));
}else {// 没有接单去接单
baseDataObservable = mOCHTaxiServiceApi.resetOrderServing(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
, MoGoAiCloudClientConfig.getInstance().getToken()
, new DriverStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().getSn()));
}
baseDataObservable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "updateDriverServiceStatus"));
}
/**
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
* @param context
* @param lon
* @param lat
* @param callback
*/
public void runCarHeartbeat(Context context, double lon, double lat,
TaxiServiceCallback<BaseData> callback) {
mOCHTaxiServiceApi.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"));
}
/**
* 查询司机服务数据
* @param context
* @param callback
*/
public void queryDriverServiceData(Context context,
TaxiServiceCallback<DriverServiceDataRespBean> callback) {
mOCHTaxiServiceApi.queryServiceData(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,MoGoAiCloudClientConfig.getInstance().getSn())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "queryDriverServiceData"));
}
/**
* 根据订单上传工控机返回的全路径规划数据
* @param context
* @param orderNo
* @param callback
*/
public void updateOrderRoute(Context context, String orderNo, List<OrderRouteUpdateReqBean.Result> points,
TaxiServiceCallback<BaseData> callback){
mOCHTaxiServiceApi.updateOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new OrderRouteUpdateReqBean(orderNo,points))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"updateOrderRoute"));
}
/**
* 上报剩余里程,时间
* @param context
* @param orderNo
* @param distance
* @param duration
* @param callback
*/
public void reportOrderRemain(Context context, String orderNo, long distance, long duration
, TaxiServiceCallback<BaseData> callback){
mOCHTaxiServiceApi.reportOrderRemain(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new UpdateOrderDisAndTimeReqBean(orderNo,distance,duration))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"reportOrderRemain"));
}
/**
* 查询订单全路径
* @param context
* @param orderNo
* @param callback
*/
public void queryOrderRoute(Context context, String orderNo, TaxiServiceCallback<QueryOrderRouteResp> callback) {
mOCHTaxiServiceApi.queryOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,orderNo)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"queryOrderRoute"));
}
public void confirmAutopilotConditionByDriver(Context context, String orderNo
, TaxiOrPassengerReadyReqBean.Result loc
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
mOCHTaxiServiceApi.confirmAutopilotConditionByDriver(
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
,orderNo,loc))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"confirmAutopilotConditionByDriver"));
}
public void queryAutopilotStatus(Context context, String orderNo,
TaxiServiceCallback<TaxiDataBaseRespBean> callback){
mOCHTaxiServiceApi.queryPilotStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,orderNo)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context,callback,"queryAutopilotStatus"));
}
public void updatePassengerHasBoardedStatus(Context context, String orderNo
, TaxiOrPassengerReadyReqBean.Result loc
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
mOCHTaxiServiceApi.updatePassengerHasBoardedStatus(
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
,orderNo,loc))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "updatePassengerHasBoardedStatus"));
}
public void startServicePilotDone(Context context, String orderNo
, TaxiOrPassengerReadyReqBean.Result loc
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
mOCHTaxiServiceApi.startServicePilotDone(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
,orderNo,loc))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "startServicePilotDone"));
}
public void arrivedStartPoint(Context context, String orderNo
, TaxiOrPassengerReadyReqBean.Result loc
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
mOCHTaxiServiceApi.arrivedStartPoint(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
,orderNo,loc))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "arrivedStartPoint"));
}
public void arriveTerminal(Context context, String orderNo
, TaxiOrPassengerReadyReqBean.Result loc
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
mOCHTaxiServiceApi.arriveTerminal(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
,orderNo,loc))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "arriveTerminal"));
}
public void orderCompleted(Context context, String orderNo
, TaxiOrPassengerReadyReqBean.Result loc
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
mOCHTaxiServiceApi.orderCompleted(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
,MoGoAiCloudClientConfig.getInstance().getToken()
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
,orderNo,loc))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSubscribeImpl(context, callback, "orderCompleted"));
}
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
Context context, TaxiServiceCallback<T> callback, String apiName) {
return new SubscribeImpl<T>(RequestOptions.create(context)) {
@Override
public void onSuccess(T o) {
super.onSuccess(o);
CallerLogger.INSTANCE.d(M_TAXI + TAG,apiName + ": onSuccess() " + o.msg);
if (callback != null) {
callback.onSuccess(o);
}
}
@Override
public void onError(Throwable e) {
super.onError(e);
CallerLogger.INSTANCE.e(M_TAXI + 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_TAXI + TAG,String.format(apiName + ": onError() code = %d; message = %s;", code, message));
if (callback != null) {
callback.onFail(code, message);
}
}
};
}
}

View File

@@ -0,0 +1,497 @@
package com.mogo.och.taxi.network
import android.content.Context
import com.mogo.och.taxi.constant.TaxiConst.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.common.module.biz.network.OchCommonServiceCallback
import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl
import com.mogo.och.common.module.biz.network.interceptor.transformTry
import com.mogo.och.taxi.bean.*
import io.reactivex.Observable
/**
* Created by pangfan on 2021/8/19
*/
object TaxiServiceManager {
private var mOCHTaxiServiceApi: TaxiServiceApiNew =
MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
TaxiServiceApiNew::class.java
)
/**
* 查询全部服务中/待服务订单列表
* @param context
* @param callback
*/
@JvmStatic
fun queryOrdersInAndWaitService(
context: Context,
callback: OchCommonServiceCallback<OrdersInServiceQueryRespBean>?
) {
mOCHTaxiServiceApi.queryOrdersInAndWaitService(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
MoGoAiCloudClientConfig.getInstance().sn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrdersInAndWaitService"))
}
/**
* 查询新到的预约单
* @param context
* @param callback
*/
@JvmStatic
fun queryNewBookingOrder(
context: Context,
callback: OchCommonServiceCallback<OrdersNewBookingQueryRespBean>?
) {
mOCHTaxiServiceApi.queryNewBookingOrder(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
MoGoAiCloudClientConfig.getInstance().sn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryNewBookingOrder"))
}
/**
* (预约单)执行抢单动作
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
fun grabOrder(
context: Context, orderNo: String?,
callback: OchCommonServiceCallback<OrderGrabRespBean>?
) {
mOCHTaxiServiceApi.grabOrder(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
OrderGrabReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "grabOrder"))
}
/**
* (预约单)查询抢单结果
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
fun queryOrderGrabStatus(
context: Context, orderNo: String?,
callback: OchCommonServiceCallback<OrderGrabStatusQueryRespBean>?
) {
mOCHTaxiServiceApi.queryOrderGrabStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
OrderGrabReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderGrabStatus"))
}
/**
* 查询订单路径规划信息(到上车点、起始点间的距离和预估时间)
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
fun queryOrderRouteInfo(
context: Context, orderNo: String?,
callback: OchCommonServiceCallback<OrderQueryRouteInfoRespBean>?
) {
mOCHTaxiServiceApi.queryOrderRouteInfo(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
OrderQueryRouteInfoReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRouteInfo"))
}
/**
* 通过orderId查询订单信息用于本地已经有orderId时
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
@Deprecated("v2.1_0930需求中暂不再使用此接口")
fun queryOrderById(
context: Context, orderNo: String?,
callback: OchCommonServiceCallback<OrderQueryRespBean>?
) {
mOCHTaxiServiceApi.queryOrderById(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
OrderQueryReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderById"))
}
/**
* 查询未完成态订单信息用于本地无orderId时
* 如果有多条,只会返回时间最近的一条
* @param context
* @param callback
*/
@JvmStatic
@Deprecated("v2.1_0930需求中暂不再使用此接口")
fun queryOrderInService(
context: Context,
callback: OchCommonServiceCallback<OrderQueryRespBean>?
) {
mOCHTaxiServiceApi.queryOrderInService(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
MoGoAiCloudClientConfig.getInstance().sn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderInService"))
}
/**
* 司机取消订单
* @param context
* @param orderNo
* @param cancelType
* @param cancelReason
* @param callback
*/
@JvmStatic
fun cancelOrder(
context: Context, orderNo: String?, cancelType: Int, cancelReason: String?,
callback: OchCommonServiceCallback<BaseData>?
) {
mOCHTaxiServiceApi.cancelOrder(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
OrderCancelReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo, cancelType, cancelReason
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "cancelOrder"))
}
/**
* 订单列表获取
* @param context
* @param page
* @param size
* @param callback
*/
@JvmStatic
fun queryOrdersList(
context: Context, page: Int, size: Int,
callback: OchCommonServiceCallback<OrdersListQueryRespBean>?
) {
mOCHTaxiServiceApi.queryOrdersList(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
OrdersListQueryReqBean(
MoGoAiCloudClientConfig.getInstance().sn, page, size
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrdersList"))
}
/**
* 订单状态更新
* @param context
* @param orderNo
* @param orderStatus
* @param callback
*/
@JvmStatic
fun updateOrderStatus(
context: Context, orderNo: String?, orderStatus: Int,
callback: OchCommonServiceCallback<BaseData>?
) {
mOCHTaxiServiceApi.updateOrderStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
OrderStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo, orderStatus
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "updateOrderStatus"))
}
/**
* 暂停接单
* @param context
* @param callback
*/
@JvmStatic
fun changeOrderServing(
context: Context, isOrdering: Boolean,
callback: OchCommonServiceCallback<BaseData>?
) {
val baseDataObservable: Observable<BaseData> = if (isOrdering) { // 正在接单去暂停
mOCHTaxiServiceApi.stopOrderServing(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
DriverStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().sn
)
).transformTry()
} else { // 没有接单去接单
mOCHTaxiServiceApi.resetOrderServing(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
DriverStatusUpdateReqBean(
MoGoAiCloudClientConfig.getInstance().sn
)
).transformTry()
}
baseDataObservable
.subscribe(OchCommonSubscribeImpl(context, callback, "updateDriverServiceStatus"))
}
/**
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
* @param context
* @param lon
* @param lat
* @param callback
*/
@JvmStatic
fun runCarHeartbeat(
context: Context, lon: Double, lat: Double,
callback: OchCommonServiceCallback<BaseData>?
) {
mOCHTaxiServiceApi.runCarHeartbeat(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
CarHeartbeatReqBean(
MoGoAiCloudClientConfig.getInstance().sn, lon, lat
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "runCarHeartbeat"))
}
/**
* 查询司机服务数据
* @param context
* @param callback
*/
@JvmStatic
fun queryDriverServiceData(
context: Context,
callback: OchCommonServiceCallback<DriverServiceDataRespBean>?
) {
mOCHTaxiServiceApi.queryServiceData(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
MoGoAiCloudClientConfig.getInstance().sn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverServiceData"))
}
/**
* 根据订单上传工控机返回的全路径规划数据
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
fun updateOrderRoute(
context: Context, orderNo: String?, points: List<OrderRouteUpdateReqBean.Result?>?,
callback: OchCommonServiceCallback<BaseData>?
) {
mOCHTaxiServiceApi.updateOrderRoute(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
OrderRouteUpdateReqBean(orderNo, points)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "updateOrderRoute"))
}
/**
* 上报剩余里程,时间
* @param context
* @param orderNo
* @param distance
* @param duration
* @param callback
*/
@JvmStatic
fun reportOrderRemain(
context: Context,
orderNo: String?,
distance: Long,
duration: Long,
callback: OchCommonServiceCallback<BaseData>?
) {
mOCHTaxiServiceApi.reportOrderRemain(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
UpdateOrderDisAndTimeReqBean(orderNo, distance, duration)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "reportOrderRemain"))
}
/**
* 查询订单全路径
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
fun queryOrderRoute(
context: Context,
orderNo: String?,
callback: OchCommonServiceCallback<QueryOrderRouteResp>?
) {
mOCHTaxiServiceApi.queryOrderRoute(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
orderNo
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRoute"))
}
@JvmStatic
fun confirmAutopilotConditionByDriver(
context: Context,
orderNo: String?,
loc: TaxiOrPassengerReadyReqBean.Result?,
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
) {
mOCHTaxiServiceApi.confirmAutopilotConditionByDriver(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiOrPassengerReadyReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "confirmAutopilotConditionByDriver"))
}
@JvmStatic
fun queryAutopilotStatus(
context: Context, orderNo: String?,
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
) {
mOCHTaxiServiceApi.queryPilotStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
orderNo
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryAutopilotStatus"))
}
@JvmStatic
fun updatePassengerHasBoardedStatus(
context: Context,
orderNo: String?,
loc: TaxiOrPassengerReadyReqBean.Result?,
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
) {
mOCHTaxiServiceApi.updatePassengerHasBoardedStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiOrPassengerReadyReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "updatePassengerHasBoardedStatus"))
}
@JvmStatic
fun startServicePilotDone(
context: Context,
orderNo: String?,
loc: TaxiOrPassengerReadyReqBean.Result?,
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
) {
mOCHTaxiServiceApi.startServicePilotDone(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiOrPassengerReadyReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "startServicePilotDone"))
}
@JvmStatic
fun arrivedStartPoint(
context: Context,
orderNo: String?,
loc: TaxiOrPassengerReadyReqBean.Result?,
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
) {
mOCHTaxiServiceApi.arrivedStartPoint(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiOrPassengerReadyReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "arrivedStartPoint"))
}
@JvmStatic
fun arriveTerminal(
context: Context,
orderNo: String?,
loc: TaxiOrPassengerReadyReqBean.Result?,
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>
) {
mOCHTaxiServiceApi.arriveTerminal(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiOrPassengerReadyReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "arriveTerminal"))
}
@JvmStatic
fun orderCompleted(
context: Context,
orderNo: String?,
loc: TaxiOrPassengerReadyReqBean.Result?,
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>
) {
mOCHTaxiServiceApi.orderCompleted(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
TaxiOrPassengerReadyReqBean(
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
)
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "orderCompleted"))
}
}

View File

@@ -88,6 +88,7 @@ import com.mogo.eagle.core.utilcode.kotlin.*
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.*
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
import com.mogo.eagle.core.utilcode.reminder.*
import com.mogo.eagle.core.utilcode.reminder.api.*
@@ -743,6 +744,18 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
activity?.let {
val warningContent = alertContent
?: EventTypeEnum.getWarningContent(v2xType)
//占道施工预警
if (v2xType.equals("10006") || v2xType.equals("100061")) {
val currentTime = System.currentTimeMillis() / 1000
val oldTime =
context?.let { it -> SharedPrefsMgr.getInstance(it).getLong("roadwork", 0) }
if (currentTime - oldTime!! > 60) { //超过一分钟,才会继续播报重复提醒
context?.let { it -> SharedPrefsMgr.getInstance(it).putLong("roadwork", System.currentTimeMillis() / 1000) }
CallerAutoPilotManager.sendTripInfo(5, "", "", false);
}
}
if (warningContent.isEmpty()) {
CallerLogger.e("$M_HMI$TAG", "Show warningContent is null or empty!")
return

View File

@@ -59,15 +59,13 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
companion object {
private var maxAcceleration: Double = 2.0
private var speedLimit: Double = 0.0
private var speedLimit: Int = 0
}
@SuppressLint("ClickableViewAccessibility")
private fun initView() {
background = ColorDrawable(Color.parseColor("#F0151D41"))
if (keyBoardUtil == null) {
keyBoardUtil = KeyBoardUtil(sKeyBoardView, etInputSpeed)
}
keyBoardUtil?.setActionListener { inputContent ->
inputContent.toIntOrNull()?.let { speed ->
when {
@@ -76,10 +74,6 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
ToastUtils.showShort("超过最大限速值60设置失败")
}
else -> {
llSpeedPosition.background =
resources.getDrawable(R.drawable.pilot_speed_bg)
keyBoardUtil?.hideKeyboard()
etInputSpeed.clearFocus()
// 设置自动驾驶速度
val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speed)
when {
@@ -94,7 +88,6 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
}
}
}
KeyBoardUtil.hideSystemSoftKeyboard(context, etInputSpeed)
ivCloseIcon.setOnClickListener {
clickListener?.onClose(it)
}
@@ -113,49 +106,60 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
ivDebugFeedback.onClick {
clickListener?.showFeedbackView()
}
etInputSpeed.setOnFocusChangeListener { v, hasFocus ->
when {
hasFocus -> {
llSpeedPosition.background =
resources.getDrawable(R.drawable.pilot_speed_high_light_bg)
if (keyBoardUtil == null) {
keyBoardUtil = KeyBoardUtil(sKeyBoardView, etInputSpeed)
}
keyBoardUtil?.showKeyboard()
}
else -> llSpeedPosition.background =
resources.getDrawable(R.drawable.pilot_speed_bg)
}
}
etInputSpeed.setOnTouchListener { v, event ->
var curTime = System.currentTimeMillis()
if (curTime - lastTime < 1000) {
return@setOnTouchListener true
}
if (!connectStatus) {
ToastUtils.showShort("设置车速失败,请启动域控制器")
keyBoardUtil?.hideKeyboard()
return@setOnTouchListener true
} else {
return@setOnTouchListener false
}
}
updateSpeedSettingViews()
if (AppConfigInfo.isConnectAutopilot) {
CallerAutoPilotManager.getCarConfig()
}
if (maxAcceleration > 0) {
tvAcceleration.text = "加速度 $maxAcceleration m/s²"
}
// if (maxAcceleration > 0) {
// tvAcceleration.text = "加速度 $maxAcceleration m/s²"
// }
tvAcceleration.text = "每次调整车速±5km/h"
if (speedLimit > 0) {
etInputSpeed.setText((speedLimit * 3.6).toInt().toString())
tvSpeed.text = speedLimit.toString()
}else{
tvSpeed.text = "0"
}
ivSpeedReduce.setOnClickListener {
if(speedLimit>=5){
speedLimit -= 5
//速度显示
val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speedLimit)
when {
isSuccess -> {
//速度显示
tvSpeed.text = speedLimit.toString()
ToastUtils.showShort("车速设置成功,立即生效")
}
else -> {
ToastUtils.showShort("设置车速失败,请启动域控制器")
}
}
}else{
ToastUtils.showShort("车速不能再减了")
}
}
ivSpeedAdd.setOnClickListener {
if(speedLimit<=55){
speedLimit += 5
//速度显示
val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speedLimit)
when {
isSuccess -> {
//速度显示
tvSpeed.text = speedLimit.toString()
ToastUtils.showShort("车速设置成功,立即生效")
}
else -> {
ToastUtils.showShort("设置车速失败,请启动域控制器")
}
}
}else{
ToastUtils.showShort("车速不能再加了")
}
}
initOchView()
// // 比如需要设置默认速度
// val speed = "30"
// etInputSpeed.setText(speed)
// etInputSpeed.setSelection(speed.length)
initOchView()
}
private fun initOchView() {
@@ -192,11 +196,6 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
this.clickListener = clickListener
}
private fun updateSpeedSettingViews() {
tvSpeedTitle.visibility = View.VISIBLE
llSpeedPosition.visibility = View.VISIBLE
}
fun showAdUpgradeStatus(ipcUpgradeStateInfo: IPCUpgradeStateInfo) {
systemVersionView?.showAdUpgradeStatus(ipcUpgradeStateInfo)
}
@@ -228,12 +227,15 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
override fun onAutopilotCarConfig(carConfigResp: MessagePad.CarConfigResp) {
UiThreadHandler.post {
tvAcceleration?.let {
maxAcceleration = carConfigResp.maxAcceleration
speedLimit = carConfigResp.speedLimit
tvAcceleration.text = "加速度 ${carConfigResp.maxAcceleration} m/s²"
etInputSpeed.setText((carConfigResp.speedLimit * 3.6).toInt().toString())
}
// tvAcceleration?.let {
// maxAcceleration = carConfigResp.maxAcceleration
// speedLimit = carConfigResp.speedLimit
//// tvAcceleration.text = "加速度 ${carConfigResp.maxAcceleration} m/s²"
// tvSpeed.text = (carConfigResp.speedLimit * 3.6).toInt().toString()
// }
maxAcceleration = carConfigResp.maxAcceleration
speedLimit = (carConfigResp.speedLimit * 3.6).toInt()
tvSpeed.text = speedLimit.toString()
}
}
}

View File

@@ -24,7 +24,7 @@ class BusOperationView @JvmOverloads constructor(
init {
LayoutInflater.from(context).inflate(R.layout.view_och_bus_operation,this,true)
context?.let {
actvAccountPhone.text = SharedPrefs.getInstance(it).getString("account","")
actvAccountPhone.text = phoneMask(SharedPrefs.getInstance(it).getString("och_account",""))
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -43,6 +43,7 @@
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/tv_check_title"
app:layout_constraintTop_toBottomOf="@+id/v_second_group">
@@ -205,43 +206,51 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sopLayout" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/llSpeedPosition"
android:layout_width="390px"
<ImageView
android:id="@+id/ivSpeedReduce"
android:layout_width="105px"
android:layout_height="140px"
android:layout_marginStart="113px"
android:layout_marginTop="40px"
android:background="@drawable/pilot_speed_bg"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:src="@drawable/icon_speed_reduce"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSpeedTitle">
app:layout_constraintTop_toBottomOf="@id/tvSpeedTitle"
/>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/etInputSpeed"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="92px"
android:layout_weight="1"
android:background="@null"
android:gravity="center"
android:maxLength="3"
android:maxLines="1"
android:textColor="#FFFFFFFF"
android:textSize="80px"
tools:ignore="SpeakableTextPresentCheck" />
<TextView
android:id="@+id/tvSpeed"
android:layout_width="189px"
android:layout_height="140px"
app:layout_constraintTop_toTopOf="@id/ivSpeedReduce"
app:layout_constraintBottom_toBottomOf="@id/ivSpeedReduce"
app:layout_constraintLeft_toRightOf="@id/ivSpeedReduce"
android:background="#1E3062"
android:textColor="#FFFFFFFF"
android:textSize="80px"
android:gravity="center"
/>
<TextView
android:layout_width="93px"
android:layout_height="53px"
android:layout_gravity="center_vertical"
android:layout_marginEnd="28px"
android:text="km/h"
android:textColor="@color/color_B3FFFFFF"
android:textSize="38px" />
<ImageView
android:id="@+id/ivSpeedAdd"
android:layout_width="105px"
android:layout_height="140px"
app:layout_constraintTop_toTopOf="@id/tvSpeed"
app:layout_constraintBottom_toBottomOf="@id/tvSpeed"
app:layout_constraintLeft_toRightOf="@id/tvSpeed"
android:src="@drawable/icon_speed_add"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="km/h"
android:textColor="#FFFFFFFF"
android:textSize="38px"
app:layout_constraintTop_toTopOf="@id/ivSpeedAdd"
app:layout_constraintBottom_toBottomOf="@id/ivSpeedAdd"
app:layout_constraintLeft_toRightOf="@id/ivSpeedAdd"
android:layout_marginStart="40px"
/>x`
<TextView
android:id="@+id/tvAcceleration"
@@ -252,7 +261,7 @@
android:textColor="#A7B6F0"
android:textSize="32px"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/llSpeedPosition" />
app:layout_constraintTop_toBottomOf="@id/ivSpeedReduce" />
<View
android:layout_width="14px"

View File

@@ -41,7 +41,7 @@ class ColorfulStrategy(private val colors: List<Int> = emptyList(), var isLightO
object RouteStrategy {
@Volatile
private var isEnable = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) && !AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
private var isEnable = !AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
private var strategy: Strategy? = null