| File was renamed from amaplib/src/main/java/cn/sinata/amaplib/BaseMapActivity.java |
| | |
| | | package cn.sinata.amaplib; |
| | | package amaplib; |
| | | |
| | | import android.app.Activity; |
| | | import android.os.Bundle; |
| | |
| | | import com.amap.api.navi.AMapNaviListener; |
| | | import com.amap.api.navi.AMapNaviView; |
| | | import com.amap.api.navi.AMapNaviViewListener; |
| | | import com.amap.api.navi.NaviSetting; |
| | | import com.amap.api.navi.model.AMapCalcRouteResult; |
| | | import com.amap.api.navi.model.AMapLaneInfo; |
| | | import com.amap.api.navi.model.AMapModelCross; |
| | | import com.amap.api.navi.model.AMapNaviCameraInfo; |
| | | import com.amap.api.navi.model.AMapNaviCross; |
| | | import com.amap.api.navi.model.AMapNaviInfo; |
| | | import com.amap.api.navi.model.AMapNaviLocation; |
| | | import com.amap.api.navi.model.AMapNaviRouteNotifyData; |
| | | import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo; |
| | |
| | | import com.amap.api.navi.model.AimLessModeStat; |
| | | import com.amap.api.navi.model.NaviInfo; |
| | | import com.amap.api.navi.model.NaviLatLng; |
| | | import com.autonavi.tbt.TrafficFacilityInfo; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import cn.sinata.amaplib.util.TTSController; |
| | | import amaplib.util.TTSController; |
| | | |
| | | |
| | | public class BaseMapActivity extends Activity implements AMapNaviListener, AMapNaviViewListener { |
| | |
| | | protected AMapNaviView mAMapNaviView; |
| | | protected AMapNavi mAMapNavi; |
| | | protected TTSController mTtsManager; |
| | | protected NaviLatLng mEndLatlng = new NaviLatLng(40.084894,116.603039); |
| | | protected NaviLatLng mStartLatlng = new NaviLatLng(39.825934,116.342972); |
| | | protected NaviLatLng mEndLatlng = new NaviLatLng(40.084894, 116.603039); |
| | | protected NaviLatLng mStartLatlng = new NaviLatLng(39.825934, 116.342972); |
| | | protected final List<NaviLatLng> sList = new ArrayList<>(); |
| | | protected final List<NaviLatLng> eList = new ArrayList<>(); |
| | | protected List<NaviLatLng> mWayPointList; |
| | |
| | | mTtsManager.init(); |
| | | |
| | | // |
| | | mAMapNavi = AMapNavi.getInstance(getApplicationContext()); |
| | | mAMapNavi.addAMapNaviListener(this); |
| | | try { |
| | | NaviSetting.updatePrivacyShow(this, true, true); |
| | | NaviSetting.updatePrivacyAgree(this, true); |
| | | mAMapNavi = AMapNavi.getInstance(getApplicationContext()); |
| | | if (mAMapNavi == null) { |
| | | finish(); |
| | | return; |
| | | } |
| | | mAMapNavi.addAMapNaviListener(this); |
| | | // mAMapNavi.addAMapNaviListener(mTtsManager); |
| | | |
| | | LatLng mStart = getIntent().getParcelableExtra("start"); |
| | | LatLng mEnd = getIntent().getParcelableExtra("end"); |
| | | mStartLatlng = new NaviLatLng(mStart.latitude, mStart.longitude); |
| | | mEndLatlng = new NaviLatLng(mEnd.latitude, mEnd.longitude); |
| | | //设置模拟导航的行车速度 |
| | | mAMapNavi.setEmulatorNaviSpeed(75); |
| | | sList.add(mStartLatlng); |
| | | eList.add(mEndLatlng); |
| | | LatLng mStart = getIntent().getParcelableExtra("start"); |
| | | LatLng mEnd = getIntent().getParcelableExtra("end"); |
| | | mStartLatlng = new NaviLatLng(mStart.latitude, mStart.longitude); |
| | | mEndLatlng = new NaviLatLng(mEnd.latitude, mEnd.longitude); |
| | | //设置模拟导航的行车速度 |
| | | mAMapNavi.setEmulatorNaviSpeed(75); |
| | | sList.add(mStartLatlng); |
| | | eList.add(mEndLatlng); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onResume() { |
| | | super.onResume(); |
| | | mAMapNaviView.onResume(); |
| | | if (mAMapNavi != null) { |
| | | mAMapNaviView.onResume(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onPause() { |
| | | super.onPause(); |
| | | mAMapNaviView.onPause(); |
| | | if (mAMapNavi != null) { |
| | | mAMapNaviView.onPause(); |
| | | } |
| | | |
| | | // 仅仅是停止你当前在说的这句话,一会到新的路口还是会再说的 |
| | | mTtsManager.stopSpeaking(); |
| | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | mAMapNaviView.onDestroy(); |
| | | //since 1.6.0 不再在naviview destroy的时候自动执行AMapNavi.stopNavi();请自行执行 |
| | | mAMapNavi.stopNavi(); |
| | | mAMapNavi.destroy(); |
| | | if (mAMapNavi != null) { |
| | | mAMapNaviView.onDestroy(); |
| | | //since 1.6.0 不再在naviview destroy的时候自动执行AMapNavi.stopNavi();请自行执行 |
| | | mAMapNavi.stopNavi(); |
| | | mAMapNavi.destroy(); |
| | | } |
| | | mTtsManager.destroy(); |
| | | } |
| | | |
| | |
| | | //全览按钮点击回调 |
| | | } |
| | | |
| | | @Deprecated |
| | | @Override |
| | | public void onNaviInfoUpdated(AMapNaviInfo naviInfo) { |
| | | //过时 |
| | | } |
| | | |
| | | @Override |
| | | public void updateCameraInfo(AMapNaviCameraInfo[] aMapCameraInfos) { |
| | | |
| | |
| | | @Override |
| | | public void onNaviInfoUpdate(NaviInfo naviinfo) { |
| | | //导航过程中的信息更新,请看NaviInfo的具体说明 |
| | | } |
| | | |
| | | @Override |
| | | public void OnUpdateTrafficFacility(TrafficFacilityInfo trafficFacilityInfo) { |
| | | //已过时 |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onGpsSignalWeak(boolean b) { |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onLockMap(boolean isLock) { |