opt
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -89,7 +89,6 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -135,12 +135,12 @@ class MogoOCHTaxiModel {
|
||||
queryOCHOrderStatus( orderNo, new OCHOrderStatusCallback< OCHTaxiOrderResponse2 >() {
|
||||
@Override
|
||||
public void onSuccess( OCHTaxiOrderResponse2 data ) {
|
||||
if ( data == null ) {
|
||||
if ( data == null && data.result != null ) {
|
||||
clearCurrentOCHOrder();
|
||||
return;
|
||||
}
|
||||
convertCurrentOrder( data );
|
||||
OCHOrderStatus status = OCHOrderStatus.valueOf( data.orderDispatchType );
|
||||
OCHOrderStatus status = OCHOrderStatus.valueOf( data.result.orderDispatchType );
|
||||
switch ( status ) {
|
||||
case Completed:
|
||||
case Cancel:
|
||||
@@ -190,24 +190,24 @@ class MogoOCHTaxiModel {
|
||||
}
|
||||
|
||||
private void convertCurrentOrder( OCHTaxiOrderResponse2 data ) {
|
||||
mCurrentOCHOrder.orderNo = data.orderNo;
|
||||
mCurrentOCHOrder.orderDispatchType = data.orderDispatchType;
|
||||
mCurrentOCHOrder.endStation = data.endStation;
|
||||
mCurrentOCHOrder.startStation = data.startStation;
|
||||
mCurrentOCHOrder.travelDistance = data.travelDistance;
|
||||
mCurrentOCHOrder.orderType = data.orderType;
|
||||
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.drivingRoutes = new ArrayList<>();
|
||||
OCHTaxiOrderResponse.OCHTaxiStation startStation = new OCHTaxiOrderResponse.OCHTaxiStation();
|
||||
startStation.lon = data.startStationCoordinate.get( 0 );
|
||||
startStation.lat = data.startStationCoordinate.get( 1 );
|
||||
startStation.siteId = data.startStationId;
|
||||
startStation.siteName = data.startStation;
|
||||
startStation.lon = data.result.startStationCoordinate.get( 0 );
|
||||
startStation.lat = data.result.startStationCoordinate.get( 1 );
|
||||
startStation.siteId = data.result.startStationId;
|
||||
startStation.siteName = data.result.startStation;
|
||||
mCurrentOCHOrder.drivingRoutes.add( startStation );
|
||||
OCHTaxiOrderResponse.OCHTaxiStation endStation = new OCHTaxiOrderResponse.OCHTaxiStation();
|
||||
endStation.lon = data.endStationCoordinate.get( 0 );
|
||||
endStation.lat = data.endStationCoordinate.get( 1 );
|
||||
endStation.siteId = data.endStationId;
|
||||
endStation.siteName = data.endStation;
|
||||
endStation.lon = data.result.endStationCoordinate.get( 0 );
|
||||
endStation.lat = data.result.endStationCoordinate.get( 1 );
|
||||
endStation.siteId = data.result.endStationId;
|
||||
endStation.siteName = data.result.endStation;
|
||||
mCurrentOCHOrder.drivingRoutes.add( endStation );
|
||||
|
||||
cacheOrderInfo2Native( mCurrentOCHOrder );
|
||||
@@ -230,7 +230,7 @@ class MogoOCHTaxiModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* 位置变化时,通过围栏(5M)判断,是否到达起点
|
||||
* 位置变化时,通过围栏(5M)判断,是否到达x点
|
||||
*
|
||||
* @param location
|
||||
*/
|
||||
@@ -245,13 +245,39 @@ class MogoOCHTaxiModel {
|
||||
unregisterCarLocationListener();
|
||||
return;
|
||||
}
|
||||
judgeStationStation( location );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 是否到达起点
|
||||
*
|
||||
* @param location
|
||||
*/
|
||||
private void judgeStationStation( Location location ) {
|
||||
OCHTaxiOrderResponse.OCHTaxiStation station = mCurrentOCHOrder.drivingRoutes.get( 0 );//起点
|
||||
double distance = CoordinateUtils.calculateLineDistance( station.lon, station.lat, location.getLongitude(), location.getLatitude() );
|
||||
if ( distance <= 5 ) {
|
||||
mIsArriveAtStartStation = true;
|
||||
unregisterCarLocationListener();
|
||||
OCHTaxiUiController.getInstance().onArriveAtStartStation();
|
||||
updateOCHOrderStatus( OCHOrderStatus.ArriveAtStartStation, null );
|
||||
updateOCHOrderStatus( OCHOrderStatus.ArriveAtStartStation, new OCHOrderStatusCallback() {
|
||||
@Override
|
||||
public void onSuccess( Object data ) {
|
||||
Logger.d( TAG, "更新状态成功" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
Logger.d( TAG, "更新状态失败" );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Logger.d( TAG, "更新状态失败2" );
|
||||
}
|
||||
} );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -272,6 +298,11 @@ class MogoOCHTaxiModel {
|
||||
return mIsArriveAtEndStation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置去往终点状态
|
||||
*
|
||||
* @param isOnTheWay2EndStation
|
||||
*/
|
||||
public void setOnTheWay2EndStation( boolean isOnTheWay2EndStation ) {
|
||||
this.mIsOnTheWay2EndStation = isOnTheWay2EndStation;
|
||||
}
|
||||
@@ -366,6 +397,7 @@ class MogoOCHTaxiModel {
|
||||
switch ( status ) {
|
||||
case Cancel:
|
||||
clearCurrentOCHOrder();
|
||||
OCHTaxiUiController.getInstance().removeFragment();
|
||||
break;
|
||||
default:
|
||||
Logger.d( TAG, "current order status: %s", status );
|
||||
@@ -511,6 +543,7 @@ class MogoOCHTaxiModel {
|
||||
Logger.e( TAG, "no order or order is empty." );
|
||||
return;
|
||||
}
|
||||
|
||||
RemoteControlAutoPilotParameters parameters = new RemoteControlAutoPilotParameters();
|
||||
parameters.vehicleType = mCurrentOCHOrder.orderType;
|
||||
parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 0 ).lat, mCurrentOCHOrder.drivingRoutes.get( 0 ).lon );
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package com.mogo.och.taxi;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
@@ -16,116 +11,52 @@ public
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class OCHTaxiOrderResponse2 extends BaseData implements Parcelable {
|
||||
class OCHTaxiOrderResponse2 extends BaseData {
|
||||
|
||||
public String _id;
|
||||
// 订单号
|
||||
public String orderNo;
|
||||
// 订单运营类型 (9出租车,10小巴)
|
||||
public int orderType;
|
||||
public Result result;
|
||||
|
||||
// 当前订单状态
|
||||
public int orderDispatchType;
|
||||
// 起始站目的站距离km
|
||||
public double travelDistance;
|
||||
public static class Result {
|
||||
public String _id;
|
||||
// 订单号
|
||||
public String orderNo;
|
||||
// 订单运营类型 (9出租车,10小巴)
|
||||
public int orderType;
|
||||
|
||||
public String userName;
|
||||
public String userPhone;
|
||||
// 当前订单状态
|
||||
public int orderDispatchType;
|
||||
// 起始站目的站距离km
|
||||
public double travelDistance;
|
||||
|
||||
// 起始站名称
|
||||
public String startStation;
|
||||
// 起始站ID
|
||||
public String startStationId;
|
||||
// 起点站点
|
||||
public List< Double > startStationCoordinate;
|
||||
public String userName;
|
||||
public String userPhone;
|
||||
|
||||
// 目的站名称
|
||||
public String endStation;
|
||||
// 目的站ID
|
||||
public String endStationId;
|
||||
// 终点站点
|
||||
public List< Double > endStationCoordinate;
|
||||
// 起始站名称
|
||||
public String startStation;
|
||||
// 起始站ID
|
||||
public String startStationId;
|
||||
// 起点站点
|
||||
public List< Double > startStationCoordinate;
|
||||
|
||||
public String orderStartTime;
|
||||
public String cityCode;
|
||||
public String areaCode;
|
||||
public String createTime;
|
||||
public int personNum;
|
||||
// 目的站名称
|
||||
public String endStation;
|
||||
// 目的站ID
|
||||
public String endStationId;
|
||||
// 终点站点
|
||||
public List< Double > endStationCoordinate;
|
||||
|
||||
public OCHTaxiOrderResponse2() {
|
||||
public String orderStartTime;
|
||||
public String cityCode;
|
||||
public String areaCode;
|
||||
public String createTime;
|
||||
public String updateTime;
|
||||
public int personNum;
|
||||
public String headImgUrl;
|
||||
public String lastBrandName;
|
||||
|
||||
public String arrivedStartStationTime;
|
||||
public String arrivedEndStationTime;
|
||||
|
||||
public String sn;
|
||||
public String carNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OCHTaxiResponse{" +
|
||||
"orderNo='" + orderNo + '\'' +
|
||||
", orderType=" + orderType +
|
||||
", startStation='" + startStation + '\'' +
|
||||
", endStation='" + endStation + '\'' +
|
||||
", orderDispatchType=" + orderDispatchType +
|
||||
", travelDistance=" + travelDistance +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeString( this._id );
|
||||
dest.writeString( this.orderNo );
|
||||
dest.writeInt( this.orderType );
|
||||
dest.writeInt( this.orderDispatchType );
|
||||
dest.writeDouble( this.travelDistance );
|
||||
dest.writeString( this.userName );
|
||||
dest.writeString( this.userPhone );
|
||||
dest.writeString( this.startStation );
|
||||
dest.writeString( this.startStationId );
|
||||
dest.writeList( this.startStationCoordinate );
|
||||
dest.writeString( this.endStation );
|
||||
dest.writeString( this.endStationId );
|
||||
dest.writeList( this.endStationCoordinate );
|
||||
dest.writeString( this.orderStartTime );
|
||||
dest.writeString( this.cityCode );
|
||||
dest.writeString( this.areaCode );
|
||||
dest.writeString( this.createTime );
|
||||
dest.writeInt( this.personNum );
|
||||
}
|
||||
|
||||
protected OCHTaxiOrderResponse2( Parcel in ) {
|
||||
this._id = in.readString();
|
||||
this.orderNo = in.readString();
|
||||
this.orderType = in.readInt();
|
||||
this.orderDispatchType = in.readInt();
|
||||
this.travelDistance = in.readDouble();
|
||||
this.userName = in.readString();
|
||||
this.userPhone = in.readString();
|
||||
this.startStation = in.readString();
|
||||
this.startStationId = in.readString();
|
||||
this.startStationCoordinate = new ArrayList< Double >();
|
||||
in.readList( this.startStationCoordinate, Double.class.getClassLoader() );
|
||||
this.endStation = in.readString();
|
||||
this.endStationId = in.readString();
|
||||
this.endStationCoordinate = new ArrayList< Double >();
|
||||
in.readList( this.endStationCoordinate, Double.class.getClassLoader() );
|
||||
this.orderStartTime = in.readString();
|
||||
this.cityCode = in.readString();
|
||||
this.areaCode = in.readString();
|
||||
this.createTime = in.readString();
|
||||
this.personNum = in.readInt();
|
||||
}
|
||||
|
||||
public static final Creator< OCHTaxiOrderResponse2 > CREATOR = new Creator< OCHTaxiOrderResponse2 >() {
|
||||
@Override
|
||||
public OCHTaxiOrderResponse2 createFromParcel( Parcel source ) {
|
||||
return new OCHTaxiOrderResponse2( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCHTaxiOrderResponse2[] newArray( int size ) {
|
||||
return new OCHTaxiOrderResponse2[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@ import androidx.annotation.NonNull;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.taxi.IMogoOCHTaxiArriveCallback;
|
||||
import com.mogo.och.taxi.MogoOCHTaxi;
|
||||
import com.mogo.och.taxi.MogoOCHTaxiModel;
|
||||
import com.mogo.och.taxi.OCHOrderStatus;
|
||||
import com.mogo.och.taxi.OCHOrderStatusCallback;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -52,7 +53,29 @@ class OCHTaxiFragment extends MvpFragment< OCHTaxiView, OCHTaxiPresenter > imple
|
||||
autoPilot = findViewById( R.id.autoPilot );
|
||||
orderInfo.setText( MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().toString() );
|
||||
autoPilot.setOnClickListener( view -> {
|
||||
if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
|
||||
Logger.w( TAG, "已到达终点" );
|
||||
return;
|
||||
}
|
||||
MogoOCHTaxiModel.getInstance().startAutoPilot();
|
||||
MogoOCHTaxiModel.getInstance().setOnTheWay2EndStation( true );
|
||||
MogoOCHTaxiModel.getInstance().updateOCHOrderStatus( OCHOrderStatus.OnTheWayToEndStation, new OCHOrderStatusCallback() {
|
||||
@Override
|
||||
public void onSuccess( Object data ) {
|
||||
Logger.d( TAG, "更新状态成功" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
Logger.d( TAG, "更新状态失败" );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Logger.d( TAG, "更新状态失败2" );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
if ( MogoApisHandler.getInstance()
|
||||
@@ -99,30 +122,50 @@ class OCHTaxiFragment extends MvpFragment< OCHTaxiView, OCHTaxiPresenter > imple
|
||||
}
|
||||
|
||||
private void initOrderStatus() {
|
||||
if ( MogoOCHTaxiModel.getInstance().isArriveAtStartStation() ) {
|
||||
|
||||
if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
|
||||
Logger.d( TAG, "已经达到终点" );
|
||||
return;
|
||||
}
|
||||
if ( MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
|
||||
|
||||
Logger.d( TAG, "已经去往终点" );
|
||||
return;
|
||||
}
|
||||
if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
|
||||
|
||||
if ( MogoOCHTaxiModel.getInstance().isArriveAtStartStation() ) {
|
||||
Logger.d( TAG, "已经达到起点" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArriveAtStartStation() {
|
||||
Logger.d( TAG, "达到起点" );
|
||||
Logger.d( TAG, "通知达到起点" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArriveAtEndStation() {
|
||||
Logger.d( TAG, "达到终点" );
|
||||
Logger.d( TAG, "通知达到终点" );
|
||||
MogoOCHTaxiModel.getInstance().updateOCHOrderStatus( OCHOrderStatus.ArriveAtEndStation, new OCHOrderStatusCallback() {
|
||||
@Override
|
||||
public void onSuccess( Object data ) {
|
||||
Logger.d( TAG, "更新状态成功" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
Logger.d( TAG, "更新状态失败" );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Logger.d( TAG, "更新状态失败2" );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTheWay2EndStation() {
|
||||
Logger.d( TAG, "去往终点" );
|
||||
Logger.d( TAG, "通知去往终点" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.taxi.ui;
|
||||
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
@@ -50,19 +51,11 @@ class OCHTaxiUiController implements IMogoOCHTaxiArriveCallback {
|
||||
public void init( FragmentActivity activity, int containerId ) {
|
||||
mActivity = activity;
|
||||
mContainerId = containerId;
|
||||
addFragment();
|
||||
}
|
||||
|
||||
public void addFragment() {
|
||||
|
||||
if ( Looper.myLooper() != Looper.getMainLooper() ) {
|
||||
UiThreadHandler.post( () -> {
|
||||
addFragmentImpl();
|
||||
} );
|
||||
} else {
|
||||
addFragmentImpl();
|
||||
}
|
||||
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
runOnUIThread( this::addFragmentImpl );
|
||||
}
|
||||
|
||||
private void addFragmentImpl() {
|
||||
@@ -84,15 +77,17 @@ class OCHTaxiUiController implements IMogoOCHTaxiArriveCallback {
|
||||
}
|
||||
|
||||
public void removeFragment() {
|
||||
Fragment fragment = null;
|
||||
FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
|
||||
fragment = fragmentManager.findFragmentByTag( OCHTaxiFragment.TAG );
|
||||
if ( fragment == null ) {
|
||||
return;
|
||||
}
|
||||
fragmentManager.beginTransaction()
|
||||
.remove( fragment )
|
||||
.commitNowAllowingStateLoss();
|
||||
runOnUIThread( () -> {
|
||||
Fragment fragment = null;
|
||||
FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
|
||||
fragment = fragmentManager.findFragmentByTag( OCHTaxiFragment.TAG );
|
||||
if ( fragment == null ) {
|
||||
return;
|
||||
}
|
||||
fragmentManager.beginTransaction()
|
||||
.remove( fragment )
|
||||
.commitNowAllowingStateLoss();
|
||||
} );
|
||||
}
|
||||
|
||||
public void setOCHTaxiArriveCallback( IMogoOCHTaxiArriveCallback OCHTaxiArriveCallback ) {
|
||||
@@ -103,7 +98,7 @@ class OCHTaxiUiController implements IMogoOCHTaxiArriveCallback {
|
||||
public void onArriveAtStartStation() {
|
||||
runOnUIThread( () -> {
|
||||
if ( mOCHTaxiArriveCallback != null ) {
|
||||
mOCHTaxiArriveCallback.onArriveAtEndStation();
|
||||
mOCHTaxiArriveCallback.onArriveAtStartStation();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -902,7 +902,9 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
// vr 模式切换到普通模式下,保持之前的白天模式 wtf.
|
||||
if ( last == EnumMapUI.Type_VR && mCurrentUI != last ) {
|
||||
if ( last == EnumMapUI.Type_VR
|
||||
&& mCurrentUI != last
|
||||
&& mCurrentUI != EnumMapUI.Type_Light ) {
|
||||
if ( mIsLightStyle ) {
|
||||
changeMapMode( EnumMapUI.Type_Light );
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user