feat: 增加导航方式界面
This commit is contained in:
@@ -269,7 +269,7 @@ public class Constant {
|
||||
}
|
||||
|
||||
// 导航方式
|
||||
enum NAV_TYPE {
|
||||
public enum NAV_TYPE {
|
||||
CAR, RIDE, WALK
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.navinfo.outdoor.room.PoiEntity;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.Geohash;
|
||||
import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.NaviUtils;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
import com.tencent.lbssearch.httpresponse.Poi;
|
||||
@@ -193,13 +194,24 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (Constant.currentNaviType == null) {
|
||||
NaviUtils.getInstance().selectNaviType((AppCompatActivity) getActivity(), new NaviUtils.SelectNaviTypeListener() {
|
||||
@Override
|
||||
public void selectNaviType(Constant.NAV_TYPE nav_type) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 已选择导航方式
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* */
|
||||
|
||||
/**
|
||||
* 保存小数点后两位
|
||||
*
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.kongzue.dialog.v3.CustomDialog;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.tencent.map.navi.CalcRouteCallback;
|
||||
import com.tencent.map.navi.TencentNaviManager;
|
||||
import com.tencent.map.navi.car.CarRouteSearchOptions;
|
||||
import com.tencent.map.navi.car.TencentCarNaviManager;
|
||||
import com.tencent.map.navi.data.CalcRouteResult;
|
||||
import com.tencent.map.navi.data.NaviPoi;
|
||||
import com.tencent.map.navi.ride.TencentRideNaviManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class NaviUtils {
|
||||
private static NaviUtils instance;
|
||||
public static NaviUtils getInstance() {
|
||||
@@ -9,5 +31,94 @@ public class NaviUtils {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void selectNaviType(AppCompatActivity mContext, SelectNaviTypeListener selectNaviTypeListener) {
|
||||
CustomDialog selectNaviTypeDialog = CustomDialog.build(mContext, R.layout.dialog_select_navi_type, new CustomDialog.OnBindView() {
|
||||
@Override
|
||||
public void onBind(CustomDialog dialog, View v) {
|
||||
RadioGroup rgNaviType = v.findViewById(R.id.rg_navi_type);
|
||||
RadioButton rbtnCar = v.findViewById(R.id.navi_type_car);
|
||||
RadioButton rbtnRide = v.findViewById(R.id.navi_type_ride);
|
||||
RadioButton rbtnWalk = v.findViewById(R.id.navi_type_walk);
|
||||
if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) {
|
||||
rbtnCar.setChecked(true);
|
||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) {
|
||||
rbtnRide.setChecked(true);
|
||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.WALK) {
|
||||
rbtnWalk.setChecked(true);
|
||||
}
|
||||
TextView tvConfirm = v.findViewById(R.id.btn_navi_type_select_confirm);
|
||||
TextView tvCancel = v.findViewById(R.id.btn_navi_type_select_cancel);
|
||||
tvCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (dialog.isShow) {
|
||||
dialog.doDismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
tvConfirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!rbtnCar.isChecked()&&!rbtnRide.isChecked()&&!rbtnWalk.isChecked()) {
|
||||
ToastUtils.Message(mContext, "请选择导航方式!");
|
||||
return;
|
||||
}
|
||||
if (rbtnCar.isChecked()) {
|
||||
Constant.currentNaviType = Constant.NAV_TYPE.CAR;
|
||||
} else if (rbtnRide.isChecked()) {
|
||||
Constant.currentNaviType = Constant.NAV_TYPE.RIDE;
|
||||
} else if (rbtnWalk.isChecked()) {
|
||||
Constant.currentNaviType = Constant.NAV_TYPE.WALK;
|
||||
}
|
||||
if (Constant.currentNaviType!=null) {
|
||||
selectNaviTypeListener.selectNaviType(Constant.currentNaviType);
|
||||
}
|
||||
if (dialog.isShow) {
|
||||
dialog.doDismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
selectNaviTypeDialog.show();
|
||||
}
|
||||
|
||||
public TencentNaviManager obitainnaviManager(Context mContext, Constant.NAV_TYPE nav_type) {
|
||||
TencentNaviManager naviManager = null;
|
||||
if (nav_type == Constant.NAV_TYPE.CAR) {
|
||||
naviManager = new TencentCarNaviManager(mContext);
|
||||
} else if (nav_type == Constant.NAV_TYPE.RIDE) {
|
||||
naviManager = new TencentRideNaviManager(mContext);
|
||||
} else {
|
||||
naviManager = new TencentRideNaviManager(mContext);
|
||||
}
|
||||
return naviManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路径规划
|
||||
* */
|
||||
public void searchRoute(Constant.NAV_TYPE nav_type, TencentNaviManager naviManager,
|
||||
NaviPoi start, NaviPoi end) throws Exception {
|
||||
if (nav_type == Constant.NAV_TYPE.CAR) {
|
||||
TencentCarNaviManager carNaviManager = (TencentCarNaviManager)naviManager;
|
||||
|
||||
CarRouteSearchOptions options = CarRouteSearchOptions.create();
|
||||
carNaviManager.searchRoute(start, end, new ArrayList<>(), options, new CalcRouteCallback() {
|
||||
@Override
|
||||
public void onCalcRouteSuccess(CalcRouteResult calcRouteResult) {
|
||||
// 路径规划成功
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalcRouteFailure(CalcRouteResult calcRouteResult) {
|
||||
// 路径规划失败
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public interface SelectNaviTypeListener {
|
||||
void selectNaviType(Constant.NAV_TYPE nav_type);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user