Merge branch 'dev_hengyang_base' of http://gitlab.zhidaoauto.com/ecos/yycp-service/Launcher into dev_hengyang_base
This commit is contained in:
@@ -221,7 +221,7 @@ public class OchBusFragment extends BaseOchFragment< OchBusFragment, OchBusPrese
|
||||
isOperationStatus = launch;
|
||||
if ( launch ) {
|
||||
tvOperationStatus.setText( "收车" );
|
||||
showSlidePanle("滑动出发");
|
||||
// showSlidePanle("滑动出发");
|
||||
showPanel();
|
||||
} else {
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已收车");
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.och.taxi;
|
||||
|
||||
public interface IOperationChangedListener {
|
||||
void onOperationChanged(boolean launch);
|
||||
void onOrderStatusChanged(int status);
|
||||
}
|
||||
@@ -8,7 +8,10 @@ import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.IMogoOCH;
|
||||
import com.mogo.och.OCHConstants;
|
||||
import com.mogo.och.taxi.ui.OCHTaxiFragment;
|
||||
import com.mogo.och.taxi.ui.OCHTaxiUiController;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -20,13 +23,17 @@ public
|
||||
* 网约车-出租车
|
||||
*/
|
||||
@Route( path = OCHConstants.PATH )
|
||||
class MogoOCHTaxi implements IMogoOCH {
|
||||
class MogoOCHTaxi implements IMogoOCH , IMogoStatusChangedListener {
|
||||
|
||||
private static final String TAG = "MogoOCHTaxi";
|
||||
|
||||
private OCHTaxiFragment ochTaxiFragment;
|
||||
private FragmentActivity mActivity;
|
||||
private int mContainerId;
|
||||
@Override
|
||||
public void init( FragmentActivity activity, int containerId ) {
|
||||
MogoOCHTaxiModel.getInstance().init( activity.getApplicationContext() );
|
||||
this.mActivity = activity;
|
||||
this.mContainerId = containerId;
|
||||
// MogoOCHTaxiModel.getInstance().init( activity.getApplicationContext() );
|
||||
OCHTaxiUiController.getInstance().init( activity, containerId );
|
||||
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
@@ -38,5 +45,36 @@ class MogoOCHTaxi implements IMogoOCH {
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
Logger.d( TAG, "init" );
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("ochTaxi", StatusDescriptor.VR_MODE,this);
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("ochTaxi", StatusDescriptor.TOP_VIEW,this);
|
||||
}
|
||||
|
||||
private void showFragment() {
|
||||
if (ochTaxiFragment == null) {
|
||||
Logger.d(TAG, "准备add fragment======");
|
||||
ochTaxiFragment = new OCHTaxiFragment();
|
||||
mActivity.getSupportFragmentManager().beginTransaction().add(mContainerId, ochTaxiFragment).commit();
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "准备show fragment");
|
||||
mActivity.getSupportFragmentManager().beginTransaction().show(ochTaxiFragment).commit();
|
||||
}
|
||||
|
||||
private void hideFragment(){
|
||||
if (ochTaxiFragment != null){
|
||||
mActivity.getSupportFragmentManager().beginTransaction().hide(ochTaxiFragment).commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
if (descriptor == StatusDescriptor.VR_MODE){
|
||||
if (isTrue){
|
||||
showFragment();
|
||||
MogoOCHTaxiModel.getInstance().init( mActivity.getApplicationContext() );
|
||||
}else {
|
||||
hideFragment();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
@@ -93,16 +93,18 @@ class MogoOCHTaxiModel {
|
||||
*/
|
||||
private boolean mIsArriveAtEndStation = false;
|
||||
|
||||
/**
|
||||
* 乘客已到达上车站点
|
||||
*/
|
||||
private boolean mIsUserArriveAtStartStation = false;
|
||||
// /**
|
||||
// * 乘客已到达上车站点
|
||||
// */
|
||||
// private boolean mIsUserArriveAtStartStation = false;
|
||||
|
||||
/**
|
||||
* 查询订单信息重试次数
|
||||
*/
|
||||
private int mRetryCounter = 0;
|
||||
|
||||
private int mOCHRHCarstatus = -1;
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
@@ -111,6 +113,9 @@ class MogoOCHTaxiModel {
|
||||
public void init( Context context ) {
|
||||
mContext = context.getApplicationContext();
|
||||
|
||||
if (mOCHTaxiServiceApi == null){
|
||||
mOCHTaxiServiceApi = MogoApisHandler.getInstance().getApis().getNetworkApi().create(OCHTaxiServiceApi.class, HostConst.OCH_DOMAIN);
|
||||
}
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getSocketManagerApi( context )
|
||||
@@ -130,6 +135,46 @@ class MogoOCHTaxiModel {
|
||||
if ( NetworkUtils.isConnected( mContext ) ) {
|
||||
restoreOrderInfo();
|
||||
}
|
||||
if ( NetworkUtils.isConnected( mContext ) ) {
|
||||
querryCarStatus();
|
||||
}
|
||||
}
|
||||
|
||||
public void querryCarStatus() {
|
||||
mOCHTaxiServiceApi.queryCarStatus( new OCHCarStatus (MoGoAiCloudClientConfig.getInstance().getSn(),0))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new SubscribeImpl< OCHCarStatusResponse >(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(OCHCarStatusResponse data) {
|
||||
super.onSuccess(data);
|
||||
Logger.e(TAG,"OCHCarStatusResponse:"+data.data.status);
|
||||
mOCHRHCarstatus = data.data.status;
|
||||
//更新view
|
||||
OCHTaxiUiController.getInstance().onOperationChanged(mOCHRHCarstatus==1);
|
||||
//刷新数据
|
||||
updateData(mOCHRHCarstatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.e(TAG,"OCHCarStatusResponse:"+e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message,code);
|
||||
Logger.e(TAG,"OCHCarStatusResponse:"+message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateData(int status){
|
||||
if (status == 1){
|
||||
//查询订单
|
||||
restoreOrderInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,6 +186,7 @@ class MogoOCHTaxiModel {
|
||||
if ( mCurrentOCHOrder == null ) {
|
||||
// 订单恢复
|
||||
String orderInfo = SharedPrefsMgr.getInstance( mContext ).getString( SP_KEY_OCH_TAXI_ORDER );
|
||||
Logger.d(TAG,"restoreOrderInfo:"+orderInfo);
|
||||
if ( !TextUtils.isEmpty( orderInfo ) ) {
|
||||
mCurrentOCHOrder = GsonUtil.objectFromJson( orderInfo, OCHTaxiOrderResponse.class );
|
||||
if ( mCurrentOCHOrder == null ) {
|
||||
@@ -158,6 +204,28 @@ class MogoOCHTaxiModel {
|
||||
}
|
||||
}
|
||||
|
||||
// private void restoreOrderInfo_() {
|
||||
// Logger.d( TAG, "重新查询订单状态" );
|
||||
// mRetryCounter = 0;
|
||||
// if ( mCurrentOCHOrder == null ) {
|
||||
// // 订单恢复
|
||||
// String orderInfo = SharedPrefsMgr.getInstance( mContext ).getString( SP_KEY_OCH_TAXI_ORDER );
|
||||
// if ( !TextUtils.isEmpty( orderInfo ) ) {
|
||||
// mCurrentOCHOrder = GsonUtil.objectFromJson( orderInfo, OCHTaxiOrderResponse.class );
|
||||
// if ( mCurrentOCHOrder == null ) {
|
||||
// // 解决本地没有缓存订单号的问题
|
||||
// query2RestoreOrderStatus( null );
|
||||
// } else {
|
||||
// query2RestoreOrderStatus( mCurrentOCHOrder.orderNo );
|
||||
// }
|
||||
// } else {
|
||||
// // 解决本地没有缓存订单号的问题
|
||||
// query2RestoreOrderStatus( null );
|
||||
// }
|
||||
// } else {
|
||||
// query2RestoreOrderStatus( mCurrentOCHOrder.orderNo );
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* 查询订单状态,来恢复旧订单(因crash导致应用重启、断网没收到推送等)状态
|
||||
* <p>
|
||||
@@ -171,62 +239,65 @@ class MogoOCHTaxiModel {
|
||||
* @param orderNo
|
||||
*/
|
||||
private void query2RestoreOrderStatus( String orderNo ) {
|
||||
Logger.e(TAG,"query2RestoreOrderStatus:"+orderNo);
|
||||
queryOCHOrderStatus( orderNo, new OCHOrderStatusCallback< OCHTaxiOrderResponse2 >() {
|
||||
@Override
|
||||
public void onSuccess( OCHTaxiOrderResponse2 data ) {
|
||||
if ( data == null || data.result == null ) {
|
||||
|
||||
if ( data == null || data.data == null ) {
|
||||
Logger.d( TAG, "订单已取消或已完成" );
|
||||
clearCurrentOCHOrder();
|
||||
OCHTaxiUiController.getInstance().removeFragment();
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(OCHOrderStatus.None.getCode());
|
||||
return;
|
||||
}
|
||||
convertCurrentOrder( data );
|
||||
OCHOrderStatus status = OCHOrderStatus.valueOf( data.result.orderDispatchType );
|
||||
OCHOrderStatus status = OCHOrderStatus.valueOf( data.data.orderDispatchType );
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(data.data.orderDispatchType);
|
||||
switch ( status ) {
|
||||
case Completed:
|
||||
TipToast.shortTip( mContext.getString( R.string.module_och_taxi_order_completed ) );
|
||||
clearCurrentOCHOrder();
|
||||
OCHTaxiUiController.getInstance().removeFragment();
|
||||
// OCHTaxiUiController.getInstance().removeFragment();
|
||||
break;
|
||||
case Cancel:
|
||||
TipToast.shortTip( mContext.getString( R.string.module_och_taxi_order_cancel ) );
|
||||
clearCurrentOCHOrder();
|
||||
OCHTaxiUiController.getInstance().removeFragment();
|
||||
// OCHTaxiUiController.getInstance().removeFragment();
|
||||
break;
|
||||
case ArriveAtEndStation:
|
||||
mIsArriveAtEndStation = true;
|
||||
mIsArriveAtStartStation = false;
|
||||
mIsOnTheWay2EndStation = false;
|
||||
mIsUserArriveAtStartStation = false;
|
||||
OCHTaxiUiController.getInstance().addFragment();
|
||||
// mIsUserArriveAtStartStation = false;
|
||||
// OCHTaxiUiController.getInstance().addFragment();
|
||||
break;
|
||||
case ArriveAtStartStation:
|
||||
mIsArriveAtStartStation = true;
|
||||
mIsArriveAtEndStation = false;
|
||||
mIsOnTheWay2EndStation = false;
|
||||
mIsUserArriveAtStartStation = false;
|
||||
OCHTaxiUiController.getInstance().addFragment();
|
||||
// mIsUserArriveAtStartStation = false;
|
||||
// OCHTaxiUiController.getInstance().addFragment();
|
||||
break;
|
||||
case UserArriveAtStartStation:
|
||||
mIsArriveAtStartStation = true;
|
||||
mIsArriveAtEndStation = false;
|
||||
mIsOnTheWay2EndStation = false;
|
||||
mIsUserArriveAtStartStation = true;
|
||||
OCHTaxiUiController.getInstance().addFragment();
|
||||
// mIsUserArriveAtStartStation = true;
|
||||
// OCHTaxiUiController.getInstance().addFragment();
|
||||
break;
|
||||
case OnTheWayToEndStation:
|
||||
mIsArriveAtStartStation = false;
|
||||
mIsArriveAtEndStation = false;
|
||||
mIsOnTheWay2EndStation = true;
|
||||
mIsUserArriveAtStartStation = false;
|
||||
OCHTaxiUiController.getInstance().addFragment();
|
||||
// mIsUserArriveAtStartStation = false;
|
||||
// OCHTaxiUiController.getInstance().addFragment();
|
||||
break;
|
||||
case OnTheWayToStartStation:
|
||||
default:
|
||||
mIsArriveAtStartStation = false;
|
||||
mIsArriveAtEndStation = false;
|
||||
mIsOnTheWay2EndStation = false;
|
||||
mIsUserArriveAtStartStation = false;
|
||||
// mIsUserArriveAtStartStation = false;
|
||||
mOrderMsgListener.onMsgReceived( mCurrentOCHOrder );
|
||||
break;
|
||||
}
|
||||
@@ -256,24 +327,24 @@ class MogoOCHTaxiModel {
|
||||
if ( mCurrentOCHOrder == null ) {
|
||||
mCurrentOCHOrder = new OCHTaxiOrderResponse();
|
||||
}
|
||||
mCurrentOCHOrder.orderNo = data.result.orderNo;
|
||||
mCurrentOCHOrder.orderDispatchType = data.result.orderDispatchType;
|
||||
mCurrentOCHOrder.endStation = data.result.endStation;
|
||||
mCurrentOCHOrder.startStation = data.result.startStation;
|
||||
mCurrentOCHOrder.travelDistance = data.result.travelDistance;
|
||||
mCurrentOCHOrder.orderType = data.result.orderType;
|
||||
mCurrentOCHOrder.orderNo = data.data.orderNo;
|
||||
mCurrentOCHOrder.orderDispatchType = data.data.orderDispatchType;
|
||||
mCurrentOCHOrder.endStation = data.data.endStation;
|
||||
mCurrentOCHOrder.startStation = data.data.startStation;
|
||||
mCurrentOCHOrder.travelDistance = data.data.travelDistance;
|
||||
mCurrentOCHOrder.orderType = data.data.orderType;
|
||||
mCurrentOCHOrder.drivingRoutes = new ArrayList<>();
|
||||
OCHTaxiOrderResponse.OCHTaxiStation startStation = new OCHTaxiOrderResponse.OCHTaxiStation();
|
||||
startStation.lon = data.result.startStationCoordinate.get( 0 );
|
||||
startStation.lat = data.result.startStationCoordinate.get( 1 );
|
||||
startStation.siteId = data.result.startStationId;
|
||||
startStation.siteName = data.result.startStation;
|
||||
startStation.lon = data.data.startStationCoordinate.get( 0 );
|
||||
startStation.lat = data.data.startStationCoordinate.get( 1 );
|
||||
startStation.siteId = data.data.startStationId;
|
||||
startStation.siteName = data.data.startStation;
|
||||
mCurrentOCHOrder.drivingRoutes.add( startStation );
|
||||
OCHTaxiOrderResponse.OCHTaxiStation endStation = new OCHTaxiOrderResponse.OCHTaxiStation();
|
||||
endStation.lon = data.result.endStationCoordinate.get( 0 );
|
||||
endStation.lat = data.result.endStationCoordinate.get( 1 );
|
||||
endStation.siteId = data.result.endStationId;
|
||||
endStation.siteName = data.result.endStation;
|
||||
endStation.lon = data.data.endStationCoordinate.get( 0 );
|
||||
endStation.lat = data.data.endStationCoordinate.get( 1 );
|
||||
endStation.siteId = data.data.endStationId;
|
||||
endStation.siteName = data.data.endStation;
|
||||
mCurrentOCHOrder.drivingRoutes.add( endStation );
|
||||
|
||||
cacheOrderInfo2Native( mCurrentOCHOrder );
|
||||
@@ -294,6 +365,47 @@ class MogoOCHTaxiModel {
|
||||
}
|
||||
};
|
||||
|
||||
public void changedOperationStatus() {
|
||||
if ( mOCHRHCarstatus == -1){
|
||||
querryCarStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkCurrentOCHOrder()){
|
||||
TipToast.shortTip( "订单未完成,无法下线收车" );
|
||||
return;
|
||||
}
|
||||
|
||||
int status = mOCHRHCarstatus == 1 ? 0 : 1;
|
||||
mOCHTaxiServiceApi.updateCarStatus(new OCHCarStatus(MoGoAiCloudClientConfig.getInstance().getSn(),status))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new SubscribeImpl< OCHCarStatusResponse >(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(OCHCarStatusResponse o) {
|
||||
super.onSuccess(o);
|
||||
mOCHRHCarstatus = o.data.status;
|
||||
// mIsWork = mOCHRHCarstatus.status == 1;
|
||||
// mOCHRHCarstatus.status = status;
|
||||
OCHTaxiUiController.getInstance().onOperationChanged(mOCHRHCarstatus == 1);
|
||||
updateData(mOCHRHCarstatus);
|
||||
Logger.d(TAG,"changeCarStatus:"+status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.d(TAG,"changeCarStatus:"+e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
Logger.d(TAG,"changeCarStatus:"+message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 自车定位
|
||||
*/
|
||||
@@ -301,12 +413,12 @@ class MogoOCHTaxiModel {
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2( Location location ) {
|
||||
Logger.d( TAG, "定位已判断是否达到上车站点: 起点(%s, %s), 当前位置(%s, %s)",
|
||||
mCurrentOCHOrder.drivingRoutes.get( 0 ).lon,
|
||||
mCurrentOCHOrder.drivingRoutes.get( 0 ).lat,
|
||||
location.getLongitude(),
|
||||
location.getLatitude()
|
||||
);
|
||||
// Logger.d( TAG, "定位已判断是否达到上车站点: 起点(%s, %s), 当前位置(%s, %s)",
|
||||
// mCurrentOCHOrder.drivingRoutes.get( 0 ).lon,
|
||||
// mCurrentOCHOrder.drivingRoutes.get( 0 ).lat,
|
||||
// location.getLongitude(),
|
||||
// location.getLatitude()
|
||||
// );
|
||||
onLocationChanged( location );
|
||||
}
|
||||
|
||||
@@ -331,9 +443,9 @@ class MogoOCHTaxiModel {
|
||||
if ( mIsArriveAtStartStation ) {
|
||||
return;
|
||||
}
|
||||
if ( mIsUserArriveAtStartStation ) {
|
||||
return;
|
||||
}
|
||||
// if ( mIsUserArriveAtStartStation ) {
|
||||
// return;
|
||||
// }
|
||||
judgeStartStation( location );
|
||||
}
|
||||
|
||||
@@ -392,14 +504,14 @@ class MogoOCHTaxiModel {
|
||||
return mIsArriveAtEndStation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户是否达到上车站点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isUserArriveAtStartStation() {
|
||||
return mIsUserArriveAtStartStation;
|
||||
}
|
||||
// /**
|
||||
// * 用户是否达到上车站点
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public boolean isUserArriveAtStartStation() {
|
||||
// return mIsUserArriveAtStartStation;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 设置去往终点状态
|
||||
@@ -446,7 +558,8 @@ class MogoOCHTaxiModel {
|
||||
if ( !isArriveAtStartStation() ) {
|
||||
registerCarLocationListener();
|
||||
}
|
||||
OCHTaxiUiController.getInstance().addFragment();
|
||||
// OCHTaxiUiController.getInstance().addFragment();
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(mCurrentOCHOrder.orderDispatchType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,7 +623,7 @@ class MogoOCHTaxiModel {
|
||||
break;
|
||||
case UserArriveAtStartStation:
|
||||
mIsArriveAtStartStation = true;
|
||||
mIsUserArriveAtStartStation = true;
|
||||
// mIsUserArriveAtStartStation = true;
|
||||
OCHTaxiUiController.getInstance().onUserArriveAtStartStation();
|
||||
break;
|
||||
default:
|
||||
@@ -576,11 +689,13 @@ class MogoOCHTaxiModel {
|
||||
if ( callback != null ) {
|
||||
callback.onError();
|
||||
}
|
||||
Logger.e(TAG,"updateOCHOrderStatus:"+e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( String message, int code ) {
|
||||
super.onError( message, code );
|
||||
Logger.e(TAG,"updateOCHOrderStatus:"+message);
|
||||
if ( callback != null ) {
|
||||
callback.onFail();
|
||||
}
|
||||
@@ -620,6 +735,7 @@ class MogoOCHTaxiModel {
|
||||
@Override
|
||||
public void onError( String message, int code ) {
|
||||
super.onError( message, code );
|
||||
Logger.e("MogoOCHTaxi","queryOCHOrderStatus:"+message);
|
||||
if ( callback != null ) {
|
||||
callback.onFail();
|
||||
}
|
||||
@@ -635,7 +751,7 @@ class MogoOCHTaxiModel {
|
||||
mIsArriveAtStartStation = false;
|
||||
mIsArriveAtEndStation = false;
|
||||
mIsOnTheWay2EndStation = false;
|
||||
mIsUserArriveAtStartStation = false;
|
||||
// mIsUserArriveAtStartStation = false;
|
||||
SharedPrefsMgr.getInstance( mContext ).remove( SP_KEY_OCH_TAXI_ORDER );
|
||||
}
|
||||
|
||||
@@ -646,8 +762,7 @@ class MogoOCHTaxiModel {
|
||||
*/
|
||||
public boolean checkCurrentOCHOrder() {
|
||||
if ( mCurrentOCHOrder != null
|
||||
&& mCurrentOCHOrder.drivingRoutes != null
|
||||
&& mCurrentOCHOrder.drivingRoutes.size() >= 2 ) {
|
||||
&& mCurrentOCHOrder.drivingRoutes != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mogo.och.taxi;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
public
|
||||
/**
|
||||
*
|
||||
* 修改/查询网约车-出租车订单状态的数据结构
|
||||
*/
|
||||
class OCHCarStatus extends BaseData {
|
||||
|
||||
public String sn;// 不排除本地没有缓存订单号的情况
|
||||
public int status; //0 收车 1出车
|
||||
|
||||
public OCHCarStatus(String sn,
|
||||
int status ) {
|
||||
this.sn = sn;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mogo.och.taxi;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
public
|
||||
/**
|
||||
*
|
||||
* 修改/查询网约车-出租车订单状态的数据结构
|
||||
*/
|
||||
class OCHCarStatusResponse extends BaseData {
|
||||
|
||||
public String sn;// 不排除本地没有缓存订单号的情况
|
||||
public int status; //0 收车 1出车
|
||||
public Result data;
|
||||
|
||||
public OCHCarStatusResponse(String sn,
|
||||
int status ) {
|
||||
this.sn = sn;
|
||||
this.status = status;
|
||||
}
|
||||
public static class Result{
|
||||
public int id;
|
||||
public String sn;
|
||||
public String areaCode;
|
||||
public String plateNumber;
|
||||
public int status;
|
||||
// String remark;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public
|
||||
*/
|
||||
class OCHTaxiOrderResponse2 extends BaseData {
|
||||
|
||||
public Result result;
|
||||
public Result data;
|
||||
|
||||
public static class Result {
|
||||
public String _id;
|
||||
|
||||
@@ -23,7 +23,7 @@ interface OCHTaxiServiceApi {
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/order/updateOCHOrder/v1" )
|
||||
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/order/updateOCHOrderState/v1" )
|
||||
Observable< BaseData > updateOrderStatus( @Body OCHTaxiOrderStatus status );
|
||||
|
||||
/**
|
||||
@@ -32,6 +32,20 @@ interface OCHTaxiServiceApi {
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/order/queryOCHOrderDetails/v1" )
|
||||
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/order/queryOrderForCar/v1" )
|
||||
Observable< OCHTaxiOrderResponse2 > queryOrder( @Body OCHTaxiOrderStatus status );
|
||||
/**
|
||||
* 查询网约车状态
|
||||
*/
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
@POST("/yycp-onlinecar-hailing/onlineCarHailing/order/queryTaxiCarStatus/v1")
|
||||
Observable<OCHCarStatusResponse> queryCarStatus(@Body OCHCarStatus sn );
|
||||
|
||||
|
||||
/**
|
||||
* 更新网约车状态
|
||||
*/
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
@POST("/yycp-onlinecar-hailing/onlineCarHailing/order/updateTaxiCarStatus/v1")
|
||||
Observable<OCHCarStatusResponse> updateCarStatus(@Body OCHCarStatus status );
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.BaseOchFragment;
|
||||
import com.mogo.och.taxi.IMogoADASAutoPilotStatusChangedListener;
|
||||
import com.mogo.och.taxi.IMogoOCHTaxiArriveCallback;
|
||||
import com.mogo.och.taxi.IOperationChangedListener;
|
||||
import com.mogo.och.taxi.MogoOCHTaxiModel;
|
||||
import com.mogo.och.taxi.OCHOrderStatus;
|
||||
import com.mogo.och.taxi.OCHOrderStatusCallback;
|
||||
@@ -35,6 +37,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
IMogoStatusChangedListener,
|
||||
IMogoOCHTaxiArriveCallback,
|
||||
IMogoADASAutoPilotStatusChangedListener,
|
||||
IOperationChangedListener,
|
||||
IMogoCarLocationChangedListener2 {
|
||||
|
||||
public static final String TAG = "OCHTaxiFragment";
|
||||
@@ -52,7 +55,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
private TextView mStartStationName;
|
||||
private TextView mEndStationName;
|
||||
private TextView mDistance;
|
||||
|
||||
@Override
|
||||
public int getStationPanelViewId() {
|
||||
return R.layout.module_och_taxi_panel;
|
||||
@@ -62,6 +64,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
public void restartAutopilot() {
|
||||
// 在自动驾驶中,才会有重新开启自动驾驶的操作
|
||||
if ( MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
|
||||
Logger.d( TAG, "restartAutopilot" );
|
||||
MogoOCHTaxiModel.getInstance().startAutoPilot();
|
||||
}
|
||||
}
|
||||
@@ -74,9 +77,11 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
mEndStationName = findViewById( R.id.module_och_taxi_order_end_station );
|
||||
mDistance = findViewById( R.id.module_och_taxi_order_distance );
|
||||
|
||||
showPanel();
|
||||
// showPanel();
|
||||
hidPanel();
|
||||
initListeners();
|
||||
updateOrderStatus();
|
||||
// TODO: 2021/6/18 调整接口刷新时间
|
||||
// updateOrderStatus();
|
||||
if ( MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getStatusManagerApi()
|
||||
@@ -85,8 +90,8 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
} else {
|
||||
flatMode();
|
||||
}
|
||||
// 出租车不需要开启按钮
|
||||
tvOperationStatus.setVisibility(View.GONE);
|
||||
|
||||
tvOperationStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
@@ -96,6 +101,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
.registerStatusChangedListener( TAG, StatusDescriptor.VR_MODE, this );
|
||||
OCHTaxiUiController.getInstance().setOCHTaxiArriveCallback( this );
|
||||
OCHTaxiUiController.getInstance().setAutoPilotStatusChangedListener( this );
|
||||
OCHTaxiUiController.getInstance().setOperationChangeListener(this);
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getRegisterCenterApi()
|
||||
@@ -117,6 +123,12 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChangeOperationStatus() {
|
||||
super.onChangeOperationStatus();
|
||||
MogoOCHTaxiModel.getInstance().changedOperationStatus();
|
||||
}
|
||||
|
||||
private void vrMode() {
|
||||
if ( mRootView != null ) {
|
||||
mRootView.setVisibility(
|
||||
@@ -151,15 +163,17 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
} else if ( MogoOCHTaxiModel.getInstance().isArriveAtStartStation() ) {
|
||||
Logger.d( TAG, "已经达到起点" );
|
||||
mOrderStatus.setText( R.string.module_och_taxi_waiting );
|
||||
if ( MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation() ) {
|
||||
Logger.d( TAG, "乘客已上车" );
|
||||
slidePanelView.setVisibility( View.VISIBLE );
|
||||
// if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE ) {
|
||||
// } else {
|
||||
// slidePanelView.setVisibility( View.GONE );
|
||||
// }
|
||||
slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_start_station ) );
|
||||
}
|
||||
// if ( MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation() ) {
|
||||
// Logger.d( TAG, "乘客已上车" );
|
||||
// slidePanelView.setVisibility( View.VISIBLE );
|
||||
//// if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE ) {
|
||||
//// } else {
|
||||
//// slidePanelView.setVisibility( View.GONE );
|
||||
//// }
|
||||
// slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_start_station ) );
|
||||
// }
|
||||
slidePanelView.setVisibility( View.VISIBLE );
|
||||
slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_start_station ) );
|
||||
} else if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
|
||||
Logger.d( TAG, "去往上车站点" );
|
||||
slidePanelView.setVisibility( View.GONE );
|
||||
@@ -247,6 +261,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
.unregisterStatusChangedListener( TAG, StatusDescriptor.VR_MODE, this );
|
||||
OCHTaxiUiController.getInstance().setOCHTaxiArriveCallback( null );
|
||||
OCHTaxiUiController.getInstance().setAutoPilotStatusChangedListener( null );
|
||||
OCHTaxiUiController.getInstance().setOperationChangeListener(null);
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getRegisterCenterApi()
|
||||
@@ -269,7 +284,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
Logger.d( TAG, "更新状态成功" );
|
||||
MogoOCHTaxiModel.getInstance().clearCurrentOCHOrder();
|
||||
MogoOCHTaxiModel.getInstance().cancelAutopilot();
|
||||
OCHTaxiUiController.getInstance().removeFragment();
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,8 +299,8 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
} );
|
||||
return;
|
||||
// 乘客已确认到达起点,前往下一站并开启自动驾驶
|
||||
} else if ( MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation()
|
||||
&& !MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
|
||||
} else if ( !MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
|
||||
// MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation() &&
|
||||
MogoOCHTaxiModel.getInstance().startAutoPilot();
|
||||
}
|
||||
}
|
||||
@@ -367,4 +382,32 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
}
|
||||
mLocation = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOperationChanged(boolean launch) {
|
||||
isOperationStatus = launch;
|
||||
if ( launch ) {
|
||||
tvOperationStatus.setText( "收车" );
|
||||
// showSlidePanle("滑动出发");
|
||||
// showPanel();
|
||||
} else {
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已收车");
|
||||
tvOperationStatus.setText("出车");
|
||||
// hideSlidePanel();
|
||||
// hidPanel();
|
||||
}
|
||||
// changeLayoutViewStatus(launch);
|
||||
}
|
||||
|
||||
private void changeLayoutViewStatus(boolean launch) {
|
||||
getPanelView().setVisibility(launch ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOrderStatusChanged(int status) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
getPanelView().setVisibility(status != 0 ? View.VISIBLE : View.INVISIBLE);
|
||||
updateOrderStatus();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.fragment.app.FragmentManager;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.taxi.IMogoADASAutoPilotStatusChangedListener;
|
||||
import com.mogo.och.taxi.IMogoOCHTaxiArriveCallback;
|
||||
import com.mogo.och.taxi.IOperationChangedListener;
|
||||
import com.mogo.och.taxi.MogoOCHTaxiModel;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -31,6 +32,7 @@ class OCHTaxiUiController implements IMogoOCHTaxiArriveCallback, IMogoADASAutoPi
|
||||
|
||||
private IMogoOCHTaxiArriveCallback mOCHTaxiArriveCallback;
|
||||
private IMogoADASAutoPilotStatusChangedListener mAutoPilotStatusChangedListener;
|
||||
private IOperationChangedListener mOperationChangedLisnter;
|
||||
|
||||
private OCHTaxiUiController() {
|
||||
}
|
||||
@@ -101,6 +103,10 @@ class OCHTaxiUiController implements IMogoOCHTaxiArriveCallback, IMogoADASAutoPi
|
||||
this.mAutoPilotStatusChangedListener = autoPilotStatusChangedListener;
|
||||
}
|
||||
|
||||
public void setOperationChangeListener(IOperationChangedListener listener){
|
||||
this.mOperationChangedLisnter = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTheWay2StartStation() {
|
||||
runOnUIThread( () -> {
|
||||
@@ -167,6 +173,8 @@ class OCHTaxiUiController implements IMogoOCHTaxiArriveCallback, IMogoADASAutoPi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 进入鹰眼模式,设置手势缩放地图失效
|
||||
*/
|
||||
@@ -178,4 +186,19 @@ class OCHTaxiUiController implements IMogoOCHTaxiArriveCallback, IMogoADASAutoPi
|
||||
.getMapUIController()
|
||||
.openVrMode( false );
|
||||
}
|
||||
|
||||
public void onOperationChanged(boolean b) {
|
||||
runOnUIThread( () -> {
|
||||
if (mOperationChangedLisnter != null){
|
||||
mOperationChangedLisnter.onOperationChanged(b);
|
||||
}
|
||||
} );
|
||||
}
|
||||
public void onOrderStatusChanged(int status){
|
||||
runOnUIThread( () -> {
|
||||
if (mOperationChangedLisnter != null){
|
||||
mOperationChangedLisnter.onOrderStatusChanged(status);
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/module_och_taxi_layoutview"
|
||||
android:layout_width="@dimen/module_mogo_och_autopilot_order_bg_width"
|
||||
android:layout_height="@dimen/module_mogo_och_autopilot_order_bg_height"
|
||||
android:orientation="vertical">
|
||||
@@ -72,6 +73,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="上车"
|
||||
android:textColor="@color/module_och_taxi_order_start_station_anchor_textColor"
|
||||
android:layout_marginRight="@dimen/module_och_taxi_order_text_marginRight"
|
||||
android:textSize="@dimen/module_och_taxi_order_start_station_anchor_textSize"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_och_taxi_order_start_station"
|
||||
@@ -116,6 +118,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="下车"
|
||||
android:layout_marginRight="@dimen/module_och_taxi_order_text_marginRight"
|
||||
android:textColor="@color/module_och_taxi_order_end_station_anchor_textColor"
|
||||
android:textSize="@dimen/module_och_taxi_order_end_station_anchor_textSize"
|
||||
android:textStyle="bold"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<dimen name="module_och_taxi_order_start_station_marginLeft">15px</dimen>
|
||||
<dimen name="module_och_taxi_order_status_marginLeft">25px</dimen>
|
||||
<dimen name="module_och_taxi_order_status_marginTop">25px</dimen>
|
||||
<dimen name="module_och_taxi_order_status_textSize">20px</dimen>
|
||||
<dimen name="module_och_taxi_order_status_textSize">32px</dimen>
|
||||
<dimen name="module_och_taxi_order_status_divider_height">1px</dimen>
|
||||
<dimen name="module_och_taxi_order_status_divider_marginLeft">20px</dimen>
|
||||
<dimen name="module_och_taxi_order_status_divider_marginTop">20px</dimen>
|
||||
@@ -24,4 +24,5 @@
|
||||
<dimen name="module_och_taxi_order_distance_anchor_textSize">32px</dimen>
|
||||
<dimen name="module_och_taxi_order_distance_textSize">36px</dimen>
|
||||
<dimen name="module_och_taxi_order_distance_marginRight">17px</dimen>
|
||||
<dimen name="module_och_taxi_order_text_marginRight">31.5px</dimen>
|
||||
</resources>
|
||||
@@ -24,4 +24,5 @@
|
||||
<dimen name="module_och_taxi_order_distance_anchor_textSize">20px</dimen>
|
||||
<dimen name="module_och_taxi_order_distance_textSize">24px</dimen>
|
||||
<dimen name="module_och_taxi_order_distance_marginRight">17px</dimen>
|
||||
<dimen name="module_och_taxi_order_text_marginRight">22.5px</dimen>
|
||||
</resources>
|
||||
@@ -57,7 +57,7 @@ public class SlidePanelView extends View {
|
||||
private final Paint blockPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private final Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
private static int textSize = 40;
|
||||
private static int textSize = 67;
|
||||
private static int BLOCK_START_X = 15;
|
||||
private static int BLOCK_START_Y = 15;
|
||||
private static int NORMAL_TEXT_MARGIN_LEFT = 40;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_checked="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:bottomLeftRadius="30px" android:bottomRightRadius="70px" android:topLeftRadius="70px" android:topRightRadius="30px" />
|
||||
<gradient android:angle="315" android:endColor="#2B6EFF" android:startColor="#2B6EFF" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:bottomLeftRadius="30px" android:bottomRightRadius="70px" android:topLeftRadius="70px" android:topRightRadius="30px" />
|
||||
<gradient android:angle="315" android:endColor="#3B4577" android:startColor="#3B4577" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 15 KiB |
@@ -2,13 +2,13 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_checked="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:bottomLeftRadius="30px" android:bottomRightRadius="130px" android:topLeftRadius="130px" android:topRightRadius="30px" />
|
||||
<corners android:bottomLeftRadius="30px" android:bottomRightRadius="70px" android:topLeftRadius="70px" android:topRightRadius="30px" />
|
||||
<gradient android:angle="315" android:endColor="#2B6EFF" android:startColor="#2B6EFF" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:bottomLeftRadius="30px" android:bottomRightRadius="130px" android:topLeftRadius="130px" android:topRightRadius="30px" />
|
||||
<corners android:bottomLeftRadius="30px" android:bottomRightRadius="70px" android:topLeftRadius="70px" android:topRightRadius="30px" />
|
||||
<gradient android:angle="315" android:endColor="#3B4577" android:startColor="#3B4577" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class SubscribeImpl< T extends BaseData > implements Observer< T
|
||||
@Override
|
||||
public void onNext( T o ) {
|
||||
if ( o != null ) {
|
||||
if ( o.code != 0 ) {
|
||||
if ( o.code != 0 && o.code!= 200 ) {
|
||||
onError( o.msg, o.code );
|
||||
} else {
|
||||
onSuccess( o );
|
||||
|
||||
Reference in New Issue
Block a user