Merge branch 'dev_robotaxi-d-app-module_2100_220816_2.10.0' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_robotaxi-d-app-module_2100_220816_2.10.0
This commit is contained in:
@@ -67,6 +67,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
private RelativeLayout ctvAutopilotStatus;
|
||||
private ImageView ctvAutopilotStatusIv;
|
||||
private TextView ctvAutopilotStatusTv;
|
||||
private TextView tvArrived;
|
||||
protected TextView tvOperationStatus;
|
||||
protected RelativeLayout mSettingBtn;
|
||||
protected RelativeLayout mBadcaseBtn;
|
||||
@@ -120,6 +121,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
// CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView);
|
||||
|
||||
tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status);
|
||||
tvArrived = findViewById(R.id.module_mogo_och_arrived_tv);
|
||||
|
||||
flSpeed = (FrameLayout) findViewById(R.id.fl_speed);
|
||||
mTrafficDataView = (TrafficDataView) findViewById(R.id.bus_arc);
|
||||
@@ -198,6 +200,10 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
tvOperationStatus.setOnClickListener(view -> {
|
||||
onChangeOperationStatus();
|
||||
});
|
||||
|
||||
tvArrived.setOnClickListener(view -> {
|
||||
onArriveStation();
|
||||
});
|
||||
|
||||
mSettingBtn = findViewById(R.id.module_mogo_och_setting_layout);
|
||||
mSettingBtn.setOnClickListener(v -> {
|
||||
@@ -226,6 +232,8 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void onArriveStation();
|
||||
|
||||
private void updateSwitchMapIcon(){
|
||||
if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight()) {
|
||||
mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long);
|
||||
@@ -284,6 +292,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
getActivity().runOnUiThread(() -> {
|
||||
slidePanelView.setText(text);
|
||||
slidePanelView.setVisibility(View.VISIBLE);
|
||||
tvArrived.setClickable(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -294,6 +303,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
public void hideSlidePanel() {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
slidePanelView.setVisibility(View.GONE);
|
||||
tvArrived.setClickable(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
private TextView mLineName;
|
||||
private int mCurrentStation = 0;
|
||||
|
||||
private View mBus;
|
||||
// private View mBus;
|
||||
|
||||
private BusStationBean startStation = null;
|
||||
private BusStationBean endStation = null;
|
||||
@@ -63,19 +63,20 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
@Override
|
||||
protected void initViews() {
|
||||
super.initViews();
|
||||
mBus = findViewById(R.id.module_och_bus_tag);
|
||||
// mBus = findViewById(R.id.module_och_bus_tag);
|
||||
mCurrentStationName = findViewById(R.id.module_och_bus_current_station);
|
||||
mCurrentTag = findViewById(R.id.module_och_bus_current_station_anchor);
|
||||
mNextStationName = findViewById(R.id.module_och_bus_order_end_station);
|
||||
mNextTag = findViewById(R.id.module_och_bus_next_station_anchor);
|
||||
mSwitchLine = findViewById(R.id.switch_line_btn);
|
||||
mSwitchLine.setTag(0);
|
||||
mLineName = findViewById(R.id.module_och_bus_line_name);
|
||||
|
||||
if (DebugConfig.isDebug()) {
|
||||
mBus.setOnClickListener(view -> {
|
||||
ToastUtils.showShort("重置了车站状态");
|
||||
mPresenter.queryBusRoutes();
|
||||
});
|
||||
// if (DebugConfig.isDebug()) { //任意模式下都打开调试面板
|
||||
// mBus.setOnClickListener(view -> {
|
||||
// ToastUtils.showShort("重置了车站状态");
|
||||
// mPresenter.queryBusRoutes();
|
||||
// });
|
||||
|
||||
//debug下调用测试面板
|
||||
mCurrentStationName.setOnLongClickListener(v -> {
|
||||
@@ -83,7 +84,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
showHideTestBar();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
// }
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
// 初始化的时候设置 UI 按钮状态
|
||||
@@ -105,6 +106,11 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
mSwitchLine.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onArriveStation() {
|
||||
mPresenter.onAutopilotArriveAtStation(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void debugArrivedStation() {
|
||||
mPresenter.onAutopilotArriveAtStation(null);
|
||||
@@ -235,10 +241,14 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
}
|
||||
|
||||
private void showOrHideSwitchLineBtn(boolean isShow) {
|
||||
if (isShow){
|
||||
mSwitchLine.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
mSwitchLine.setVisibility(View.GONE);
|
||||
if (isShow){//显示切换路线
|
||||
// mSwitchLine.setVisibility(View.VISIBLE);
|
||||
mSwitchLine.setTag(0);
|
||||
mSwitchLine.setText(getResources().getString(R.string.bus_switch_line_btn));
|
||||
}else {//显示结束路线
|
||||
// mSwitchLine.setVisibility(View.GONE);
|
||||
mSwitchLine.setTag(1);
|
||||
mSwitchLine.setText(getResources().getString(R.string.bus_close_line_btn));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,12 +402,12 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning1));
|
||||
return;
|
||||
}
|
||||
if (mCurrentStation > 0) {
|
||||
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning2));
|
||||
return;
|
||||
if ((int)mSwitchLine.getTag() == 0){//切换路线
|
||||
Intent intent = new Intent(getContext(), BusSwitchLineActivity.class);
|
||||
startActivity(intent);
|
||||
}else {//结束路线
|
||||
mPresenter.resetCurrentLineStatus();
|
||||
}
|
||||
Intent intent = new Intent(getContext(), BusSwitchLineActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class BusLineModel {
|
||||
}
|
||||
|
||||
public void commitSwitchLineId(int lineId){
|
||||
BusServiceManager.getInstance().resetStationStatus(mContext,lineId, new IBusServiceCallback<BusRoutesResponse>() {
|
||||
BusServiceManager.getInstance().switchLine(mContext,lineId, new IBusServiceCallback<BusRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusRoutesResponse o) {
|
||||
if (mBusLinesCallback != null){
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.location.Location;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -444,11 +443,11 @@ public class BusOrderModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试、重置站点状态
|
||||
* 重置路线站点状态--结束路线,当前路线恢复到始发站
|
||||
*/
|
||||
public void debugResetStationStatus() {
|
||||
CallerLogger.INSTANCE.d( M_BUS + TAG, "测试、重置站点状态");
|
||||
BusServiceManager.getInstance().resetStationStatus(mContext, currentLineId
|
||||
public void resetCurrentLineStatus() {
|
||||
CallerLogger.INSTANCE.d( M_BUS + TAG, "结束当前路线");
|
||||
BusServiceManager.getInstance().resetCurrentLineStatus(mContext, currentLineId
|
||||
, new IBusServiceCallback<BusRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusRoutesResponse o) {
|
||||
@@ -520,9 +519,9 @@ public class BusOrderModel {
|
||||
)
|
||||
private void leaveStationSuccess(BusRoutesResult result, boolean isRestart) {
|
||||
renderBusStationsStatus(result);
|
||||
if (slidePannelHideCallback != null) {
|
||||
slidePannelHideCallback.hideSlidePanel();
|
||||
}
|
||||
// if (slidePannelHideCallback != null) {
|
||||
// slidePannelHideCallback.hideSlidePanel();
|
||||
// }
|
||||
//开启自动驾驶
|
||||
startAutopilot(isRestart);
|
||||
if (isGoingToNextStation) {
|
||||
|
||||
@@ -74,13 +74,27 @@ public class BusServiceManager {
|
||||
* @param lineId
|
||||
* @param callback
|
||||
*/
|
||||
public void resetStationStatus(Context context, int lineId, IBusServiceCallback<BusRoutesResponse> callback){
|
||||
mService.resetStationStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
public void switchLine(Context context, int lineId, IBusServiceCallback<BusRoutesResponse> callback){
|
||||
mService.switchLine(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),new BusResetDrivingLineRequest(lineId))
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"debugResetStationStatus"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束当前路线,当前路线状态重置到始发站
|
||||
* @param context
|
||||
* @param lineId
|
||||
* @param callback
|
||||
*/
|
||||
public void resetCurrentLineStatus(Context context, int lineId, IBusServiceCallback<BusRoutesResponse> callback){
|
||||
// mService.switchLine(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
// ,MoGoAiCloudClientConfig.getInstance().getToken(),new BusResetDrivingLineRequest(lineId))
|
||||
// .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(getSubscribeImpl(context,callback,"debugResetStationStatus"));
|
||||
// TODO 需要重置接口
|
||||
}
|
||||
|
||||
/**
|
||||
* 离站上报
|
||||
* @param context
|
||||
|
||||
@@ -42,8 +42,6 @@ public interface IBusApiService {
|
||||
Observable<BusRoutesResponse> querySiteByCoordinate(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request);
|
||||
|
||||
/**
|
||||
* 重置巴士路线: 点击小巴车tab 或者出车后会使用
|
||||
*
|
||||
* @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的
|
||||
* @return 返回值是重置后的车站列表
|
||||
*/
|
||||
@@ -51,7 +49,7 @@ public interface IBusApiService {
|
||||
// @POST( "/autopilot-car-hailing/car/v2/bus/drivingLine/reset" )
|
||||
@POST( "/autopilot-car-hailing/car/v2/driver/bus/drivingLine/reset" )
|
||||
// @POST( "/mock/268/autopilot-car-hailing/bus/api/drivingLine/reset" )
|
||||
Observable<BusRoutesResponse> resetStationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request);
|
||||
Observable<BusRoutesResponse> switchLine(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request);
|
||||
|
||||
/**
|
||||
* 离站,通知服务器
|
||||
|
||||
@@ -90,8 +90,8 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
BusOrderModel.getInstance().queryBusRoutes();
|
||||
}
|
||||
|
||||
public void debugResetStationStatus() {
|
||||
BusOrderModel.getInstance().debugResetStationStatus();
|
||||
public void resetCurrentLineStatus() {
|
||||
BusOrderModel.getInstance().resetCurrentLineStatus();
|
||||
}
|
||||
|
||||
public void autoDriveToNextStation(boolean isRestart) {
|
||||
|
||||
@@ -82,8 +82,8 @@
|
||||
android:background="@drawable/bus_switch_map_bg"
|
||||
android:elevation="@dimen/bus_dp_10"
|
||||
android:padding="@dimen/bus_dp_20"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_mogo_och_operation_status"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_mogo_och_operation_status"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_mogo_och_arrived_tv"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_mogo_och_arrived_tv"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
@@ -109,6 +109,22 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_mogo_och_arrived_tv"
|
||||
android:layout_width="@dimen/module_mogo_och_operation_status_bg_width"
|
||||
android:layout_height="@dimen/module_mogo_och_operation_status_bg_height"
|
||||
android:background="@drawable/bus_operation_status_bg_selector"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:text="@string/bus_arrived_str"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/bus_autopilot_text_color_selector"
|
||||
android:textSize="@dimen/module_mogo_och_arrived_text_size"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginLeft="@dimen/module_mogo_och_margin_left"
|
||||
android:layout_marginBottom="@dimen/module_mogo_och_margin_bottom"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_mogo_och_operation_status"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/module_mogo_och_setting_layout"
|
||||
android:layout_width="@dimen/module_mogo_och_operation_status_bg_width"
|
||||
@@ -137,12 +153,13 @@
|
||||
android:elevation="@dimen/dp_10"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@id/module_mogo_och_setting_layout">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/bad_case_selector"/>
|
||||
android:src="@drawable/bad_case_selector" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_och_bus_line_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_68"
|
||||
android:layout_marginRight="@dimen/dp_20"
|
||||
@@ -23,26 +23,25 @@
|
||||
android:textColor="#FFF"
|
||||
android:textSize="38px"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintRight_toLeftOf="@+id/module_och_bus_tag"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_och_bus_tag"
|
||||
android:layout_width="@dimen/dp_109"
|
||||
android:layout_height="@dimen/dp_42"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginRight="@dimen/dp_60"
|
||||
android:background="@drawable/bus_panel_anchor_bkg"
|
||||
android:gravity="center"
|
||||
android:text="小巴车"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="@dimen/module_mogo_och_autopilot_order_tag_height"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_och_bus_line_name"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/module_och_bus_line_name" />
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/module_och_bus_tag"-->
|
||||
<!-- android:layout_width="@dimen/dp_109"-->
|
||||
<!-- android:layout_height="@dimen/dp_42"-->
|
||||
<!-- android:layout_gravity="right"-->
|
||||
<!-- android:layout_marginTop="@dimen/dp_10"-->
|
||||
<!-- android:layout_marginRight="@dimen/dp_60"-->
|
||||
<!-- android:background="@drawable/bus_panel_anchor_bkg"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- android:text="小巴车"-->
|
||||
<!-- android:textColor="#FFF"-->
|
||||
<!-- android:textSize="@dimen/module_mogo_och_autopilot_order_tag_height"-->
|
||||
<!-- android:textStyle="bold"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="@+id/module_och_bus_line_name"-->
|
||||
<!-- app:layout_constraintRight_toRightOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="@id/module_och_bus_line_name" />-->
|
||||
|
||||
<View
|
||||
android:id="@+id/line1"
|
||||
@@ -53,7 +52,7 @@
|
||||
android:layout_marginRight="@dimen/dp_30"
|
||||
android:background="@drawable/bus_line_dividing_line1_selector"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_och_bus_tag" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_och_bus_line_name" />
|
||||
|
||||
<View
|
||||
android:id="@+id/line2"
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
|
||||
|
||||
<dimen name="module_mogo_och_autopilot_status_text_size">40px</dimen>
|
||||
<dimen name="module_mogo_och_arrived_text_size">32px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_padding_top">13px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_drawable_padding">12px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_m_l">350px</dimen>
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
|
||||
|
||||
<dimen name="module_mogo_och_autopilot_status_text_size">40px</dimen>
|
||||
<dimen name="module_mogo_och_arrived_text_size">32px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_padding_top">13px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_drawable_padding">12px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_m_l">350px</dimen>
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
<dimen name="module_mogo_och_autopilot_order_bg_height">270px</dimen>
|
||||
|
||||
<dimen name="module_mogo_och_autopilot_status_text_size">30px</dimen>
|
||||
<dimen name="module_mogo_och_arrived_text_size">30px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_padding_top">13px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_drawable_padding">12px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_m_l">288px</dimen>
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
<string name="bus_switch_line_end">终点:</string>
|
||||
<string name="bus_switch_line_btn_txt">确认</string>
|
||||
<string name="bus_switch_line_btn">切换路线</string>
|
||||
<string name="bus_switch_line_btn_warning1">自动驾驶中,不可切换路线</string>
|
||||
<string name="bus_close_line_btn">结束路线</string>
|
||||
<string name="bus_switch_line_btn_warning1">自动驾驶状态中,不可切换或结束路线</string>
|
||||
<string name="bus_switch_line_btn_warning2">当前行程未完成,不可切换路线</string>
|
||||
<string name="bus_no_line_tip">当前车辆无路线\n请联系运营人员绑定</string>
|
||||
<string name="bus_line_start">起点: </string>
|
||||
@@ -24,4 +25,5 @@
|
||||
<string name="bus_arrive_to_current_tag">当前站点:</string>
|
||||
<string name="bus_arrive_to_next_tag">下一站:</string>
|
||||
<string name="bus_auto_disable_tip">自动驾驶状态为0不可用</string>
|
||||
<string name="bus_arrived_str">进站</string>
|
||||
</resources>
|
||||
|
||||
@@ -165,8 +165,8 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
|
||||
mSpeedView = findViewById(R.id.module_mogo_och_speed_tv);
|
||||
mCloseNaviIcon = findViewById(R.id.taxi_close_navi_icon);
|
||||
flNaviPanelContainer = findViewById(R.id.module_mogo_och_navi_panel_container);
|
||||
if (DebugConfig.isDebug()) {
|
||||
mSpeedView.setLongClickable(true);
|
||||
// if (DebugConfig.isDebug()) {
|
||||
mSpeedView.setLongClickable(true); //调试按钮任意模式下都开
|
||||
// TODO: 2021/11/27 暂去除此调试功能
|
||||
// mSpeedView.setOnClickListener(v -> {
|
||||
// onAutopilotStatusChanged(false);
|
||||
@@ -178,7 +178,7 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
|
||||
// MogoApisHandler.getInstance().getApis().getIntentManagerApi().invoke("com.mogo.mock", intent);
|
||||
// return true;
|
||||
// });
|
||||
}
|
||||
// }
|
||||
|
||||
tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status);
|
||||
mDriverRole = findViewById(R.id.taxi_driver_role_tv);
|
||||
@@ -248,8 +248,8 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
|
||||
}
|
||||
});
|
||||
|
||||
// debug下调用测试面板 长按速度值
|
||||
if (DebugConfig.isDebug()) {
|
||||
// debug下调用测试面板 长按速度值 任意模式下调试都打开
|
||||
// if (DebugConfig.isDebug()) {
|
||||
mSpeedView.setOnLongClickListener(v -> {
|
||||
if (groupTestPanel.getVisibility() == View.VISIBLE) {
|
||||
groupTestPanel.setVisibility(View.GONE);
|
||||
@@ -258,7 +258,7 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
// }
|
||||
|
||||
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
|
||||
|
||||
@@ -143,9 +143,9 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implement
|
||||
|
||||
isHaveBeingOrder(false);
|
||||
|
||||
if (DebugConfig.isDebug()) {
|
||||
// if (DebugConfig.isDebug()) { //任意模式下调试信息都打开
|
||||
initOrderTestBar(view);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,17 +28,20 @@ if (!isAndroidTestBuild()) {
|
||||
apply plugin: 'apm-plugin'
|
||||
}
|
||||
|
||||
if (!isAndroidTestBuild()) {
|
||||
apply plugin: 'bytex.threadOpt'
|
||||
thread_opt {
|
||||
enable true
|
||||
enableInDebug true
|
||||
logLevel "DEBUG"
|
||||
//白名单中的类不进行替换
|
||||
white_list = [
|
||||
'leakcanary.*',
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//if (!isAndroidTestBuild()) {
|
||||
// apply plugin: 'bytex.threadOpt'
|
||||
// thread_opt {
|
||||
// enable true
|
||||
// enableInDebug true
|
||||
// rxJavaIoReplacer 'com/mogo/eagle/core/utilcode/util/ThreadUtils@@getIoPool@@()Ljava/util/concurrent/ExecutorService;'
|
||||
// rxJavaComputationReplacer 'com/mogo/eagle/core/utilcode/util/ThreadUtils@@getCpuPool@@()Ljava/util/concurrent/ExecutorService;'
|
||||
// coroutineIoReplacer 'com/mogo/eagle/core/utilcode/util/ThreadUtils@@getIoPool@@()Ljava/util/concurrent/ExecutorService;'
|
||||
// coroutineDefaultReplacer 'com/mogo/eagle/core/utilcode/util/ThreadUtils@@getCpuPool@@()Ljava/util/concurrent/ExecutorService;'
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 方便使用systrace工具,在工程侧打点,便于分析工程侧性能问题
|
||||
// */
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
package com.mogo.launcher;
|
||||
|
||||
import com.mogo.eagle.core.function.main.MainMoGoApplication;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.launcher.crash.CrashSystem;
|
||||
import com.mogo.thread.ext.core.ThreadManager;
|
||||
import com.mogo.thread.ext.core.config.ThreadConfig;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -13,6 +25,41 @@ import com.mogo.launcher.crash.CrashSystem;
|
||||
*/
|
||||
public class MogoApplication extends MainMoGoApplication {
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
ThreadConfig.Builder builder = new ThreadConfig.Builder().listener(new ThreadConfig.TaskExecuteListener() {
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true; // 如果返回true,会有后续的回调;如果返回false, 不会有后续的回调
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutorBefore(@NonNull Runnable runnable) {
|
||||
//每个任务执行前回调
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutorAfter(@NonNull Runnable runnable) {
|
||||
//每个任务执行后回调
|
||||
}
|
||||
|
||||
/**
|
||||
* @param core 线程池的核心数
|
||||
* @param max 线程池的最大线程数
|
||||
* @param active 线程池正在活跃的任务数
|
||||
* @param completed 线程池已完成的任务数
|
||||
*/
|
||||
@Override
|
||||
public void onExecutorStateChanged(@NonNull ThreadPoolExecutor pool, int core, int max, int active, long completed) {
|
||||
//线程池在执行过程,状态变化回调
|
||||
//Log.d("POOL", "core:" + core + ";max:" + max + ";active:" + active + ";completed:" + completed);
|
||||
}
|
||||
});
|
||||
builder.loggable(false);
|
||||
ThreadManager.INSTANCE.init(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initCrashConfig() {
|
||||
CrashSystem crashSystem = CrashSystem.getInstance(this);
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ProcessUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadPoolService
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.map.location.GDLocationClient
|
||||
import com.mogo.module.common.constants.HostConst
|
||||
import com.rousetime.android_startup.AndroidStartup
|
||||
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
|
||||
@@ -74,12 +75,17 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
override fun create(context: Context): Boolean {
|
||||
this.context = context
|
||||
if (ProcessUtils.isMainProcess(context)) {
|
||||
initGDLoc()
|
||||
initHttpDns()
|
||||
initCloudClientConfig()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun initGDLoc() {
|
||||
GDLocationClient.getInstance(context).start()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 HttpDNS ,这里会通过一个接口获取所有鹰眼中使用的微服务域名以及端口号
|
||||
* 后续的网络请求会通过 HttpDnsInterceptor 进行拦截替换
|
||||
@@ -126,10 +132,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
//设置长链接的secretKey //todo 通过SHA1和包名找中台服务生成,后续包名分渠道,需要做对应操作
|
||||
clientConfig.secretKey = "YMj2VFDFxJ3Q4gNoZceJ"
|
||||
|
||||
// todo 使用旧链路
|
||||
// clientConfig.setUseOriginSocket(true);
|
||||
clientConfig.iHttpDnsCurrentLocation = object : IHttpDnsCurrentLocation {
|
||||
override fun getCurrentLocation(): HttpDnsSimpleLocation? {
|
||||
override fun getCurrentLocation(): HttpDnsSimpleLocation {
|
||||
val envConfig = EnvChangeManager.getEnvConfig()
|
||||
if (envConfig != null) {
|
||||
return HttpDnsSimpleLocation(envConfig.cityCode, envConfig.lat, envConfig.lon)
|
||||
@@ -141,13 +145,23 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
mogoLocation = locationClient.lastKnowLocation
|
||||
}
|
||||
val httpDnsSimpleLocation =
|
||||
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0
|
||||
) {
|
||||
HttpDnsSimpleLocation(
|
||||
mogoLocation.cityCode,
|
||||
mogoLocation.latitude,
|
||||
mogoLocation.longitude
|
||||
)
|
||||
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0) {
|
||||
if (mogoLocation.cityCode.isNullOrEmpty() && !GDLocationClient.getInstance(
|
||||
context
|
||||
).lastCityCode.isNullOrEmpty()
|
||||
) {
|
||||
HttpDnsSimpleLocation(
|
||||
GDLocationClient.getInstance(context).lastCityCode,
|
||||
mogoLocation.latitude,
|
||||
mogoLocation.longitude
|
||||
)
|
||||
} else {
|
||||
HttpDnsSimpleLocation(
|
||||
mogoLocation.cityCode,
|
||||
mogoLocation.latitude,
|
||||
mogoLocation.longitude
|
||||
)
|
||||
}
|
||||
} else {
|
||||
val ciyCode =
|
||||
SharedPrefsMgr.getInstance(
|
||||
@@ -172,7 +186,6 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
// e.printStackTrace();
|
||||
HttpDnsSimpleLocation("010", 1.0, 1.0)
|
||||
}
|
||||
//CallerLogger.INSTANCE.d(M_HMI + TAG, "使用缓存GPS信息:" + httpDnsSimpleLocation);
|
||||
}
|
||||
return httpDnsSimpleLocation
|
||||
}
|
||||
@@ -242,10 +255,10 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
linkCode = CHAIN_LINK_CLOUD_SHOW,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED,
|
||||
paramIndexes = [0],
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onAddressChanged(address: Map<String, String>?) {
|
||||
override fun onAddressChanged(cityCode: String, address: Map<String, String>?) {
|
||||
val dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(
|
||||
host,
|
||||
HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP
|
||||
@@ -323,6 +336,18 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
CallerLogger.d(SceneConstant.M_HMI + TAG, "socket-onConnectLost")
|
||||
DebugConfig.setDownloadSnapshot(false)
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
linkCode = CHAIN_LINK_CLOUD_SHOW,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onError(code: String, msg: String?) {
|
||||
CallerLogger.d(SceneConstant.M_HMI + TAG, "socket-onConnectLost")
|
||||
}
|
||||
})
|
||||
// 开启Socket长链服务
|
||||
val lat = location.latitude
|
||||
|
||||
@@ -4,7 +4,6 @@ apply from: "javadoc.gradle"
|
||||
buildscript {
|
||||
|
||||
repositories {
|
||||
|
||||
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
maven { url "https://artifact.bytedance.com/repository/byteX/" }
|
||||
maven { url 'http://nexus.zhidaoauto.com/repository/maven-releases/' }
|
||||
@@ -33,7 +32,7 @@ buildscript {
|
||||
classpath "com.bytedance.android.byteX:base-plugin:0.3.0"
|
||||
classpath "com.mogo.cloud:hook:${HOOK_LOG_VERSION}"
|
||||
classpath 'com.volcengine:apm_insight_plugin:1.4.1'
|
||||
classpath 'com.mogo.cloud:thread_opt:1.0.1'
|
||||
classpath 'com.mogo.cloud:thread_opt:5.0.5'
|
||||
classpath 'com.mogo.cloud:systrace:1.0.1'
|
||||
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
android:id="@+id/tvHmiPncActions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_30"
|
||||
android:textSize="@dimen/sp_38"
|
||||
android:textColor="#FFFFFF"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -51,6 +51,7 @@ class ChainConstant {
|
||||
const val CHAIN_ALIAS_CODE_CLOUD_CONNECT_FAIL = "CHAIN_ALIAS_CODE_CLOUD_CONNECT_FAIL"
|
||||
const val CHAIN_ALIAS_CODE_CLOUD_CONNECT_SUCCESS = "CHAIN_ALIAS_CODE_CLOUD_CONNECT_SUCCESS"
|
||||
const val CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST = "CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST"
|
||||
const val CHAIN_ALIAS_CODE_CLOUD_CONNECT_ERROR = "CHAIN_ALIAS_CODE_CLOUD_CONNECT_ERROR"
|
||||
const val CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED = "CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED"
|
||||
|
||||
const val CHAIN_ALIAS_CODE_INIT_ON_MAP_LOADED = "CHAIN_ALIAS_CODE_INIT_ON_MAP_LOADED"
|
||||
|
||||
@@ -6,4 +6,8 @@ public interface IMogoLifecycleListener {
|
||||
void onConnectSuccess();
|
||||
|
||||
void onConnectLost();
|
||||
|
||||
default void onError(String code, String msg){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketErrorListener;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketMsgAckListener;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.cloud.socket.SocketManager;
|
||||
@@ -24,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* 长链实现:基于 netty
|
||||
*/
|
||||
@Keep
|
||||
public class MogoAiCloudSocketManager extends ConnectionLifecycleListener implements IMogoSocketManager {
|
||||
public class MogoAiCloudSocketManager extends ConnectionLifecycleListener implements IMogoSocketManager, IMogoCloudSocketErrorListener {
|
||||
|
||||
private static final String TAG = "MogoAiCloudSocketManager-sdk";
|
||||
|
||||
@@ -70,6 +71,7 @@ public class MogoAiCloudSocketManager extends ConnectionLifecycleListener implem
|
||||
this.mAppId = appId;
|
||||
SocketManager.getInstance().init(context, lat, lon);
|
||||
SocketManager.getInstance().registerSocketConnCallback(this);
|
||||
SocketManager.getInstance().registerSocketErrorCallback(TAG, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,6 +142,7 @@ public class MogoAiCloudSocketManager extends ConnectionLifecycleListener implem
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
SocketManager.getInstance().unregisterSocketErrorCallback(TAG);
|
||||
SocketManager.getInstance().release();
|
||||
}
|
||||
|
||||
@@ -212,4 +215,15 @@ public class MogoAiCloudSocketManager extends ConnectionLifecycleListener implem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
if (mLifeCycleListeners.size() > 0) {
|
||||
for (IMogoLifecycleListener lifecycleListener : mLifeCycleListeners.values()) {
|
||||
if (lifecycleListener != null) {
|
||||
lifecycleListener.onError(code + "", msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,23 +63,23 @@ SERVICE_CHAIN_VERSION=1.1.0
|
||||
LOGLIB_VERSION=1.3.31
|
||||
######## MogoAiCloudSDK Version ########
|
||||
# 网络请求LOGLIB_VERSION
|
||||
MOGO_NETWORK_VERSION=1.4.3.8
|
||||
MOGO_NETWORK_VERSION=1.4.3.17
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.4.3.8
|
||||
MOGO_PASSPORT_VERSION=1.4.3.17
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.4.3.8
|
||||
MOGO_SOCKET_VERSION=1.4.3.17
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.4.3.8
|
||||
MOGO_REALTIME_VERSION=1.4.3.17
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.4.3.8
|
||||
MOGO_TANLU_VERSION=1.4.3.17
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.4.3.8
|
||||
MOGO_LIVE_VERSION=1.4.3.17
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.3.8
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.3.17
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.4.3.8
|
||||
MOGO_LOCATION_VERSION=1.4.3.17
|
||||
# 远程通讯模块
|
||||
MOGO_TELEMATIC_VERSION=1.4.3.8
|
||||
MOGO_TELEMATIC_VERSION=1.4.3.17
|
||||
######## MogoAiCloudSDK Version ########
|
||||
# 自研地图
|
||||
MAP_SDK_VERSION=2.4.0.1
|
||||
@@ -90,8 +90,8 @@ WEBSOCKET_VERSION=1.1.7
|
||||
applicationId=com.mogo.launcer
|
||||
applicationName=IntelligentPilot
|
||||
# RoboBus司机端:2.5.1;RoboTaxi司机端:2.5.1;RoboTaxi乘客端:1.0.0
|
||||
versionCode=2090000
|
||||
versionName=2.9.0
|
||||
versionCode=2100000
|
||||
versionName=2.10.0
|
||||
|
||||
################# 新架构模块Maven版本管理 #################
|
||||
MOGO_CORE_FUNCTION_AUTOPILOT_VERSION=0.0.58.10
|
||||
@@ -155,7 +155,7 @@ MOGO_OCH_TAXI_VERSION=2.0.66
|
||||
# mogoAiCloud sdk services
|
||||
MOGO_AICLOUD_SERVICES_SDK_VERSION=2.1.16.10
|
||||
# v2x-sdk
|
||||
MOGO_V2X_SDK_VERSION=1.4.3.8
|
||||
MOGO_V2X_SDK_VERSION=1.4.3.17
|
||||
################# 旧版本架构模块版本 #################
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ dependencies {
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
// 高精地图
|
||||
implementation rootProject.ext.dependencies.mogocustommap
|
||||
// 高德地图
|
||||
api rootProject.ext.dependencies.amaplocation
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogomapapi
|
||||
|
||||
@@ -643,6 +643,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
/**
|
||||
* 设置转向灯和刹车灯
|
||||
*
|
||||
* @param type :车尾灯类型 time: 闪烁时间 最小500ms 小于500ms 默认为500ms
|
||||
* @param time
|
||||
*/
|
||||
@@ -748,9 +749,11 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
sysLocation.setSpeed(location.getSpeed());
|
||||
|
||||
// 将有效经纬度暂存本地,提供给下一次的Http-DNS使用,防止首次请求位置获取不到
|
||||
if (location.getLat() > 0) {
|
||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
|
||||
if (location.getLat() > 0 && location.getLon() > 0) {
|
||||
if (location.getCityCode() != null && !location.getCityCode().isEmpty()) {
|
||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
|
||||
}
|
||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||
.putString(SharedPrefsConstants.LOCATION_LATITUDE, String.valueOf(location.getLat()));
|
||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||
@@ -1000,7 +1003,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
bean.setAcceleration(gnssInfo.getAcceleration());
|
||||
bean.setAlt(gnssInfo.getAltitude());
|
||||
bean.setSystemTime(Double.valueOf(gnssInfo.getSystemTime()).longValue());
|
||||
bean.setSatelliteTime(Double.valueOf(gnssInfo.getSatelliteTime()*1000).longValue());
|
||||
bean.setSatelliteTime(Double.valueOf(gnssInfo.getSatelliteTime() * 1000).longValue());
|
||||
bean.setLon(gnssInfo.getLongitude());
|
||||
bean.setLat(gnssInfo.getLatitude());
|
||||
bean.setGnss_speed(((float) gnssInfo.getGnssSpeed()));
|
||||
@@ -1053,7 +1056,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getRoadAngle(Double lon,Double lat,float angle) {
|
||||
public Double getRoadAngle(Double lon, Double lat, float angle) {
|
||||
return MapDataApi.INSTANCE.getRoadRectInfo(lon, lat, angle).getAngle();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.mogo.map.location;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.location.AMapLocationClient;
|
||||
import com.amap.api.location.AMapLocationClientOption;
|
||||
import com.amap.api.location.AMapLocationListener;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.constants.SharedPrefsConstants;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
|
||||
public class GDLocationClient implements AMapLocationListener {
|
||||
|
||||
private volatile static GDLocationClient gdLocationClient;
|
||||
private static final byte[] obj = new byte[0];
|
||||
|
||||
public static GDLocationClient getInstance(Context context) {
|
||||
if (gdLocationClient == null) {
|
||||
synchronized (obj) {
|
||||
if (gdLocationClient == null) {
|
||||
gdLocationClient = new GDLocationClient(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return gdLocationClient;
|
||||
}
|
||||
|
||||
//声明LocationClient对象
|
||||
private final AMapLocationClient mLocationClient;
|
||||
private String mCityCode;
|
||||
|
||||
private GDLocationClient(Context context) {
|
||||
mLocationClient = new AMapLocationClient(context);
|
||||
//初始化定位参数
|
||||
//声明mLocationOption对象
|
||||
AMapLocationClientOption mLocationOption = new AMapLocationClientOption();
|
||||
//设置定位监听
|
||||
mLocationClient.setLocationListener(this);
|
||||
//设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
|
||||
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
|
||||
//设置定位间隔,单位毫秒,默认为2000ms
|
||||
mLocationOption.setInterval(1000);
|
||||
//设置定位参数
|
||||
mLocationClient.setLocationOption(mLocationOption);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mLocationClient.startLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(AMapLocation aMapLocation) {
|
||||
if (aMapLocation != null) {
|
||||
String cityCode = aMapLocation.getCityCode();
|
||||
if (cityCode != null && !cityCode.isEmpty()) {
|
||||
mCityCode = aMapLocation.getCityCode();
|
||||
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
|
||||
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, cityCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getLastCityCode() {
|
||||
return mCityCode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user