[6.2.0]
[taxi taxi-u] [高德导航使用single 线程]
This commit is contained in:
@@ -25,7 +25,7 @@ import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.och.common.module.utils.PermissionUtil;
|
||||
import com.mogo.och.common.module.wigets.toast.ToastCharterUtils;
|
||||
|
||||
@@ -61,16 +61,18 @@ public class AmapNaviToDestinationModel implements AMapNaviListener {
|
||||
}
|
||||
|
||||
public void initAMapNavi(NaviLatLng startLatLng, NaviLatLng endLatLng) {
|
||||
try {
|
||||
CallerLogger.i( TAG, "initAMapNavi()");
|
||||
mAMapNavi = AMapNavi.getInstance(AbsMogoApplication.getApp());
|
||||
mAMapNavi.addAMapNaviListener(this);
|
||||
mAMapNavi.setUseInnerVoice(true, true);
|
||||
sList.add(startLatLng);
|
||||
eList.add(endLatLng);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ThreadUtils.getSinglePool().execute(() -> {
|
||||
try {
|
||||
CallerLogger.i(TAG, "initAMapNavi()");
|
||||
mAMapNavi = AMapNavi.getInstance(AbsMogoApplication.getApp());
|
||||
mAMapNavi.addAMapNaviListener(this);
|
||||
mAMapNavi.setUseInnerVoice(true, true);
|
||||
sList.add(startLatLng);
|
||||
eList.add(endLatLng);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setVoiceIsMute(boolean isPlay) {
|
||||
@@ -89,14 +91,16 @@ public class AmapNaviToDestinationModel implements AMapNaviListener {
|
||||
|
||||
public void destroyAmaNavi() {
|
||||
if (mAMapNavi != null) {
|
||||
CallerLogger.i( TAG, "destroyAmaNavi()");
|
||||
isPlay = false;
|
||||
sList.clear();
|
||||
eList.clear();
|
||||
mAMapNavi.stopNavi();
|
||||
mAMapNavi.destroy();
|
||||
mAMapNavi = null;
|
||||
mNaviChangedCallback = null;
|
||||
ThreadUtils.getSinglePool().execute(() -> {
|
||||
CallerLogger.i( TAG, "destroyAmaNavi()");
|
||||
isPlay = false;
|
||||
sList.clear();
|
||||
eList.clear();
|
||||
mAMapNavi.stopNavi();
|
||||
mAMapNavi.destroy();
|
||||
mAMapNavi = null;
|
||||
mNaviChangedCallback = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,20 +128,22 @@ public class AmapNaviToDestinationModel implements AMapNaviListener {
|
||||
* 说明: 以上参数都是boolean类型,其中multipleroute参数表示是否多条路线,如果为true则此策略会算出多条路线。
|
||||
* 注意: 不走高速与高速优先不能同时为true 高速优先与避免收费不能同时为true
|
||||
*/
|
||||
int strategy = 0;
|
||||
try {
|
||||
//再次强调,最后一个参数为true时代表多路径,否则代表单路径
|
||||
strategy = mAMapNavi.strategyConvert(true, false, false, false, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy);
|
||||
ThreadUtils.getSinglePool().execute(() -> {
|
||||
int strategy = 0;
|
||||
try {
|
||||
//再次强调,最后一个参数为true时代表多路径,否则代表单路径
|
||||
strategy = mAMapNavi.strategyConvert(true, false, false, false, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateRouteSuccess(int[] ints) {
|
||||
//多路径算路成功回调
|
||||
mAMapNavi.startNavi(NaviType.GPS);
|
||||
ThreadUtils.getSinglePool().execute(() -> mAMapNavi.startNavi(NaviType.GPS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user