package com.electric.chargingpile.activity; import android.animation.ValueAnimator; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabaseLockedException; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.provider.MediaStore; import android.support.v7.app.AlertDialog; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewTreeObserver; import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.Switch; import android.widget.TextView; import android.widget.Toast; 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.amap.api.maps.AMap; import com.amap.api.maps.AMapUtils; import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.LocationSource; import com.amap.api.maps.MapView; import com.amap.api.maps.UiSettings; import com.amap.api.maps.model.BitmapDescriptorFactory; import com.amap.api.maps.model.CameraPosition; import com.amap.api.maps.model.LatLng; import com.amap.api.maps.model.LatLngBounds; import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.maps.model.MyLocationStyle; import com.amap.api.navi.AMapNavi; import com.amap.api.navi.AMapNaviListener; 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.AMapNaviPath; import com.amap.api.navi.model.AMapNaviRouteNotifyData; import com.amap.api.navi.model.AMapNaviStep; import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo; import com.amap.api.navi.model.AMapServiceAreaInfo; import com.amap.api.navi.model.AimLessModeCongestionInfo; import com.amap.api.navi.model.AimLessModeStat; import com.amap.api.navi.model.NaviInfo; import com.amap.api.navi.model.NaviLatLng; import com.amap.api.navi.view.RouteOverLay; import com.amap.api.services.core.LatLonPoint; import com.amap.api.services.core.PoiItem; import com.amap.api.services.geocoder.GeocodeResult; import com.amap.api.services.geocoder.GeocodeSearch; import com.amap.api.services.geocoder.RegeocodeQuery; import com.amap.api.services.geocoder.RegeocodeResult; import com.autonavi.tbt.TrafficFacilityInfo; import com.blankj.utilcode.util.EmptyUtils; import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.SizeUtils; import com.electric.chargingpile.R; import com.electric.chargingpile.adapter.RoueteInfoAdapter; import com.electric.chargingpile.application.MainApplication; import com.electric.chargingpile.data.Rectangle; import com.electric.chargingpile.data.RouteHistoryBean; import com.electric.chargingpile.data.RouteInfoData; import com.electric.chargingpile.data.RoutePlanInfo; import com.electric.chargingpile.data.RoutePointInfo; import com.electric.chargingpile.data.Zhan; import com.electric.chargingpile.data.ZhanData; import com.electric.chargingpile.data.zhan_list; import com.electric.chargingpile.gen.DaoMaster; import com.electric.chargingpile.gen.DaoSession; import com.electric.chargingpile.gen.zhan_listDao; import com.electric.chargingpile.manager.ProfileManager; import com.electric.chargingpile.util.BarColorUtil; import com.electric.chargingpile.util.DES3S; import com.electric.chargingpile.util.JsonUtils; import com.electric.chargingpile.util.LoadingDialog; import com.electric.chargingpile.util.ToastUtil; import com.electric.chargingpile.util.Util; import com.electric.chargingpile.view.MyAutoLayout; import com.google.gson.Gson; import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet; import com.umeng.analytics.MobclickAgent; import com.zhy.autolayout.AutoLayout; import com.zhy.http.okhttp.OkHttpUtils; import com.zhy.http.okhttp.callback.StringCallback; import org.json.JSONException; import org.json.JSONObject; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import cn.sharesdk.framework.Platform; import cn.sharesdk.framework.PlatformActionListener; import cn.sharesdk.framework.ShareSDK; import cn.sharesdk.tencent.qq.QQ; import cn.sharesdk.wechat.friends.Wechat; import cn.sharesdk.wechat.moments.WechatMoments; import okhttp3.Call; //import com.electric.chargingpile.util.TTSController; /** * 创建时间:15/12/7 18:11 * 项目名称:newNaviDemo * * @author lingxiang.wang * @email lingxiang.wang@alibaba-inc.com * 类说明: */ public class RoutePlanMapActivity extends Activity implements LocationSource, AMapLocationListener, AMap.OnMapLoadedListener, AMap.OnCameraChangeListener, View.OnClickListener, AMap.OnMarkerClickListener, AMap.OnMapClickListener, GeocodeSearch.OnGeocodeSearchListener, AMapNaviListener, CompoundButton.OnCheckedChangeListener, AMap.InfoWindowAdapter { private static final String TAG = "RoutePlanMapActivity"; NaviLatLng endLatlng; NaviLatLng startLatlng; NaviLatLng zhongLatlng; NaviLatLng zhongLatlng1; private Switch switch_highway; List startList = new ArrayList(); List endList = new ArrayList(); List zhongList = new ArrayList(); private MapView mapView; private AMap amap; private AMapNavi aMapNavi; private List pl; private HashMap routeOverlays = new HashMap(); private int routeIndex; private int[] routeIds; // private TTSController ttsManager; private boolean chooseRouteSuccess; private boolean mapClickStartReady; private boolean mapClickEndReady; private Marker mStartMarker; private Marker mWayMarker; private Marker mEndMarker; private GeocodeSearch geocoderSearch; private boolean calculateSuccess; private String start_name, start_address, start_jing, start_wei, end_name, end_address, end_jing, end_wei; String poi_jing, poi_wei; private float minZoomLevel; private float maxZoomLevel; private UiSettings mUiSettings; TextView tv, tv_infowindow; private AMapLocationClient mlocationClient; private LocationSource.OnLocationChangedListener mListener; private AMapLocationClientOption mLocationOption; LatLng target = null; private Marker mMarkerCity = null; private MarkerOptions oocity = null; LatLng center; private Bitmap bitmap; private TextView tv_zhan_num, tv_route_no1, tv_route_time1, tv_route_distance1, tv_route_no2, tv_route_time2, tv_route_distance2, tv_route_no3, tv_route_time3, tv_route_distance3; private List list = new ArrayList(); private List list_zhong = new ArrayList(); private RoutePlanInfo routePlanInfo; private Zhan zhan; private RelativeLayout rl_route1, rl_route2, rl_route3, rl_submit, rela_paopao, rl_zhong; private View view1, view2; private RouteOverLay routeOverLay; private ImageView iv_back, iv_zhong; private TextView detail_name, tv_fastNum, tv_slowNum, tv_charge, tv_service, tv_park, tv_cost_way, tv_zhong; String p1 = "", p2 = "", p3 = ""; private Marker currentClickedMarker; private Marker detailMarker; private int select; private LoadingDialog dialog; private LinearLayout ll_paoxiang, ll_share_ui; private RelativeLayout ll_comment, tv_notice; private TextView tv_num, tv_daohang, tvOne, tvTwo, tvThree, tv_start, tv_end; private double bd_lon, bd_lat, bd_jing, bd_wei; private PopupWindow popupWindow; private View popupWindowView; private Button cancleButton; private ImageView mIvMarkerBgYes, iv_screen; private ScrollView sv; private View mMarkerViewYes; private TextView tv_iknow, tv_setting, tv_route_name, tv_route_fast, tv_route_slow, tv_route_costway, tv_distance, tv_screenShot; private RelativeLayout rl_yinying, rl_infowindow, rl_details, rl_routebtn, rl_share; private boolean canRoute = false; private boolean canSave = false; String gd_jing, gd_wei; private int k = 0; public static final int REQUSET = 11; private RoueteInfoAdapter roueteInfoAdapter; private float mLastTimeY; public void setEndLatlng(NaviLatLng endLatlng) { this.endLatlng = endLatlng; } private int zhan_num = 0; private String tag = ""; private ImageView iv_setting, iv_screenShot; private String mTime = ""; private List list_zhan = new ArrayList(); ; private List zhanDataList = new ArrayList(); private List routeOne = new ArrayList(); private List routeTwo = new ArrayList(); private List routeThree = new ArrayList(); private int routeNum = 1; private String shareStatus = ""; private String sharePoint = ""; private String sharePlatform = ""; private TextView tv_point, tv_save_route, tv_navigation_route; private RelativeLayout rl_point; private android.view.animation.Animation animation; private String save_start_name = "", save_end_name = ""; private String save_id = ""; private boolean isHighWay = false; private TextView tvOpen, tvRouteTips; private RelativeLayout llOpenView; List routePointInfoList = new ArrayList<>(); private ListView lvRouteInfo; private ImageView ivListStatus; private LinearLayout llOpen, ll; private RelativeLayout rlRouteTip, activity_route_plan; private MyAutoLayout ll_route; private Zhan newZhan; private int noNameCount = 0; private int haveNameCount = 0; private final String CAN_PAY_MARKER = "canPayMarker"; private final String NO_PAY_HAVE_STATUS_MARKER = "noPayHaveStatusMarker"; private final String NO_PAY_NO_STATUS_MARKER = "noPayNoStatusMarker"; private final String ROUTE_POINT_ONE = "routePointOne"; private final String ROUTE_POINT_TWO = "routePointTwo"; private final String ROUTE_POINT_THREE = "routePointThree"; private boolean canRefreshMarker = true; private Marker currentMarker; private List currentMarkersList = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AutoLayout.getInstance().auto(this); setContentView(R.layout.activity_route_plan_map); BarColorUtil.initStatusBarColor(RoutePlanMapActivity.this); dialog = new LoadingDialog(this); dialog.setCanceledOnTouchOutside(false); dialog.show(); mapView = (MapView) findViewById(R.id.mapview); mapView.onCreate(savedInstanceState);// 此方法必须重写 // ttsManager = TTSController.getInstance(getApplicationContext()); // ttsManager.init(); // ttsManager.startSpeaking(); // 初始化Marker添加到地图 initViews(); initMap(); } private void initViews() { ll = findViewById(R.id.ll); // llView = findViewById(R.id.ll_view); activity_route_plan = findViewById(R.id.activity_route_plan); ll_route = findViewById(R.id.ll_route); tvRouteTips = findViewById(R.id.tv_route_tips); rlRouteTip = findViewById(R.id.rl_route_tip); rlRouteTip.setOnClickListener(this); llOpen = findViewById(R.id.ll_open); llOpen.setOnClickListener(this); ivListStatus = findViewById(R.id.iv_list_status); lvRouteInfo = findViewById(R.id.lv_route_info); llOpenView = findViewById(R.id.ll_openView); activity_route_plan.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { llOpenView.setTranslationY(activity_route_plan.getMeasuredHeight() - ll_route.getHeight() - SizeUtils.dp2px(60)); activity_route_plan.getViewTreeObserver().removeOnPreDrawListener(this); return true; } }); tvOpen = findViewById(R.id.tv_open); sv = (ScrollView) findViewById(R.id.sv); iv_screenShot = (ImageView) findViewById(R.id.iv_screenShot); iv_screenShot.setOnClickListener(this); iv_setting = (ImageView) findViewById(R.id.iv_setting); iv_setting.setOnClickListener(this); tv_start = (TextView) findViewById(R.id.tv_start); tv_end = (TextView) findViewById(R.id.tv_end); rl_infowindow = (RelativeLayout) findViewById(R.id.rl_infowindow); tv_route_name = (TextView) findViewById(R.id.tv_route_name); tv_route_fast = (TextView) findViewById(R.id.tv_window_fast); tv_route_slow = (TextView) findViewById(R.id.tv_window_slow); tv_route_costway = (TextView) findViewById(R.id.tv_window_costway); rl_routebtn = (RelativeLayout) findViewById(R.id.rl_routebtn); tv_distance = (TextView) findViewById(R.id.tv_distance); rl_share = (RelativeLayout) findViewById(R.id.rl_share); rl_point = (RelativeLayout) findViewById(R.id.rl_point); tv_point = (TextView) findViewById(R.id.tv_point); animation = AnimationUtils.loadAnimation(RoutePlanMapActivity.this, R.anim.nn); rl_details = (RelativeLayout) findViewById(R.id.rl_details); iv_screen = (ImageView) findViewById(R.id.iv_screen); rl_yinying = (RelativeLayout) findViewById(R.id.rl_yinying); tv_iknow = (TextView) findViewById(R.id.tv_iknow); tv_iknow.setOnClickListener(this); tv_notice = (RelativeLayout) findViewById(R.id.tv_notice); tv_notice.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv_notice.setVisibility(View.GONE); } }); switch_highway = findViewById(R.id.switch_highway); switch_highway.setOnCheckedChangeListener(this); tv_zhan_num = (TextView) findViewById(R.id.tv_zhan_num); // tv_screenShot = (TextView) findViewById(R.id.tv_screenShot); // tv_screenShot.setOnClickListener(this); mMarkerViewYes = LayoutInflater.from(this).inflate(R.layout.view_custom_yes, null); mMarkerViewYes.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); mIvMarkerBgYes = (ImageView) mMarkerViewYes.findViewById(R.id.iv_icon); rela_paopao = (RelativeLayout) findViewById(R.id.rela_paopao); detail_name = (TextView) findViewById(R.id.detail_name); tv_fastNum = (TextView) findViewById(R.id.tv_fastNum); tv_slowNum = (TextView) findViewById(R.id.tv_slowNum); tv_charge = (TextView) findViewById(R.id.tv_charge); tv_service = (TextView) findViewById(R.id.tv_service); tv_park = (TextView) findViewById(R.id.tv_park); tv_cost_way = (TextView) findViewById(R.id.tv_cost_way); rl_zhong = (RelativeLayout) findViewById(R.id.rl_zhong); tv_zhong = (TextView) findViewById(R.id.tv_zhong); iv_zhong = (ImageView) findViewById(R.id.iv_zhong); ll_share_ui = (LinearLayout) findViewById(R.id.ll_share_ui); iv_back = (ImageView) findViewById(R.id.iv_back); iv_back.setOnClickListener(this); tv_route_no1 = (TextView) findViewById(R.id.tv_route_no1); tv_route_time1 = (TextView) findViewById(R.id.tv_route_time1); tv_route_distance1 = (TextView) findViewById(R.id.tv_route_distance1); tv_route_no2 = (TextView) findViewById(R.id.tv_route_no2); tv_route_time2 = (TextView) findViewById(R.id.tv_route_time2); tv_route_distance2 = (TextView) findViewById(R.id.tv_route_distance2); tv_route_no3 = (TextView) findViewById(R.id.tv_route_no3); tv_route_time3 = (TextView) findViewById(R.id.tv_route_time3); tv_route_distance3 = (TextView) findViewById(R.id.tv_route_distance3); rl_route1 = (RelativeLayout) findViewById(R.id.rl_route1); rl_route1.setOnClickListener(this); rl_route2 = (RelativeLayout) findViewById(R.id.rl_route2); rl_route2.setOnClickListener(this); rl_route3 = (RelativeLayout) findViewById(R.id.rl_route3); rl_route3.setOnClickListener(this); view1 = findViewById(R.id.view_1); view2 = findViewById(R.id.view_2); ll_paoxiang = (LinearLayout) findViewById(R.id.ll_paoxiang); ll_comment = (RelativeLayout) findViewById(R.id.ll_comment); tv_num = (TextView) findViewById(R.id.tv_num); tv_daohang = (TextView) findViewById(R.id.tv_daohang); tv_navigation_route = (TextView) findViewById(R.id.tv_navigation_route); tv_navigation_route.setOnClickListener(this); tv_save_route = (TextView) findViewById(R.id.tv_save_route); tv_save_route.setOnClickListener(this); if (ProfileManager.getInstance().getRoutetips(getApplicationContext()) == true) { rl_yinying.setVisibility(View.VISIBLE); ProfileManager.getInstance().setRoutetips(getApplicationContext(), false); } ll_route.setOnTouchEvent_(new MyAutoLayout.OnTouchEventListener_() { @Override public boolean onTouchEvent_(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mLastTimeY = event.getY(); return false; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: float diffY = event.getY() - mLastTimeY; boolean consume = Math.abs(diffY) > 20; if (consume && canRoute) { if (diffY < 0 && lvRouteInfo.getVisibility() == View.GONE) { showListData(routeOverlays, routeNum); ivListStatus.setImageResource(R.drawable.icon_route_list_open); tvOpen.setText("显示地图"); // Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_route); // animation1.setDuration(2000); lvRouteInfo.setVisibility(View.VISIBLE); AnimatorStart(); } else { ivListStatus.setImageResource(R.drawable.icon_route_list_close); tvOpen.setText("路线详情"); new Handler().postDelayed(new Runnable() { @Override public void run() { lvRouteInfo.setVisibility(View.GONE); } }, 300); AnimatorEnd(); } } else if (consume && !canRoute) { rl_yinying.setVisibility(View.VISIBLE); } return consume; } return false; } }); } private void initMap() { if (amap == null) { amap = mapView.getMap(); aMapNavi = AMapNavi.getInstance(getApplicationContext()); aMapNavi.addAMapNaviListener(this); aMapNavi.setUseInnerVoice(true); MyLocationStyle myLocationStyle = new MyLocationStyle(); myLocationStyle.myLocationIcon(com.amap.api.maps.model.BitmapDescriptorFactory .fromResource(R.drawable.point_icon));// 设置小蓝点的图标 amap.setMyLocationStyle(myLocationStyle); mUiSettings = amap.getUiSettings(); //获得地图的最大和最小缩放级别 maxZoomLevel = amap.getMaxZoomLevel(); minZoomLevel = amap.getMinZoomLevel(); geocoderSearch = new GeocodeSearch(this); geocoderSearch.setOnGeocodeSearchListener(this); setUpMap(); } } private void setUpMap() { amap.setOnMarkerClickListener(this);// 设置点击marker事件监听器 amap.setOnMapClickListener(this); amap.setOnCameraChangeListener(this); amap.setLocationSource(this);// 设置定位监听 amap.setOnMapLoadedListener(this); amap.setInfoWindowAdapter(this); amap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示 amap.getUiSettings().setZoomControlsEnabled(false);// 设置默认缩放按钮是否显示 amap.getUiSettings().setScaleControlsEnabled(true);// 设置比例尺是否显示 amap.getUiSettings().setRotateGesturesEnabled(false);// 设置地图是否旋转 } private void initDatas() { start_name = getIntent().getStringExtra("start_name"); start_address = getIntent().getStringExtra("start_address"); if (start_name.equals("我的位置")) { tag = "start"; start_jing = String.valueOf(center.longitude); start_wei = String.valueOf(center.latitude); getAddress(new LatLonPoint(center.latitude, center.longitude)); } else { start_jing = getIntent().getStringExtra("start_jing"); start_wei = getIntent().getStringExtra("start_wei"); tv_start.setText(start_name); save_start_name = start_name; } end_name = getIntent().getStringExtra("end_name"); end_address = getIntent().getStringExtra("end_address"); if (end_name.equals("我的位置")) { tag = "end"; end_jing = String.valueOf(center.longitude); end_wei = String.valueOf(center.latitude); getAddress(new LatLonPoint(center.latitude, center.longitude)); } else { end_jing = getIntent().getStringExtra("end_jing"); end_wei = getIntent().getStringExtra("end_wei"); tv_end.setText(end_name); save_end_name = end_name; } save_id = getIntent().getStringExtra("save_id"); Log.e(TAG, "initDatas: save_id=" + save_id); endLatlng = new NaviLatLng(Double.parseDouble(end_wei), Double.parseDouble(end_jing)); startLatlng = new NaviLatLng(Double.parseDouble(start_wei), Double.parseDouble(start_jing)); endList.clear(); startList.clear(); zhongList.clear(); startList.add(startLatlng); endList.add(endLatlng); int strategyFlag = 0; try { strategyFlag = aMapNavi.strategyConvert(ProfileManager.getInstance().getDbyd(getApplicationContext()), ProfileManager.getInstance().getBzgs(getApplicationContext()), ProfileManager.getInstance().getBmsf(getApplicationContext()), ProfileManager.getInstance().getGsyx(getApplicationContext()), true); } catch (Exception e) { e.printStackTrace(); } if (!"0".equals(save_id)) { ArrayList listObj = (ArrayList) getIntent().getSerializableExtra("waypoint"); for (int i = 0; i < listObj.size(); i++) { zhongLatlng = new NaviLatLng(Double.parseDouble(listObj.get(i).getLat()), Double.parseDouble(listObj.get(i).getLon())); zhongList.add(zhongLatlng); if (EmptyUtils.isEmpty(listObj.get(i).getZhanName())) { noNameCount++; Zhan newZhan = new Zhan(); newZhan.setZhan_id(listObj.get(i).getZhanId()); newZhan.setPoi_jing(listObj.get(i).getLon()); newZhan.setPoi_wei(listObj.get(i).getLat()); if (i == 0) { getZhanInfoOne(listObj.get(i).getZhanId()); } else if (i == 1) { getZhanInfoTwo(listObj.get(i).getZhanId()); } else { getZhanInfoThree(listObj.get(i).getZhanId()); } list_zhong.add(newZhan); } else { Zhan newZhan = new Zhan(); newZhan.setZhan_id(listObj.get(i).getZhanId()); newZhan.setPoi_jing(listObj.get(i).getLon()); newZhan.setPoi_wei(listObj.get(i).getLat()); newZhan.setZhan_name(listObj.get(i).getZhanName()); list_zhong.add(newZhan); } } if (list_zhong.size() > 0) { // tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_green); // tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_green); canRoute = true; canSave = true; } String s = ""; if (list_zhong.size() == 1) { for (int j = 0; j < list_zhong.size(); j++) { s += list_zhong.get(j).getZhan_id() + ":"; } String[] my = s.split(":"); p1 = my[0]; } else if (list_zhong.size() == 2) { for (int j = 0; j < list_zhong.size(); j++) { s += list_zhong.get(j).getZhan_id() + ":"; } String[] my = s.split(":"); p1 = my[0]; p2 = my[1]; } else if (list_zhong.size() == 3) { for (int j = 0; j < list_zhong.size(); j++) { s += list_zhong.get(j).getZhan_id() + ":"; } String[] my = s.split(":"); p1 = my[0]; p2 = my[1]; p3 = my[2]; } if (strategyFlag >= 0) { aMapNavi.calculateDriveRoute(startList, endList, zhongList, strategyFlag); } } else { if (strategyFlag >= 0) { aMapNavi.calculateDriveRoute(startList, endList, null, strategyFlag); } } dialog.show(); } private void getZhanInfoOne(final String zhanId) { String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/zhan-info?" + "zhan_id=" + zhanId + "&version=" + MainApplication.current_code; OkHttpUtils.get().url(url).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { String info = JsonUtils.getKeyResult(response, "info"); String info_decode = null; try { info_decode = DES3S.decode(info); } catch (Exception e) { e.printStackTrace(); } String zhanName = JsonUtils.getKeyResult(info_decode, "zhan_name"); list_zhong.get(0).setZhan_name(zhanName); LogUtils.e("请求回数据的zhanNme:" + zhanName); haveNameCount++; } }); } private void getZhanInfoTwo(final String zhanId) { String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/zhan-info?" + "zhan_id=" + zhanId + "&version=" + MainApplication.current_code; OkHttpUtils.get().url(url).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { String info = JsonUtils.getKeyResult(response, "info"); String info_decode = null; try { info_decode = DES3S.decode(info); } catch (Exception e) { e.printStackTrace(); } String zhanName = JsonUtils.getKeyResult(info_decode, "zhan_name"); list_zhong.get(1).setZhan_name(zhanName); LogUtils.e("请求回数据的zhanNme:" + zhanName); haveNameCount++; } }); } private void getZhanInfoThree(final String zhanId) { String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/zhan-info?" + "zhan_id=" + zhanId + "&version=" + MainApplication.current_code; OkHttpUtils.get().url(url).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { String info = JsonUtils.getKeyResult(response, "info"); String info_decode = null; try { info_decode = DES3S.decode(info); } catch (Exception e) { e.printStackTrace(); } String zhanName = JsonUtils.getKeyResult(info_decode, "zhan_name"); list_zhong.get(2).setZhan_name(zhanName); LogUtils.e("请求回数据的zhanNme:" + zhanName); haveNameCount++; } }); } /** * 方法必须重写 */ @Override protected void onResume() { super.onResume(); mapView.onResume(); Log.e(TAG, "onResume: " + shareStatus + "--" + sharePoint + "--" + sharePlatform); if (shareStatus.equals("yes") && !sharePoint.equals("") && sharePlatform.equals("qq")) { Log.e(TAG, "onResume: 00000000000000000"); tv_point.setText(sharePoint); rl_point.setVisibility(View.VISIBLE); rl_point.startAnimation(animation); new Handler().postDelayed(new Runnable() { public void run() { rl_point.setVisibility(View.GONE); } }, 1000); shareStatus = ""; sharePoint = ""; sharePlatform = ""; } if (ProfileManager.getInstance().getDbyd(this) == false && ProfileManager.getInstance().getBmsf(this) == false && ProfileManager.getInstance().getGsyx(this) == false && ProfileManager.getInstance().getBzgs(this) == false) { iv_setting.setImageResource(R.drawable.icon_setting_route); } else { iv_setting.setImageResource(R.drawable.icon_setting_select_route); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) { return; } switch (requestCode) { // 如果是直接从相册获取 case REQUSET: amap.clear(); int strategyFlag = 0; try { strategyFlag = aMapNavi.strategyConvert(ProfileManager.getInstance().getDbyd(getApplicationContext()), ProfileManager.getInstance().getBzgs(getApplicationContext()), ProfileManager.getInstance().getBmsf(getApplicationContext()), ProfileManager.getInstance().getGsyx(getApplicationContext()), true); } catch (Exception e) { e.printStackTrace(); } if (strategyFlag >= 0) { if (list_zhong.size() > 0) { aMapNavi.calculateDriveRoute(startList, endList, zhongList, strategyFlag); } else { aMapNavi.calculateDriveRoute(startList, endList, null, strategyFlag); } } break; default: break; } } /** * 方法必须重写 */ @Override protected void onPause() { super.onPause(); mapView.onPause(); } /** * 方法必须重写 */ @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); } /** * 方法必须重写 */ @Override protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); aMapNavi.stopNavi(); // ttsManager.destroy(); aMapNavi.destroy(); } public void calculateRoute(View view) { endLatlng = new NaviLatLng(); startLatlng = new NaviLatLng(); startList.add(startLatlng); endList.add(endLatlng); int strategyFlag = 0; try { strategyFlag = aMapNavi.strategyConvert(ProfileManager.getInstance().getDbyd(getApplicationContext()), ProfileManager.getInstance().getBzgs(getApplicationContext()), ProfileManager.getInstance().getBmsf(getApplicationContext()), ProfileManager.getInstance().getGsyx(getApplicationContext()), true); } catch (Exception e) { e.printStackTrace(); } if (strategyFlag >= 0) { aMapNavi.calculateDriveRoute(startList, endList, null, strategyFlag); dialog.show(); // ToastUtil.showToast(getApplicationContext(),"111",Toast.LENGTH_SHORT); } } @Override public void onCalculateRouteSuccess(int[] routeIds) { LogUtils.e(routeIds.length); //当且仅当,使用策略AMapNavi.DrivingMultipleRoutes时回调 //单路径算路依然回调onCalculateRouteSuccess,不回调这个 //你会获取路径ID数组 select = 0; this.routeIds = routeIds; list.clear(); routeNum = 1; Log.e("routeIds", routeIds.length + ""); for (int i = 0; i < routeIds.length; i++) { routePlanInfo = new RoutePlanInfo(); //你可以通过对应的路径ID获得一条道路路径AMapNaviPath AMapNaviPath path = null; // path = (aMapNavi.getNaviPaths()).get(routeIds[i]); // LogUtils.e(Arrays.toString(path.wayPointIndex)); // LogUtils.e(path.getStepsCount()); // LogUtils.e(Arrays.toString(path.getWayPointIndex())); // path.getSteps().get(1).getIconType(); //你可以通过这个AMapNaviPath生成一个RouteOverLay用于加在地图上 RouteOverLay routeOverLay = new RouteOverLay(amap, path, this); routeOverLay.setStartPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstarr))); routeOverLay.setEndPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstopr))); routeOverLay.setWayPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_zhanwei))); routeOverLay.addToMap(); routeOverLay.setTrafficLine(true); routeOverlays.put(routeIds[i], routeOverLay); routeOverLay.getAMapNaviPath().getSteps(); routePlanInfo.setNo(routeOverlays.get(routeIds[i]).getAMapNaviPath().getStrategy() + ""); routePlanInfo.setTime(routeOverlays.get(routeIds[i]).getAMapNaviPath().getAllTime() + ""); routePlanInfo.setDistance(routeOverlays.get(routeIds[i]).getAMapNaviPath().getAllLength() + ""); list.add(routePlanInfo); // routeOverlays.get(routeIds[i]).getAMapNaviPath().getSteps().get(i).getLength(); // routeOverlays.get(routeIds[i]).getAMapNaviPath().getSteps().get(i).getIconType(); } Log.e("list_size===", list.size() + ""); updateView(list); routeOverlays.get(routeIds[0]).zoomToSpan(); aMapNavi.selectRouteId(routeIds[0]); // LogUtils.e(routePointInfo.toString()); // // LogUtils.e(routePointInfoList.size()); routeIndex = 0; calculateSuccess = true; //突出选择的那条路 for (RouteOverLay routeOverLay : routeOverlays.values()) { routeOverLay.setTransparency(0.3f); } routeOverlays.get(routeIds[routeIndex]).setTransparency(0.8f); final List nl = (aMapNavi.getNaviPaths()).get(routeIds[0]).getCoordList(); new Handler().postDelayed(new Runnable() { @Override public void run() { if (nl != null) { getZhanPoint(nl); } } }, 500); showListData(routeOverlays, routeNum); } private void showListData(HashMap routeOverlays, int no) { List list = routeOverlays.get(routeIds[no - 1]).getAMapNaviPath().getSteps(); int routeLength = 0; int routeTime = 0; if (EmptyUtils.isNotEmpty(routePointInfoList)) { routePointInfoList.clear(); } int maxLength = 0; for (int j = 0; j < list.size(); j++) { routeLength += list.get(j).getLength(); routeTime += list.get(j).getTime(); if (list.get(j).getIconType() == 10) { LogUtils.e("!!!!!10!!!!!!" + routeLength + "----" + maxLength); if (routeLength > maxLength) { maxLength = routeLength; } RoutePointInfo routePointInfo = new RoutePointInfo(); routePointInfo.setRouteLength(getMToKm(String.valueOf(routeLength))); routePointInfo.setRouteTime(getSToHm(String.valueOf(routeTime))); routePointInfoList.add(routePointInfo); // LogUtils.e(routePointInfo.toString()); routeLength = 0; routeTime = 0; } } if (routeLength > maxLength) { maxLength = routeLength; } RoutePointInfo routePointInfo = new RoutePointInfo(); routePointInfo.setRouteLength(getMToKm(String.valueOf(routeLength))); routePointInfo.setRouteTime(getSToHm(String.valueOf(routeTime))); routePointInfoList.add(routePointInfo); if (list_zhong.size() > 0) { tvRouteTips.setText("最长单段里程" + getMToKm(String.valueOf(maxLength)) + ",点击查看详情"); rlRouteTip.setVisibility(View.VISIBLE); LogUtils.e("list_zhong=" + list_zhong.size()); ArrayList info = new ArrayList<>(); if (list_zhong.size() == 1) { info.add(new RouteInfoData("起点-" + save_start_name, "start", routePointInfoList.get(0).getRouteLength() + "," + routePointInfoList.get(0).getRouteTime())); info.add(new RouteInfoData(list_zhong.get(0).getZhan_name(), "name", routePointInfoList.get(1).getRouteLength() + "," + routePointInfoList.get(1).getRouteTime())); info.add(new RouteInfoData("终点-" + save_end_name, "end", "")); } else if (list_zhong.size() == 2) { info.add(new RouteInfoData("起点-" + save_start_name, "start", routePointInfoList.get(0).getRouteLength() + "," + routePointInfoList.get(0).getRouteTime())); info.add(new RouteInfoData(list_zhong.get(0).getZhan_name(), "name", routePointInfoList.get(1).getRouteLength() + "," + routePointInfoList.get(1).getRouteTime())); info.add(new RouteInfoData(list_zhong.get(1).getZhan_name(), "name", routePointInfoList.get(2).getRouteLength() + "," + routePointInfoList.get(2).getRouteTime())); info.add(new RouteInfoData("终点-" + save_end_name, "end", "")); } else if (list_zhong.size() == 3) { info.add(new RouteInfoData("起点-" + save_start_name, "start", routePointInfoList.get(0).getRouteLength() + "," + routePointInfoList.get(0).getRouteTime())); info.add(new RouteInfoData(list_zhong.get(0).getZhan_name(), "name", routePointInfoList.get(1).getRouteLength() + "," + routePointInfoList.get(1).getRouteTime())); info.add(new RouteInfoData(list_zhong.get(1).getZhan_name(), "name", routePointInfoList.get(2).getRouteLength() + "," + routePointInfoList.get(2).getRouteTime())); info.add(new RouteInfoData(list_zhong.get(2).getZhan_name(), "name", routePointInfoList.get(3).getRouteLength() + "," + routePointInfoList.get(3).getRouteTime())); info.add(new RouteInfoData("终点-" + save_end_name, "end", "")); } if (roueteInfoAdapter == null) { roueteInfoAdapter = new RoueteInfoAdapter(info, RoutePlanMapActivity.this); } else { roueteInfoAdapter.changeData(info); } lvRouteInfo.setAdapter(roueteInfoAdapter); } else { rlRouteTip.setVisibility(View.GONE); } } private void updateView(List l) { int i = l.size(); if (i == 1) { if (l.get(0).getNo().equals("0")) { tv_route_no1.setText("推荐"); } else if (l.get(0).getNo().equals("2")) { tv_route_no1.setText("距离最短"); } else if (l.get(0).getNo().equals("4")) { tv_route_no1.setText("时间最短"); } else { tv_route_no1.setText("其他方案"); } tv_route_distance1.setText(getMToKm(l.get(0).getDistance())); tv_route_time1.setText(getSToHm(l.get(0).getTime())); rl_route2.setVisibility(View.GONE); rl_route3.setVisibility(View.GONE); view1.setVisibility(View.GONE); view2.setVisibility(View.GONE); } else if (i == 2) { if (l.get(0).getNo().equals("0")) { tv_route_no1.setText("推荐"); } else if (l.get(0).getNo().equals("2")) { tv_route_no1.setText("距离最短"); } else if (l.get(0).getNo().equals("4")) { tv_route_no1.setText("时间最短"); } else { tv_route_no1.setText("其他方案"); } tv_route_distance1.setText(getMToKm(l.get(0).getDistance())); tv_route_time1.setText(getSToHm(l.get(0).getTime())); if (l.get(1).getNo().equals("0")) { tv_route_no2.setText("推荐"); } else if (l.get(1).getNo().equals("2")) { tv_route_no2.setText("距离最短"); } else if (l.get(1).getNo().equals("4")) { tv_route_no2.setText("时间最短"); } else { tv_route_no2.setText("其他方案"); } tv_route_distance2.setText(getMToKm(l.get(1).getDistance())); tv_route_time2.setText(getSToHm(l.get(1).getTime())); rl_route3.setVisibility(View.GONE); view2.setVisibility(View.GONE); rl_route2.setVisibility(View.VISIBLE); view1.setVisibility(View.VISIBLE); } else if (i == 3) { rl_route3.setVisibility(View.VISIBLE); view2.setVisibility(View.VISIBLE); rl_route2.setVisibility(View.VISIBLE); view1.setVisibility(View.VISIBLE); if (l.get(0).getNo().equals("0")) { tv_route_no1.setText("推荐"); } else if (l.get(0).getNo().equals("2")) { tv_route_no1.setText("距离最短"); } else if (l.get(0).getNo().equals("4")) { tv_route_no1.setText("时间最短"); } else { tv_route_no1.setText("其他方案"); } tv_route_distance1.setText(getMToKm(l.get(0).getDistance())); tv_route_time1.setText(getSToHm(l.get(0).getTime())); if (l.get(1).getNo().equals("0")) { tv_route_no2.setText("推荐"); } else if (l.get(1).getNo().equals("2")) { tv_route_no2.setText("距离最短"); } else if (l.get(1).getNo().equals("4")) { tv_route_no2.setText("时间最短"); } else { tv_route_no2.setText("其他方案"); } tv_route_distance2.setText(getMToKm(l.get(1).getDistance())); tv_route_time2.setText(getSToHm(l.get(1).getTime())); if (l.get(2).getNo().equals("0")) { tv_route_no3.setText("推荐"); } else if (l.get(2).getNo().equals("2")) { tv_route_no3.setText("距离最短"); } else if (l.get(2).getNo().equals("4")) { tv_route_no3.setText("时间最短"); } else { tv_route_no3.setText("其他方案"); } tv_route_distance3.setText(getMToKm(l.get(2).getDistance())); tv_route_time3.setText(getSToHm(l.get(2).getTime())); } } private String getSToHm(String time) { int t = Integer.parseInt(time); String s = ""; if (t >= 3600) { int h = t / 3600; int m = (t % 3600) / 60; s = h + "小时" + m + "分"; } else { int m = (t % 3600) / 60; s = m + "分钟"; } return s; } private String getMToKm(String time) { int t = Integer.parseInt(time); Integer a = t, b = 1000; float result = (float) a / b; String s = String.valueOf(Math.round(result * 10) / 10.0) + "公里"; return s; } private Bitmap drawableToBitamp(Drawable drawable) { BitmapDrawable bd = (BitmapDrawable) drawable; bitmap = bd.getBitmap(); return bitmap; } @Override public void notifyParallelRoad(int i) { } @Override public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos) { } @Override public void updateAimlessModeStatistics(AimLessModeStat aimLessModeStat) { } @Override public void updateAimlessModeCongestionInfo(AimLessModeCongestionInfo aimLessModeCongestionInfo) { } @Override public void onPlayRing(int i) { } @Override public void onCalculateRouteSuccess(AMapCalcRouteResult aMapCalcRouteResult) { } @Override public void onCalculateRouteFailure(AMapCalcRouteResult aMapCalcRouteResult) { } @Override public void onNaviRouteNotify(AMapNaviRouteNotifyData aMapNaviRouteNotifyData) { } public void changeRoute(View view) { if (mMarkerCity != null) { mMarkerCity.remove(); } if (!calculateSuccess) { Toast.makeText(this, "请先算路", Toast.LENGTH_SHORT).show(); return; } if (routeIndex >= routeIds.length) routeIndex = 0; //突出选择的那条路 for (RouteOverLay routeOverLay : routeOverlays.values()) { routeOverLay.setTransparency(0.3f); } routeOverlays.get(routeIds[routeIndex]).setTransparency(0.8f); //必须告诉AMapNavi 你最后选择的哪条路 aMapNavi.selectRouteId(routeIds[routeIndex]); // Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[routeIndex]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[routeIndex]).getAllTime() + "s", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[routeIndex]).getStrategy() + "z", Toast.LENGTH_SHORT).show(); List nl = (aMapNavi.getNaviPaths()).get(routeIds[routeIndex]).getCoordList(); // Toast.makeText(this, nl.size() + "", Toast.LENGTH_SHORT).show(); routeIndex++; chooseRouteSuccess = true; // getRouteZhan(nl); } private void getRouteZhan(List nl) { Log.e("getRouteZhan_size", nl.size() + ""); double minLon; double maxLon; double minLat; double maxLat; double alon; double alat; double blon; double blat; float Lonoff = 0.012f; float Latoff = 0.010f; int count = 0; String RangConditionStr = ""; int a = nl.size() / 500 + 1; Log.e("getRouteZhan_a", a + ""); for (int i = 0; i < nl.size() - a; i = i + a) { NaviLatLng aPoint = nl.get(i); NaviLatLng bPoint = nl.get(i + a); alon = aPoint.getLongitude(); alat = aPoint.getLatitude(); blon = bPoint.getLongitude(); blat = bPoint.getLatitude(); if (alon < blon) { minLon = alon - Lonoff; maxLon = blon + Lonoff; } else { minLon = blon - Lonoff; maxLon = alon + Lonoff; } if (alat < blat) { minLat = alat - Latoff; maxLat = blat + Latoff; } else { minLat = blat - Latoff; maxLat = alat + Latoff; } String rangStr = " poi_wei > " + minLat + " AND poi_jing > " + minLon + " AND poi_wei < " + maxLat + " AND poi_jing < " + maxLon; RangConditionStr = RangConditionStr + rangStr + " OR "; count++; if (count > 100) { String conditionSql = " ( status = '4' and suit_car != '特斯拉' ) "; RangConditionStr = RangConditionStr.substring(0, RangConditionStr.lastIndexOf('O')); final String sql = "SELECT id,status,poi_jing,poi_wei,total_num,fast_num,slow_num,belong_attribute,suit_car,charge_cost_way,city,own_pay FROM zhan_list WHERE " + conditionSql + " AND " + RangConditionStr; // new Thread(new Runnable() { // @Override // public void run() { getZhanListData(sql); // } // }).start(); count = 0; RangConditionStr = ""; } } if (RangConditionStr.length() > 10) { String conditionSql = " ( status = '4' and suit_car != '特斯拉' ) "; RangConditionStr = RangConditionStr.substring(0, RangConditionStr.lastIndexOf('O')); final String sql = "SELECT id,status,poi_jing,poi_wei,total_num,fast_num,slow_num,belong_attribute,suit_car,charge_cost_way,city,own_pay FROM zhan_list WHERE " + conditionSql + " AND " + RangConditionStr; Log.e("sql===", sql); new Thread(new Runnable() { @Override public void run() { getZhanListData(sql); } }).start(); } // initOver(list_zhan); } private void getZhanData() { DaoMaster daoMaster = new DaoMaster(SQLiteDatabase.openOrCreateDatabase(getDatabasePath("zhan_list"), null)); LogUtils.e("当前数据库版本:" + daoMaster.getSchemaVersion()); DaoSession daoSession = daoMaster.newSession(); zhan_listDao zhan_listDao = daoSession.getZhan_listDao(); try { if (isHighWay == true) { zhanDataList = zhan_listDao.queryRaw("where status = ? and suit_car != '特斯拉' and zhuang_num = '2'", new String[]{"4"}); } else { zhanDataList = zhan_listDao.queryRaw("where status = ? and suit_car != '特斯拉'", new String[]{"4"}); } } catch (SQLiteDatabaseLockedException e) { e.printStackTrace(); } finally { daoSession.clear(); zhan_listDao.detachAll(); } if (list_zhong.size() > 0) { String point_sql = "where"; List point_list = new ArrayList<>(); for (int i = 0; i < list_zhong.size(); i++) { point_sql += " id = '" + list_zhong.get(i).getZhan_id() + "' or"; } point_sql = point_sql.substring(0, point_sql.length() - 2); point_list = zhan_listDao.queryRaw(point_sql); com.blankj.utilcode.util.LogUtils.e(point_sql); com.blankj.utilcode.util.LogUtils.e(point_list.size()); for (int j = 0; j < point_list.size(); j++) { if (!zhanDataList.contains(point_list.get(j))) { zhanDataList.add(point_list.get(j)); } } } Log.e(TAG, "getZhanData: " + zhanDataList.size()); } private void getZhanPoint(List nl) { if (zhanDataList.size() == 0) { Log.e("~~~~", "z!!!!"); getZhanData(); } List rectList = new ArrayList(); rectList.clear(); List newList = new ArrayList<>(); newList.clear(); double minLon, maxLon, minLat, maxLat; double alon, alat, blon, blat; float Lonoff = 0.012f; float Latoff = 0.010f; int count = 0; int a = nl.size() / 1000 + 1; if (a < 20) { a = 20; } for (int i = 0; i < nl.size() - a; i = i + a) { NaviLatLng aPoint = nl.get(i); NaviLatLng bPoint = nl.get(i + a); alon = aPoint.getLongitude(); alat = aPoint.getLatitude(); blon = bPoint.getLongitude(); blat = bPoint.getLatitude(); if (alon < blon) { minLon = alon - Lonoff; maxLon = blon + Lonoff; } else { minLon = blon - Lonoff; maxLon = alon + Lonoff; } if (alat < blat) { minLat = alat - Latoff; maxLat = blat + Latoff; } else { minLat = blat - Latoff; maxLat = alat + Latoff; } rectList.add(new Rectangle(maxLat, maxLon, minLat, minLon)); } Log.e(TAG, "getZhanPoint: rectList_size=" + rectList.size()); for (int i = 0; i < zhanDataList.size(); i++) { if ("".equals(zhanDataList.get(i).getPoi_jing()) || "".equals(zhanDataList.get(i).getPoi_wei())) { continue; } Double zhan_jing = Double.parseDouble(zhanDataList.get(i).getPoi_jing()); // Log.e(TAG, "getZhanPoint: zhan_jing="+zhan_jing ); Double zhan_wei = Double.parseDouble(zhanDataList.get(i).getPoi_wei()); // Log.e(TAG, "getZhanPoint: zhan_wei="+zhan_wei ); for (int j = 0; j < rectList.size(); j++) { Double mMinLat = rectList.get(j).getMinLat(); // Log.e(TAG, "getZhanPoint: mMinLat="+mMinLat ); Double mMinLon = rectList.get(j).getMinLon(); Double mMaxLat = rectList.get(j).getMaxLat(); Double mMaxLon = rectList.get(j).getMaxLon(); if (zhan_jing < mMaxLon && zhan_jing > mMinLon && zhan_wei < mMaxLat && zhan_wei > mMinLat) { newList.add(zhanDataList.get(i)); break; } } } Log.e(TAG, "getZhanPoint: newList_size=" + newList.size()); Log.e(TAG, "getZhanPoint: routeNum=" + routeNum); if (routeNum == 1) { for (int i = 0; i < newList.size(); i++) { routeOne.add(newList.get(i)); } Log.e(TAG, "getZhanPoint: routeOne=" + routeOne.size()); } else if (routeNum == 2) { for (int i = 0; i < newList.size(); i++) { routeTwo.add(newList.get(i)); } } else if (routeNum == 3) { for (int i = 0; i < newList.size(); i++) { routeThree.add(newList.get(i)); } } initOver(newList); } private void getZhanListData(String sql) { k++; Log.e("k==", k + ""); String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list"; try { SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE); // Log.e("sql===",sql); Cursor cursor = db.rawQuery(sql, null); Zhan zhan; while (cursor.moveToNext()) { zhan = new Zhan(); zhan.setPoi_jing(cursor.getString(cursor.getColumnIndex("poi_jing"))); // Log.e(k+"==",cursor.getString(cursor.getColumnIndex("poi_jing"))); zhan.setPoi_wei(cursor.getString(cursor.getColumnIndex("poi_wei"))); // Log.e(k+"==",cursor.getString(cursor.getColumnIndex("poi_wei"))); zhan.setZhan_id(cursor.getString(cursor.getColumnIndex("id"))); zhan.setStatus(cursor.getString(cursor.getColumnIndex("status"))); zhan.setSuit_car(cursor.getString(cursor.getColumnIndex("suit_car"))); zhan.setOwn_pay(cursor.getString(cursor.getColumnIndex("own_pay"))); list_zhan.add(zhan); } // Log.e("size===",list_db.size()+""); // Log.e("list===", list.size() + ""); // new Thread(new Runnable() { // @Override // public void run() { // initOver(list); // } // }).start(); cursor.close(); db.close(); } catch (Exception e) { e.printStackTrace(); } } public void initOver(List list) { dialog.cancel(); zhan_num = list.size(); Log.e("initOver==", list.size() + ""); if (list.size() > 0) { tv_zhan_num.setText(zhan_num + ""); if (list_zhong.size() <= 0) { Log.e("<=0", list.size() + ""); for (int i = 0; i < list.size(); i++) { if (!list.get(i).getPoi_wei().equals("") && !list.get(i).getPoi_jing().equals("")) { int position = list.get(i).getPoi_jing().length() - list.get(i).getPoi_jing().indexOf(".") + 1; LatLng ll = null; if (position > 13) { ll = new LatLng(Double.parseDouble(list.get(i).getPoi_wei()), Double.parseDouble(list.get(i).getPoi_jing())); } else if (position <= 13) { double dwei = Double.parseDouble(list.get(i).getPoi_wei()); double djing = Double.parseDouble(list.get(i).getPoi_jing()); getGaode(djing, dwei); ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing)); } if (list.get(i).getOwn_pay().equals("1")) { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(1))) .title(CAN_PAY_MARKER); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } else { if (!list.get(i).getSuit_car().equals("特斯拉") && list.get(i).getStatus().equals("4")) { if (WelcomeActivity.canCost.contains(list.get(i).getSupplier())) { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(3))) .title(NO_PAY_HAVE_STATUS_MARKER); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } else { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(5))) .title(NO_PAY_NO_STATUS_MARKER); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } } } } } } else { Log.e(">0", list_zhong.size() + ""); String s = ""; if (list_zhong.size() == 1) { for (int j = 0; j < list_zhong.size(); j++) { s += list_zhong.get(j).getZhan_id() + ":"; } String[] my = s.split(":"); p1 = my[0]; } else if (list_zhong.size() == 2) { for (int j = 0; j < list_zhong.size(); j++) { s += list_zhong.get(j).getZhan_id() + ":"; } String[] my = s.split(":"); p1 = my[0]; p2 = my[1]; } else if (list_zhong.size() == 3) { for (int j = 0; j < list_zhong.size(); j++) { s += list_zhong.get(j).getZhan_id() + ":"; } String[] my = s.split(":"); p1 = my[0]; p2 = my[1]; p3 = my[2]; } Log.e("ssss", p1 + "---" + p2 + "---" + p3); for (int i = 0; i < list.size(); i++) { if (!list.get(i).getPoi_wei().equals("") && !list.get(i).getPoi_jing().equals("") && !String.valueOf(list.get(i).getId()).equals(p1) && !String.valueOf(list.get(i).getId()).equals(p2) && !String.valueOf(list.get(i).getId()).equals(p3)) { int position = list.get(i).getPoi_jing().length() - list.get(i).getPoi_jing().indexOf(".") + 1; LatLng ll = null; if (position > 13) { ll = new LatLng(Double.parseDouble(list.get(i).getPoi_wei()), Double.parseDouble(list.get(i).getPoi_jing())); } else if (position <= 13) { double dwei = Double.parseDouble(list.get(i).getPoi_wei()); // System.out.print("wei:"+l.get(i).getPoi_wei()); double djing = Double.parseDouble(list.get(i).getPoi_jing()); // System.out.println("jing:"+l.get(i).getPoi_jing()); getGaode(djing, dwei); ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing)); } if (list.get(i).getOwn_pay().equals("1")) { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(1))) .title(CAN_PAY_MARKER); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } else { if (!list.get(i).getSuit_car().equals("特斯拉") && list.get(i).getStatus().equals("4")) { if (WelcomeActivity.canCost.contains(list.get(i).getSupplier())) { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(3))) .title(NO_PAY_HAVE_STATUS_MARKER); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } else { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(5))) .title(NO_PAY_NO_STATUS_MARKER); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } } } } } for (int i = 0; i < list.size(); i++) { if (!list.get(i).getPoi_wei().equals("") && !list.get(i).getPoi_jing().equals("")) { int position = list.get(i).getPoi_jing().length() - list.get(i).getPoi_jing().indexOf(".") + 1; LatLng ll = null; if (position > 13) { ll = new LatLng(Double.parseDouble(list.get(i).getPoi_wei()), Double.parseDouble(list.get(i).getPoi_jing())); } else if (position <= 13) { double dwei = Double.parseDouble(list.get(i).getPoi_wei()); // System.out.print("wei:"+l.get(i).getPoi_wei()); double djing = Double.parseDouble(list.get(i).getPoi_jing()); // System.out.println("jing:"+l.get(i).getPoi_jing()); getGaode(djing, dwei); ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing)); } if (String.valueOf(list.get(i).getId()).equals(p1) && !list.get(i).getSuit_car().equals("宝马") && !list.get(i).getSuit_car().equals("特斯拉")) { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(11))) .title(ROUTE_POINT_ONE); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } else if (String.valueOf(list.get(i).getId()).equals(p2) && !list.get(i).getSuit_car().equals("宝马") && !list.get(i).getSuit_car().equals("特斯拉")) { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(12))) .title(ROUTE_POINT_TWO); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } else if (String.valueOf(list.get(i).getId()).equals(p3) && !list.get(i).getSuit_car().equals("宝马") && !list.get(i).getSuit_car().equals("特斯拉")) { Bundle bundle = new Bundle(); bundle.putSerializable("info", list.get(i)); oocity = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(getMarkerBmpYes(13))) .title(ROUTE_POINT_THREE); mMarkerCity = (Marker) amap.addMarker(oocity); mMarkerCity.setObject(bundle); } } } } } } public void goToEmulateActivity(View view) { if (chooseRouteSuccess && calculateSuccess) { //SimpleNaviActivity非常简单,就是startNavi而已(因为导航道路已在这个activity生成好) Intent intent = new Intent(this, SimpleNaviActivity.class); intent.putExtra("gps", false); startActivity(intent); } else { Toast.makeText(this, "请先算路,选路", Toast.LENGTH_SHORT).show(); } } @Override public void onInitNaviFailure() { } @Override public void onInitNaviSuccess() { } @Override public void onStartNavi(int type) { } @Override public void onTrafficStatusUpdate() { } @Override public void onLocationChange(AMapNaviLocation location) { } @Override public void onGetNavigationText(int type, String text) { } @Override public void onGetNavigationText(String s) { } @Override public void onEndEmulatorNavi() { } @Override public void onArriveDestination() { } // @Override // public void onArriveDestination(NaviStaticInfo naviStaticInfo) { // // } // // @Override // public void onArriveDestination(AMapNaviStaticInfo aMapNaviStaticInfo) { // // } // // @Override // public void onCalculateRouteSuccess() { // // } @Override public void onCalculateRouteFailure(int errorInfo) { } @Override public void onReCalculateRouteForYaw() { } @Override public void onReCalculateRouteForTrafficJam() { } @Override public void onArrivedWayPoint(int wayID) { } @Override public void onGpsOpenStatus(boolean enabled) { } @Override public void onNaviInfoUpdated(AMapNaviInfo naviInfo) { } @Override public void updateCameraInfo(AMapNaviCameraInfo[] aMapNaviCameraInfos) { } @Override public void updateIntervalCameraInfo(AMapNaviCameraInfo aMapNaviCameraInfo, AMapNaviCameraInfo aMapNaviCameraInfo1, int i) { } @Override public void onServiceAreaUpdate(AMapServiceAreaInfo[] aMapServiceAreaInfos) { } @Override public void onNaviInfoUpdate(NaviInfo naviinfo) { } @Override public void OnUpdateTrafficFacility(TrafficFacilityInfo trafficFacilityInfo) { } @Override public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo aMapNaviTrafficFacilityInfo) { } @Override public void showCross(AMapNaviCross aMapNaviCross) { aMapNaviCross.getBitmap().eraseColor(getResources().getColor(R.color.lvse)); } @Override public void hideCross() { } @Override public void showModeCross(AMapModelCross aMapModelCross) { } @Override public void hideModeCross() { } @Override public void showLaneInfo(AMapLaneInfo[] laneInfos, byte[] laneBackgroundInfo, byte[] laneRecommendedInfo) { } @Override public void showLaneInfo(AMapLaneInfo aMapLaneInfo) { } @Override public void hideLaneInfo() { } public void chooseStart(View view) { Toast.makeText(this, "请在地图上点选起点", Toast.LENGTH_SHORT).show(); mapClickStartReady = true; } public void chooseEnd(View view) { Toast.makeText(this, "请在地图上点选终点", Toast.LENGTH_SHORT).show(); mapClickEndReady = true; } public void goToGPSActivity(View view) { if (chooseRouteSuccess && calculateSuccess) { //SimpleNaviActivity非常简单,就是startNavi而已(因为导航道路已在这个activity生成好) Intent intent = new Intent(this, SimpleNaviActivity.class); intent.putExtra("gps", true); startActivity(intent); } else { Toast.makeText(this, "请先算路,选路", Toast.LENGTH_SHORT).show(); } } @Override public void activate(OnLocationChangedListener onLocationChangedListener) { // Toast.makeText(getApplicationContext(), "activate", Toast.LENGTH_SHORT).show(); mListener = onLocationChangedListener; if (mlocationClient == null) { mlocationClient = new AMapLocationClient(this); mLocationOption = new AMapLocationClientOption(); //设置定位监听 mlocationClient.setLocationListener(this); //设置为高精度定位模式 mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); mLocationOption.setGpsFirst(true); // mLocationOption.setOnceLocation(true); mLocationOption.setInterval(1500); //设置是否强制刷新WIFI,默认为强制刷新 mLocationOption.setWifiActiveScan(true); //设置定位参数 mlocationClient.setLocationOption(mLocationOption); // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗, // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求 // 在定位结束后,在合适的生命周期调用onDestroy()方法 // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除 // 设置是否只定位一次,默认为false mlocationClient.startLocation(); } } @Override public void deactivate() { mListener = null; if (mlocationClient != null) { mlocationClient.stopLocation(); mlocationClient.onDestroy(); } mlocationClient = null; } @Override public void onLocationChanged(AMapLocation amapLocation) { if (mListener != null && amapLocation != null) { if (amapLocation != null && amapLocation.getErrorCode() == 0) { mlocationClient.stopLocation(); try { poi_jing = String.valueOf(amapLocation.getLongitude()); poi_wei = String.valueOf(amapLocation.getLatitude()); } catch (NullPointerException e) { e.printStackTrace(); } // ProfileManager.getInstance().setAtCity(getApplicationContext(), MainApplication.atCity); center = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude()); // Toast.makeText(getApplicationContext(), "!!!" + amapLocation.getLongitude() + "---" + amapLocation.getLatitude(), Toast.LENGTH_SHORT).show(); mlocationClient.stopLocation(); dialog.cancel(); initDatas(); // Log.e("!@#$",amapLocation.getLatitude()+"```"+amapLocation.getLongitude()); //// Toast.makeText(this, amapLocation.getAddress(), Toast.LENGTH_SHORT).show(); //// Toast.makeText(this, amapLocation.getCity(), Toast.LENGTH_SHORT).show(); // ete("{\"fun\":\"timer\"}"); // if (isFirstLoc) { // //设置缩放级别 // aMap.moveCamera(CameraUpdateFactory.zoomTo(14)); // //将地图移动到定位点 // aMap.moveCamera(CameraUpdateFactory.changeLatLng(center)); // // //点击定位按钮 能够将地图的中心移动到定位点 // mListener.onLocationChanged(amapLocation); // isFirstLoc = false; // } // initDatas(); } else { String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo(); Log.e("AmapErr", errText); // mLocationErrText.setVisibility(View.VISIBLE); Toast.makeText(this, errText, Toast.LENGTH_SHORT).show(); } } } @Override public void onMapLoaded() { amap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种 amap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE); // aMap.moveCamera(); // amap.moveCamera(CameraUpdateFactory.zoomTo(14)); Log.d("??", "!"); } @Override public void onCameraChange(CameraPosition cameraPosition) { } // @Override public void onCameraChangeFinish(CameraPosition cameraPosition) { // LogUtils.e(currentMarker); LogUtils.e("onCameraChangeFinish"); if (canRefreshMarker == true) { if (null != currentMarker) { resetPreviousMarker(currentMarker); if (currentMarker.isInfoWindowShown()) { currentMarker.hideInfoWindow(); } } } else { canRefreshMarker = true; } } private void exchangeView(int i) { if (i == 1) { rl_route1.setBackgroundResource(R.color.white); tv_route_no1.setTextColor(getResources().getColor(R.color.lvse)); tv_route_time1.setTextColor(getResources().getColor(R.color.lvse)); tv_route_distance1.setTextColor(getResources().getColor(R.color.lvse)); rl_route2.setBackgroundResource(R.color.white); tv_route_no2.setTextColor(getResources().getColor(R.color.ui_68)); tv_route_time2.setTextColor(getResources().getColor(R.color.ui_62)); tv_route_distance2.setTextColor(getResources().getColor(R.color.ui_65)); rl_route3.setBackgroundResource(R.color.white); tv_route_no3.setTextColor(getResources().getColor(R.color.ui_68)); tv_route_time3.setTextColor(getResources().getColor(R.color.ui_62)); tv_route_distance3.setTextColor(getResources().getColor(R.color.ui_65)); } else if (i == 2) { rl_route1.setBackgroundResource(R.color.white); tv_route_no1.setTextColor(getResources().getColor(R.color.ui_68)); tv_route_time1.setTextColor(getResources().getColor(R.color.ui_62)); tv_route_distance1.setTextColor(getResources().getColor(R.color.ui_65)); rl_route2.setBackgroundResource(R.color.white); tv_route_no2.setTextColor(getResources().getColor(R.color.lvse)); tv_route_time2.setTextColor(getResources().getColor(R.color.lvse)); tv_route_distance2.setTextColor(getResources().getColor(R.color.lvse)); rl_route3.setBackgroundResource(R.color.white); tv_route_no3.setTextColor(getResources().getColor(R.color.ui_68)); tv_route_time3.setTextColor(getResources().getColor(R.color.ui_62)); tv_route_distance3.setTextColor(getResources().getColor(R.color.ui_65)); } else if (i == 3) { rl_route1.setBackgroundResource(R.color.white); tv_route_no1.setTextColor(getResources().getColor(R.color.ui_68)); tv_route_time1.setTextColor(getResources().getColor(R.color.ui_62)); tv_route_distance1.setTextColor(getResources().getColor(R.color.ui_65)); rl_route2.setBackgroundResource(R.color.white); tv_route_no2.setTextColor(getResources().getColor(R.color.ui_68)); tv_route_time2.setTextColor(getResources().getColor(R.color.ui_62)); tv_route_distance2.setTextColor(getResources().getColor(R.color.ui_65)); rl_route3.setBackgroundResource(R.color.white); tv_route_no3.setTextColor(getResources().getColor(R.color.lvse)); tv_route_time3.setTextColor(getResources().getColor(R.color.lvse)); tv_route_distance3.setTextColor(getResources().getColor(R.color.lvse)); } } @Override public void onClick(View v) { switch (v.getId()) { case R.id.rl_route_tip: ivListStatus.setImageResource(R.drawable.icon_route_list_open); tvOpen.setText("显示地图"); // Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_route); // animation1.setDuration(2000); lvRouteInfo.setVisibility(View.VISIBLE); AnimatorStart(); // llOpenView.startAnimation(animation1); break; case R.id.ll_open: if (canRoute == false) { rl_yinying.setVisibility(View.VISIBLE); } else { if (lvRouteInfo.getVisibility() == View.GONE) { showListData(routeOverlays, routeNum); ivListStatus.setImageResource(R.drawable.icon_route_list_open); tvOpen.setText("显示地图"); // Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_route); // animation1.setDuration(2000); lvRouteInfo.setVisibility(View.VISIBLE); AnimatorStart(); } else { ivListStatus.setImageResource(R.drawable.icon_route_list_close); tvOpen.setText("路线详情"); new Handler().postDelayed(new Runnable() { @Override public void run() { lvRouteInfo.setVisibility(View.GONE); } }, 300); AnimatorEnd(); } } break; case R.id.iv_setting: startActivityForResult(new Intent(RoutePlanMapActivity.this, RoutePreferenceActivity.class), REQUSET); break; case R.id.iv_screenShot: LatLngBounds bounds = LatLngBounds.builder().include(new LatLng(startLatlng.getLatitude(), startLatlng.getLongitude())).include(new LatLng(endLatlng.getLatitude(), endLatlng.getLongitude())).build(); amap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(bounds, 200, 200, 180, 460)); iv_screenShot.setEnabled(false); dialog.show(); new Handler().postDelayed(new Runnable() { public void run() { // showSimpleBottomSheetGrid(); mapScreenShot(); } }, 1000); break; case R.id.tv_iknow: rl_yinying.setVisibility(View.GONE); break; case R.id.rl_route1: dialog.show(); routeNum = 1; list_zhan.clear(); zhan_num = 0; if (null != routeIds) { select = 1; exchangeView(1); amap.clear(); for (int i = 0; i < routeIds.length; i++) { AMapNaviPath path = (aMapNavi.getNaviPaths()).get(routeIds[i]); //你可以通过这个AMapNaviPath生成一个RouteOverLay用于加在地图上 routeOverLay = new RouteOverLay(amap, path, this); routeOverLay.setStartPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_route_start))); routeOverLay.setEndPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_route_end))); routeOverLay.setWayPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_zhanwei))); routeOverLay.addToMap(); routeOverlays.put(routeIds[i], routeOverLay); } if (!calculateSuccess) { Toast.makeText(this, "请先算路", Toast.LENGTH_SHORT).show(); return; } if (routeIndex >= routeIds.length) routeIndex = 0; //突出选择的那条路 for (RouteOverLay routeOverLay : routeOverlays.values()) { routeOverLay.setTransparency(0.3f); } routeOverlays.get(routeIds[0]).setTransparency(0.8f); //必须告诉AMapNavi 你最后选择的哪条路 aMapNavi.selectRouteId(routeIds[0]); // Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllTime() + "s", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getStrategy() + "z", Toast.LENGTH_SHORT).show(); final List nl = (aMapNavi.getNaviPaths()).get(routeIds[0]).getCoordList(); // Toast.makeText(this, (aMapNavi.getNaviPaths()).get(routeIds[0]).getStrategy(), Toast.LENGTH_SHORT).show(); routeIndex++; chooseRouteSuccess = true; Log.e(TAG, "onClick: routeOne_size=" + routeOne.size()); new Handler().postDelayed(new Runnable() { @Override public void run() { if (routeNum == 1) { if (routeOne.size() > 0) { initOver(routeOne); } else { if (nl != null) { getZhanPoint(nl); } } } } }, 500); showListData(routeOverlays, routeNum); } break; case R.id.rl_route2: dialog.show(); routeNum = 2; list_zhan.clear(); zhan_num = 0; if (null != routeIds) { select = 2; exchangeView(2); amap.clear(); for (int i = 0; i < routeIds.length; i++) { AMapNaviPath path = (aMapNavi.getNaviPaths()).get(routeIds[i]); //你可以通过这个AMapNaviPath生成一个RouteOverLay用于加在地图上 routeOverLay = new RouteOverLay(amap, path, this); routeOverLay.setStartPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_route_start))); routeOverLay.setEndPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_route_end))); routeOverLay.setWayPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_zhanwei))); routeOverLay.addToMap(); routeOverlays.put(routeIds[i], routeOverLay); } if (!calculateSuccess) { Toast.makeText(this, "请先算路", Toast.LENGTH_SHORT).show(); return; } if (routeIndex >= routeIds.length) routeIndex = 0; //突出选择的那条路 for (RouteOverLay routeOverLay : routeOverlays.values()) { routeOverLay.setTransparency(0.3f); } routeOverlays.get(routeIds[1]).setTransparency(0.8f); //必须告诉AMapNavi 你最后选择的哪条路 aMapNavi.selectRouteId(routeIds[1]); final List nll = (aMapNavi.getNaviPaths()).get(routeIds[1]).getCoordList(); routeIndex++; chooseRouteSuccess = true; Log.e(TAG, "onClick: routeTwo_size=" + routeTwo.size()); new Handler().postDelayed(new Runnable() { @Override public void run() { if (routeNum == 2) { if (routeTwo.size() > 0) { initOver(routeTwo); } else { if (nll != null) { getZhanPoint(nll); } } } } }, 500); showListData(routeOverlays, routeNum); } break; case R.id.rl_route3: dialog.show(); routeNum = 3; list_zhan.clear(); zhan_num = 0; if (null != routeIds && routeIds.length >= 2) { select = 3; exchangeView(3); amap.clear(); for (int i = 0; i < routeIds.length; i++) { AMapNaviPath path = (aMapNavi.getNaviPaths()).get(routeIds[i]); //你可以通过这个AMapNaviPath生成一个RouteOverLay用于加在地图上 routeOverLay = new RouteOverLay(amap, path, this); routeOverLay.setStartPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstarr))); routeOverLay.setEndPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstopr))); routeOverLay.setWayPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_zhanwei))); routeOverLay.addToMap(); routeOverlays.put(routeIds[i], routeOverLay); } if (!calculateSuccess) { Toast.makeText(this, "请先算路", Toast.LENGTH_SHORT).show(); return; } if (routeIndex >= routeIds.length) routeIndex = 0; //突出选择的那条路 for (RouteOverLay routeOverLay : routeOverlays.values()) { routeOverLay.setTransparency(0.3f); } routeOverlays.get(routeIds[2]).setTransparency(0.8f); //必须告诉AMapNavi 你最后选择的哪条路 aMapNavi.selectRouteId(routeIds[2]); // Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllTime() + "s", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[2]).getStrategy() + "z", Toast.LENGTH_SHORT).show(); final List nlll = (aMapNavi.getNaviPaths()).get(routeIds[2]).getCoordList(); // Toast.makeText(this, (aMapNavi.getNaviPaths()).get(routeIds[2]).getStrategy(), Toast.LENGTH_SHORT).show(); routeIndex++; chooseRouteSuccess = true; Log.e(TAG, "onClick: routeThree_size=" + routeThree.size()); new Handler().postDelayed(new Runnable() { @Override public void run() { if (routeNum == 3) { if (routeThree.size() > 0) { initOver(routeThree); } else { if (nlll != null) { getZhanPoint(nlll); } } } } }, 500); showListData(routeOverlays, routeNum); } break; case R.id.tv_save_route: if (canSave == false) { rl_yinying.setVisibility(View.VISIBLE); } else { if (MainApplication.isLogin()) { MobclickAgent.onEvent(getApplicationContext(), "0308"); if ("0".equals(save_id)) { if (noNameCount == haveNameCount) // LogUtils.e(noNameCount+"---"+haveNameCount); creatSaveData(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(RoutePlanMapActivity.this); builder.setTitle("提示"); builder.setMessage("保存会覆盖本条记录,是否继续操作?"); builder.setCancelable(false); builder.setPositiveButton("保存", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (noNameCount == haveNameCount) // LogUtils.e(noNameCount+"---"+haveNameCount); creatSaveData(); } }); builder.setNegativeButton("取消", null); builder.create().show(); } } else { ToastUtil.showToast(getApplicationContext(), "请先登录", Toast.LENGTH_SHORT); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); } } break; case R.id.tv_navigation_route: if (canRoute == false) { rl_yinying.setVisibility(View.VISIBLE); } else { if (select == 0) { exchangeView(1); // amap.clear(); for (int i = 0; i < routeIds.length; i++) { AMapNaviPath path = (aMapNavi.getNaviPaths()).get(routeIds[i]); //你可以通过这个AMapNaviPath生成一个RouteOverLay用于加在地图上 routeOverLay = new RouteOverLay(amap, path, this); routeOverLay.setStartPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstarr))); routeOverLay.setEndPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstopr))); routeOverLay.setWayPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_zhanwei))); routeOverLay.addToMap(); routeOverlays.put(routeIds[i], routeOverLay); } if (!calculateSuccess) { Toast.makeText(this, "请先算路", Toast.LENGTH_SHORT).show(); return; } if (routeIndex >= routeIds.length) routeIndex = 0; //突出选择的那条路 for (RouteOverLay routeOverLay : routeOverlays.values()) { routeOverLay.setTransparency(0.3f); } routeOverlays.get(routeIds[0]).setTransparency(0.8f); //必须告诉AMapNavi 你最后选择的哪条路 aMapNavi.selectRouteId(routeIds[0]); // Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllTime() + "s", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getStrategy() + "z", Toast.LENGTH_SHORT).show(); List nnll = (aMapNavi.getNaviPaths()).get(routeIds[0]).getCoordList(); // Toast.makeText(this, (aMapNavi.getNaviPaths()).get(routeIds[0]).getStrategy(), Toast.LENGTH_SHORT).show(); routeIndex++; chooseRouteSuccess = true; // if (nnll != null) { // getRouteZhan(nnll); // } } if (chooseRouteSuccess && calculateSuccess) { MobclickAgent.onEvent(getApplicationContext(), "0309"); if (MainApplication.isLogin()) { getRouteGuide(); } //SimpleNaviActivity非常简单,就是startNavi而已(因为导航道路已在这个activity生成好) if (list_zhong.size() == 1) { Intent intent = new Intent(this, SimpleNaviActivity.class); intent.putExtra("gps", true); startActivity(intent); } else if (list_zhong.size() == 2) { Intent intent = new Intent(this, SimpleNaviActivity.class); intent.putExtra("gps", true); startActivity(intent); } else if (list_zhong.size() == 3) { Intent intent = new Intent(this, SimpleNaviActivity.class); intent.putExtra("gps", true); startActivity(intent); } else { Intent intent = new Intent(this, SimpleNaviActivity.class); intent.putExtra("gps", true); startActivity(intent); } } else { Toast.makeText(this, "请先算路,选路", Toast.LENGTH_SHORT).show(); } } break; case R.id.iv_back: // tag = 0; finish(); // amap.setLocationSource(this);// 设置定位监听 // amap.setMyLocationEnabled(true);// 是否可触发定位并显示定位层 //// ?aMap.moveCamera(CameraUpdateFactory.zoomTo(14)); // mlocationClient.startLocation(); break; default: break; } } private void AnimatorStart() { ValueAnimator valueAnimator = ValueAnimator.ofFloat(llOpenView.getTranslationY(), 0); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { llOpenView.setTranslationY(((Float) animation.getAnimatedValue())); } }); valueAnimator.setDuration(300); valueAnimator.start(); } private void AnimatorEnd() { ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, activity_route_plan.getMeasuredHeight() - ll_route.getMeasuredHeight() - ll.getMeasuredHeight()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { llOpenView.setTranslationY(((Float) animation.getAnimatedValue())); } }); valueAnimator.setDuration(300); valueAnimator.start(); } private void resetPreviousMarker(Marker marker) { switch (marker.getTitle()) { case CAN_PAY_MARKER: marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1)); break; case NO_PAY_HAVE_STATUS_MARKER: marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2)); break; case NO_PAY_NO_STATUS_MARKER: marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3)); break; case ROUTE_POINT_ONE: marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newsmallr1)); break; case ROUTE_POINT_TWO: marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newsmallr2)); break; case ROUTE_POINT_THREE: marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newsmallr3)); break; } } @Override public boolean onMarkerClick(Marker marker) { canRefreshMarker = false; if (null != currentMarker) { resetPreviousMarker(currentMarker); } amap.moveCamera(CameraUpdateFactory.changeLatLng(marker.getPosition())); if (marker.getTitle().equals(CAN_PAY_MARKER)) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig1)); } else if (marker.getTitle().equals(NO_PAY_HAVE_STATUS_MARKER)) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig2)); } else if (marker.getTitle().equals(NO_PAY_NO_STATUS_MARKER)) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig3)); } else if (marker.getTitle().equals(ROUTE_POINT_ONE)) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbigr1)); } else if (marker.getTitle().equals(ROUTE_POINT_TWO)) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbigr2)); } else if (marker.getTitle().equals(ROUTE_POINT_THREE)) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbigr3)); } currentMarker = marker; marker.showInfoWindow(); return true; } private void creatSaveData() { RouteHistoryBean.InfoBean infoBean = new RouteHistoryBean.InfoBean(); RouteHistoryBean.InfoBean.StartBean startBean = new RouteHistoryBean.InfoBean.StartBean(); startBean.setName(save_start_name); startBean.setLat(start_wei); startBean.setLon(start_jing); infoBean.setStart(startBean); RouteHistoryBean.InfoBean.EndBean endBean = new RouteHistoryBean.InfoBean.EndBean(); endBean.setName(save_end_name); endBean.setLat(end_wei); endBean.setLon(end_jing); infoBean.setEnd(endBean); List list = new ArrayList<>(); for (int i = 0; i < list_zhong.size(); i++) { RouteHistoryBean.InfoBean.WaypointBean wpb = new RouteHistoryBean.InfoBean.WaypointBean(); wpb.setLon(list_zhong.get(i).getPoi_jing()); wpb.setLat(list_zhong.get(i).getPoi_wei()); wpb.setZhanId(list_zhong.get(i).getZhan_id()); wpb.setZhanName(list_zhong.get(i).getZhan_name()); list.add(wpb); } infoBean.setWaypoint(list); String json = new Gson().toJson(infoBean); saveRoute(json); } public void showInfoWindowData(final String zhan_id, final View infoWindow, final ZhanData zhanData, final Marker marker) { TextView mInfoWindowFast = infoWindow.findViewById(R.id.evsdk_tv_info_fast); //infowinow中慢充数的显示 TextView mInfoWindowSlow = infoWindow.findViewById(R.id.evsdk_tv_info_slow); //infowinow中运营商的显示 TextView mInfoWindowSupplier = infoWindow.findViewById(R.id.evsdk_tv_info_supplier); //infowinow中距离的显示 TextView mInfoWindowDistance = infoWindow.findViewById(R.id.evsdk_tv_info_distance); LatLng ll = new LatLng(Double.parseDouble(start_wei), Double.parseDouble(start_jing)); float distance = AMapUtils.calculateLineDistance(new LatLng(ll.latitude , ll.longitude), marker.getPosition()); // Toast.makeText(getApplicationContext(),Util.getDistance(d),Toast.LENGTH_SHORT).show(); mInfoWindowDistance.setText(Util.getDistance(distance)); //infowinow中站名称的显示 TextView mInfoWindowName = infoWindow.findViewById(R.id.evsdk_tv_info_name); if (zhanData != null) { mInfoWindowSlow.setText(zhanData.getSlow_num()); mInfoWindowFast.setText(zhanData.getFast_num()); mInfoWindowName.setText(zhanData.getZhan_name()); mInfoWindowSupplier.setText(zhanData.getSupplier()); } //infowinow中添加/删除途经点的显示 ImageView mInfoWindowDeal = infoWindow.findViewById(R.id.evsdk_iv_deal_waypoint); if (marker.getTitle().equals(ROUTE_POINT_ONE) || marker.getTitle().equals(ROUTE_POINT_TWO) || marker.getTitle().equals(ROUTE_POINT_THREE)) { mInfoWindowDeal.setImageResource(R.drawable.evsdk_icon_delete_waypoint); } RelativeLayout mInfoWindowAdd = infoWindow.findViewById(R.id.evsdk_rl_routeadd); mInfoWindowAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { routeNum = 1; routeOne.clear(); routeTwo.clear(); routeThree.clear(); exchangeView(1); // if (list_zhong.size() <= 3) { if (!zhan_id.equals(p1) && !zhan_id.equals(p2) && !zhan_id.equals(p3)) { if (list_zhong.size() < 3) { zhan = new Zhan(); zhan.setPoi_jing(String.valueOf(marker.getPosition().longitude)); zhan.setPoi_wei(String.valueOf(marker.getPosition().latitude)); zhan.setZhan_id(zhan_id); if (zhanData != null) { zhan.setZhan_name(zhanData.getZhan_name()); } list_zhong.add(zhan); Log.e("size===", list_zhong.size() + ""); if (list_zhong.size() > 0) { // tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_green); // tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_green); canRoute = true; canSave = true; } else { // tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_grey); // tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_grey); canRoute = false; canSave = false; } rela_paopao.setVisibility(View.GONE); amap.clear(); endLatlng = new NaviLatLng(Double.parseDouble(end_wei), Double.parseDouble(end_jing)); startLatlng = new NaviLatLng(Double.parseDouble(start_wei), Double.parseDouble(start_jing)); endList.clear(); startList.clear(); zhongList.clear(); startList.add(startLatlng); endList.add(endLatlng); for (int i = 0; i < list_zhong.size(); i++) { zhongLatlng = new NaviLatLng(Double.parseDouble(list_zhong.get(i).getPoi_wei()), Double.parseDouble(list_zhong.get(i).getPoi_jing())); zhongList.add(zhongLatlng); } int strategyFlag = 0; try { strategyFlag = aMapNavi.strategyConvert(ProfileManager.getInstance().getDbyd(getApplicationContext()), ProfileManager.getInstance().getBzgs(getApplicationContext()), ProfileManager.getInstance().getBmsf(getApplicationContext()), ProfileManager.getInstance().getGsyx(getApplicationContext()), true); } catch (Exception e) { e.printStackTrace(); } if (strategyFlag >= 0) { aMapNavi.calculateDriveRoute(startList, endList, zhongList, strategyFlag); // Toast.makeText(getApplicationContext(), "策略:" + strategyFlag, Toast.LENGTH_LONG).show(); } rl_infowindow.setVisibility(View.GONE); } else { Toast.makeText(getApplicationContext(), "您已经选择了三个途经点", Toast.LENGTH_SHORT).show(); } } else { Log.e("!!!!", p1 + "--" + p2 + "--" + p3); if (zhan_id.equals(p1) || zhan_id.equals(p2) || zhan_id.equals(p3)) { for (int i = 0; i < list_zhong.size(); i++) { if (zhan_id.equals(list_zhong.get(i).getZhan_id())) { list_zhong.remove(i); p1 = ""; p2 = ""; p3 = ""; } } if (list_zhong.size() > 0) { // tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_green); // tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_green); canRoute = true; canSave = true; } else { // tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_grey); // tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_grey); canRoute = false; canSave = false; } } Log.e("list_zhong==!++", list_zhong.size() + ""); rela_paopao.setVisibility(View.GONE); amap.clear(); endLatlng = new NaviLatLng(Double.parseDouble(end_wei), Double.parseDouble(end_jing)); startLatlng = new NaviLatLng(Double.parseDouble(start_wei), Double.parseDouble(start_jing)); endList.clear(); startList.clear(); zhongList.clear(); startList.add(startLatlng); endList.add(endLatlng); for (int i = 0; i < list_zhong.size(); i++) { zhongLatlng = new NaviLatLng(Double.parseDouble(list_zhong.get(i).getPoi_wei()), Double.parseDouble(list_zhong.get(i).getPoi_jing())); zhongList.add(zhongLatlng); } int strategyFlag = 0; try { strategyFlag = aMapNavi.strategyConvert(ProfileManager.getInstance().getDbyd(getApplicationContext()), ProfileManager.getInstance().getBzgs(getApplicationContext()), ProfileManager.getInstance().getBmsf(getApplicationContext()), ProfileManager.getInstance().getGsyx(getApplicationContext()), true); } catch (Exception e) { e.printStackTrace(); } if (strategyFlag >= 0) { aMapNavi.calculateDriveRoute(startList, endList, zhongList, strategyFlag); // Toast.makeText(getApplicationContext(), "策略:" + strategyFlag, Toast.LENGTH_LONG).show(); } // aMapNavi.calculateDriveRoute(startList, endList, zhongList, PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES); dialog.show(); } // }else { // Toast.makeText(getApplicationContext(),"您已经选择了三个途经点",Toast.LENGTH_SHORT).show(); // } } }); LinearLayout mInfoWindow = infoWindow.findViewById(R.id.evsdk_rl_infowindow); mInfoWindow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { MainApplication.details_flag = "2"; Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class); intent.putExtra("zhan_id", zhan_id); startActivity(intent); } }); } private void getZhanInfo(final String zhan_id, final zhan_list markerInfo, final Marker marker, final View infoWindow) { String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/getzhan?zhan_id=" + zhan_id; OkHttpUtils.get() .url(url) .build() .execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { LogUtils.e(response); String info = JsonUtils.getKeyResult(response, "info"); ZhanData zhanInfo = JsonUtils.parseToObjectBean(info, ZhanData.class); showInfoWindowData(zhan_id, infoWindow, zhanInfo, marker); // try { // JSONObject object = new JSONObject(response); // JSONObject obj = object.getJSONObject("info"); // final String zhan_name = obj.getString("zhan_name"); // final String fast_num = obj.getString("fast_num"); // String slow_num = obj.getString("slow_num"); // String charge_cost = obj.getString("charge_cost"); // String stop_cost = obj.getString("stop_cost"); // String other_cost = obj.getString("other_cost"); // String charge_cost_way = obj.getString("supplier"); // String belong_attribute = obj.getString("belong_attribute"); //// rl_infowindow.setVisibility(View.VISIBLE); // tv_route_name.setText(zhan_name); // if (charge_cost_way.equals("") || belong_attribute.equals("私人")) { // tv_route_costway.setText(""); // } else { // tv_route_costway.setText(charge_cost_way); // } //// Log.e("123", "onResponse: 111111"); // // if (fast_num.equals("")) { // tv_route_fast.setText("0"); // } else { // tv_route_fast.setText(fast_num); // } // // if (slow_num.equals("")) { // tv_route_slow.setText("0"); // } else { // tv_route_slow.setText(slow_num); // } // // // rl_details.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // MainApplication.details_flag = "2"; // Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class); // intent.putExtra("zhan_id", zhan_id); // startActivity(intent); // } // }); // //// rl_routebtn.setOnClickListener(new View.OnClickListener() { //// @Override //// public void onClick(View v) { //// //// } //// }); // // // final String poi_wei = wei; // final String poi_jing = jing; // // LatLng ll = new LatLng(Double.parseDouble(start_wei), Double.parseDouble(start_jing)); // LatLng l = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing)); //// double d = DistanceUtil.getDistance(MainMapActivity.center, ll); // // double d = AMapUtils.calculateLineDistance(l, ll); //// Toast.makeText(getApplicationContext(),Util.getDistance(d),Toast.LENGTH_SHORT).show(); // tv_distance.setText(Util.getDistance(d)); // // String acNum = "", dcNum = "", acableNum = "", dcableNum = ""; // if (!obj.isNull("acNum")) { // acNum = obj.getString("acNum"); // dcNum = obj.getString("dcNum"); // acableNum = obj.getString("acableNum"); // dcableNum = obj.getString("dcableNum"); // } // // detail_name.setText(zhan_name); // // tv_charge.setText(charge_cost); // tv_service.setText(other_cost); // tv_park.setText(stop_cost); // tv_cost_way.setText(charge_cost_way); // if (!obj.isNull("acNum") && !obj.isNull("dcNum")) { // tv_slowNum.setText("空闲" + acableNum + "/共" + acNum + "个"); // tv_fastNum.setText("空闲" + dcableNum + "/共" + dcNum + "个"); // } else { // if (fast_num.equals("")) { // tv_fastNum.setText("0"); // } else { // tv_fastNum.setText(fast_num); // } // if (slow_num.equals("")) { // tv_slowNum.setText("0"); // } else { // tv_slowNum.setText(slow_num); // } // } // if (list_zhong != null) { // if (zhan_id.equals(p1) || zhan_id.equals(p2) || zhan_id.equals(p3)) { //// tv_zhong.setText("删除此途经站点"); // rl_routebtn.setBackgroundResource(R.drawable.icon_route_minus); // } else { //// tv_zhong.setText("设置为途经站点"); // rl_routebtn.setBackgroundResource(R.drawable.icon_route_plus); // } // } //// rela_paopao.setVisibility(View.VISIBLE); // // // // ll_paoxiang.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // MainApplication.details_flag = "2"; // Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class); // intent.putExtra("zhan_id", zhan_id); // startActivity(intent); // // } // }); // // ll_comment.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // MainApplication.details_flag = "4"; // Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class); // intent.putExtra("zhan_id", zhan_id); // startActivity(intent); // } // }); // // tv_daohang.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // // if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") && // !isAvilible(getApplicationContext(), "com.autonavi.minimap")) { // Intent intent = new Intent(getApplication(), BasicNaviActivity.class); // intent.putExtra("start_jing", center.longitude + ""); // intent.putExtra("start_wei", center.latitude + ""); // intent.putExtra("stop_jing", jing + ""); // intent.putExtra("stop_wei", wei + ""); // startActivity(intent); //// detailsBack = true; //// HashMap map = new HashMap(); //// map.put("Name",finalMarkerInfo.getZhan_name()); //// map.put("CostWay",finalMarkerInfo.getCharge_cost_way()); //// map.put("City",finalMarkerInfo.getCity()); //// MobclickAgent.onEvent(context, "0033", map); //// map.clear(); // } else { // if (center != null) { // LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); // popupWindowView = inflater1.inflate(R.layout.item_selectmap, null); // popupWindow = new PopupWindow(popupWindowView, // ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, // true); // popupWindow.setBackgroundDrawable(new BitmapDrawable()); // // 设置PopupWindow的弹出和消失效果 // popupWindow.setAnimationStyle(R.style.popupAnimation); // LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo); // if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) { // ll_tvTwo.setVisibility(View.GONE); // } // LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne); // if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) { // ll_tvOne.setVisibility(View.GONE); // } // cancleButton = (Button) popupWindowView // .findViewById(R.id.cancleButton); // cancleButton.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { //// Toast.makeText(ZhanDetailsNew.this, "NO", Toast.LENGTH_SHORT).show(); // popupWindow.dismiss(); // } // }); // tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree); // tvThree.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Intent intent = new Intent(getApplication(), BasicNaviActivity.class); // intent.putExtra("start_jing", center.longitude + ""); // intent.putExtra("start_wei", center.latitude + ""); // intent.putExtra("stop_jing", jing + ""); // intent.putExtra("stop_wei", wei + ""); // startActivity(intent); //// detailsBack = true; // popupWindow.dismiss(); // HashMap map = new HashMap(); //// map.put("Name",finalMarkerInfo.getZhan_name()); //// map.put("CostWay",finalMarkerInfo.getCharge_cost_way()); //// map.put("City",finalMarkerInfo.getCity()); //// MobclickAgent.onEvent(context, "0033", map); //// map.clear(); // } // }); // tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne); // tvOne.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // Intent intent = null; //// try { ////// intent = Intent.getIntent("intent://map/direction?origin=latlng:"+center.latitude+","+center.longitude+"&destination=latlng:"+ll.latitude+","+ll.longitude+"|name:"+finalMarkerInfo.getZhan_name()+"&mode=driving®ion=&src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end"); //// } catch (URISyntaxException e) { //// e.printStackTrace(); //// } // double dwei = Double.parseDouble(poi_wei); // double djing = Double.parseDouble(poi_jing); // getBaidu(center.longitude, center.latitude); // try { // String s = "intent://map/direction?" + // "origin=" + bd_lat + "," + bd_lon + "&" + // "destination=" + dwei + "," + djing + // "&mode=driving&" + // "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end"; // Log.e("sss", s); // intent = Intent.getIntent(s); //// detailsBack = true; //// HashMap map = new HashMap(); //// map.put("Name",finalMarkerInfo.getZhan_name()); //// map.put("CostWay",finalMarkerInfo.getCharge_cost_way()); //// map.put("City",finalMarkerInfo.getCity()); //// MobclickAgent.onEvent(context, "0031", map); //// map.clear(); // } catch (URISyntaxException e) { // e.printStackTrace(); // } // startActivity(intent); //// if (MainFragment.center != null) { //// double dwei = Double.parseDouble(zhan.getPoi_wei()); //// double djing = Double.parseDouble(zhan.getPoi_jing()); //// LatLng ll = new LatLng(dwei, djing); //// //// startNavi(MainFragment.center, ll); //// //// } //// startNavi(center, ll); // popupWindow.dismiss(); // // } // // }); // tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo); // tvTwo.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // try { //// getGaode(ll.longitude, ll.latitude); //// getBeginGaode(center.longitude, center.latitude); // Intent intent4 = new Intent("android.intent.action.VIEW", // android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + wei + "&dlon=" + jing + "&dname=" + zhan_name + "&dev=0&m=0&t=2")); // intent4.setPackage("com.autonavi.minimap"); // startActivity(intent4); //// detailsBack = true; // popupWindow.dismiss(); //// HashMap map = new HashMap(); //// map.put("Name",finalMarkerInfo.getZhan_name()); //// map.put("CostWay",finalMarkerInfo.getCharge_cost_way()); //// map.put("City",finalMarkerInfo.getCity()); //// MobclickAgent.onEvent(context, "0032", map); //// map.clear(); // } catch (Exception e) { // e.printStackTrace(); // Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show(); // } // // } // }); // popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0); //// startNavi(center, ll); // } else { // Toast.makeText(getApplication(), // "没有定位到您的当前位置", Toast.LENGTH_SHORT) // .show(); // } // } // } // }); // // } catch (Exception e) { // e.printStackTrace(); // } } }); } @Override public void onMapClick(LatLng latLng) { LogUtils.e("onMapClick"); if (null != currentMarker && currentMarker.isInfoWindowShown() && canRefreshMarker == true) { currentMarker.hideInfoWindow(); resetPreviousMarker(currentMarker); } } private void getCommentNum(final String zhan_id) { String url = MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/getcont?zhanid=" + zhan_id; OkHttpUtils.get() .url(url) .build() .execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { try { JSONObject jsonObject = new JSONObject(response); String comment_num = jsonObject.getString("rtnMsg"); tv_num.setText("(" + comment_num + ")"); } catch (JSONException e) { e.printStackTrace(); } } }); } private void getBaidu(Double jing, Double wei) { double x_pi = 3.14159265358979324 * 3000.0 / 180.0; double x = jing; double y = wei; double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi); bd_lon = z * Math.cos(theta) + 0.0065; bd_lat = z * Math.sin(theta) + 0.006; } private boolean isAvilible(Context context, String packageName) { //获取packagemanager final PackageManager packageManager = context.getPackageManager(); //获取所有已安装程序的包信息 List packageInfos = packageManager.getInstalledPackages(0); //用于存储所有已安装程序的包名 List packageNames = new ArrayList(); //从pinfo中将包名字逐一取出,压入pName list中 if (packageInfos != null) { for (int i = 0; i < packageInfos.size(); i++) { String packName = packageInfos.get(i).packageName; packageNames.add(packName); } } //判断packageNames中是否有目标程序的包名,有TRUE,没有FALSE return packageNames.contains(packageName); } public static Bitmap getBitmapFromView(View view) { view.destroyDrawingCache(); view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec .makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.setDrawingCacheEnabled(true); Bitmap tmp = view.getDrawingCache(); Bitmap bitmap = tmp.copy(Bitmap.Config.ARGB_8888, false); tmp.recycle(); return bitmap; } private Bitmap getMarkerBmpYes(int i) { if (i == 1) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newmarker1); } else if (i == 2) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newbig1); } else if (i == 3) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newmarker2); } else if (i == 4) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newbig2); } else if (i == 5) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newmarker3); } else if (i == 6) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newbig3); } else if (i == 11) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newsmallr1); } else if (i == 12) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newsmallr2); } else if (i == 13) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newsmallr3); } else if (i == 21) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newbigr1); } else if (i == 22) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newbigr2); } else if (i == 23) { mIvMarkerBgYes.setImageResource(R.drawable.icon_newbigr3); } else if (i == 7) { mIvMarkerBgYes.setImageResource(R.drawable.icon_srapp); } else if (i == 8) { mIvMarkerBgYes.setImageResource(R.drawable.icon_brapp); } Bitmap bmp = getBitmapFromView(mMarkerViewYes); return bmp; } private void getGaode(Double jing, Double wei) { // Log.e("jing", jing + ""); // Log.e("wei", wei + ""); double x_pi = 3.14159265358979324 * 3000.0 / 180.0; double gg_lon; double gg_lat; double x = jing - 0.0065, y = wei - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi); gg_lon = z * Math.cos(theta); gd_jing = String.valueOf(gg_lon); // Log.e("gg_lon", gg_lon + ""); gg_lat = z * Math.sin(theta); gd_wei = String.valueOf(gg_lat); // Log.e("gg_lat", gg_lat + ""); } private void showSimpleBottomSheetGrid() { final int TAG_SHARE_WECHAT_FRIEND = 0; final int TAG_SHARE_WECHAT_MOMENT = 1; final int TAG_SHARE_QQ = 2; QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(RoutePlanMapActivity.this); QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE) .addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE) .addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE) .setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() { @Override public void onClick(QMUIBottomSheet dialog, View itemView) { dialog.dismiss(); int tag = (int) itemView.getTag(); switch (tag) { case TAG_SHARE_WECHAT_FRIEND: share(Wechat.NAME); break; case TAG_SHARE_WECHAT_MOMENT: share(WechatMoments.NAME); break; case TAG_SHARE_QQ: share(QQ.NAME); break; } } }).build(); // build. build.show(); iv_screenShot.setEnabled(true); } private void mapScreenShot() { amap.getMapScreenShot(new AMap.OnMapScreenShotListener() { @Override public void onMapScreenShot(Bitmap bitmap) { tv_zhan_num.setText(zhan_num + ""); iv_screen.setImageBitmap(bitmap); getViewBitmap(ll_share_ui, ll_share_ui.getWidth(), ll_share_ui.getHeight() + 70); if (dialog.isShowing()) { dialog.dismiss(); } showSimpleBottomSheetGrid(); } @Override public void onMapScreenShot(Bitmap bitmap, int status) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); if (null == bitmap) { return; } try { FileOutputStream fos = new FileOutputStream( Environment.getExternalStorageDirectory() + "/test_" + sdf.format(new Date()) + ".png"); boolean b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); try { fos.flush(); } catch (IOException e) { e.printStackTrace(); } try { fos.close(); } catch (IOException e) { e.printStackTrace(); } StringBuffer buffer = new StringBuffer(); if (b) { // buffer.append("截屏成功 "); } else { // buffer.append("截屏失败 "); } } catch (FileNotFoundException e) { e.printStackTrace(); } } }); } private void share(final String name) { MobclickAgent.onEvent(getApplicationContext(), "0311"); Platform.ShareParams paramsToShare = new Platform.ShareParams(); paramsToShare.setText(null); paramsToShare.setTitle(null); paramsToShare.setTitleUrl(null); paramsToShare.setUrl("http://a.app.qq.com/o/simple.jsp?pkgname=com.electric.chargingpile"); paramsToShare.setImagePath(Environment.getExternalStorageDirectory() + File.separator + "d1ev/share.png"); paramsToShare.setShareType(Platform.SHARE_IMAGE); Platform platform = ShareSDK.getPlatform(name); platform.setPlatformActionListener(new PlatformActionListener() { @Override public void onComplete(Platform platform, int i, HashMap hashMap) { if (platform.getName().equalsIgnoreCase(QQ.NAME)) { if (MainApplication.isLogin()) { shareStatus = "yes"; sharePlatform = "qq"; getShareIntegral(); } } else { getShareIntegral(); } Toast.makeText(getApplication(), "分享成功", Toast.LENGTH_SHORT).show(); LogUtils.e("分享成功"); } @Override public void onError(Platform platform, int i, Throwable throwable) { LogUtils.e(throwable.getMessage()); } @Override public void onCancel(Platform platform, int i) { } }); platform.share(paramsToShare); } public Bitmap getViewBitmap(View comBitmap, int width, int height) { Bitmap bitmap = null; if (comBitmap != null) { comBitmap.clearFocus(); comBitmap.setPressed(false); boolean willNotCache = comBitmap.willNotCacheDrawing(); comBitmap.setWillNotCacheDrawing(false); // Reset the drawing cache background color to fully transparent // for the duration of this operation int color = comBitmap.getDrawingCacheBackgroundColor(); comBitmap.setDrawingCacheBackgroundColor(0); float alpha = comBitmap.getAlpha(); comBitmap.setAlpha(1.0f); if (color != 0) { comBitmap.destroyDrawingCache(); } int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY); comBitmap.measure(widthSpec, heightSpec); comBitmap.layout(0, 0, width, height); comBitmap.buildDrawingCache(); Bitmap cacheBitmap = comBitmap.getDrawingCache(); if (cacheBitmap == null) { Log.e("view.ProcessImageToBlur", "failed getViewBitmap(" + comBitmap + ")", new RuntimeException()); return null; } bitmap = Bitmap.createBitmap(cacheBitmap); // Restore the view comBitmap.setAlpha(alpha); comBitmap.destroyDrawingCache(); comBitmap.setWillNotCacheDrawing(willNotCache); comBitmap.setDrawingCacheBackgroundColor(color); } saveBitmap(imageZoom(bitmap)); return bitmap; } private static String getPath(String path) { File f = new File(path); if (!f.exists()) { f.mkdirs(); } return f.getAbsolutePath(); } private Bitmap imageZoom(Bitmap bm) { // 图片允许最大空间 单位:KB double maxSize = 200.00; // 将bitmap放至数组中,意在bitmap的大小(与实际读取的原文件要大) ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] b = baos.toByteArray(); // 将字节换成KB double mid = b.length / 1024; // 判断bitmap占用空间是否大于允许最大空间 如果大于则压缩 小于则不压缩 if (mid > maxSize) { // 获取bitmap大小 是允许最大大小的多少倍 double i = mid / maxSize; // 开始压缩 此处用到平方根 将宽带和高度压缩掉对应的平方根倍 // (1.保持刻度和高度和原bitmap比率一致,压缩后也达到了最大大小占用空间的大小) bm = zoomImage(bm, bm.getWidth() / Math.sqrt(i), bm.getHeight() / Math.sqrt(i)); } return bm; } public Bitmap zoomImage(Bitmap bgimage, double newWidth, double newHeight) { // 获取这个图片的宽和高 float width = bgimage.getWidth(); float height = bgimage.getHeight(); // 创建操作图片用的matrix对象 Matrix matrix = new Matrix(); // 计算宽高缩放率 float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // 缩放图片动作 matrix.postScale(scaleWidth, scaleHeight); Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width, (int) height, matrix, true); // iv_2.setImageBitmap(bitmap); // tv_2.setText(bitmap.getRowBytes() * bitmap.getHeight() + ""); return bitmap; } private Bitmap addBitmap(Bitmap first, Bitmap second, Bitmap thrid) { int width = Math.max(first.getWidth(), second.getWidth()); int height = first.getHeight() + second.getHeight() + thrid.getHeight(); Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); canvas.drawBitmap(first, 0, 0, null); canvas.drawBitmap(second, 0, first.getHeight(), null); canvas.drawBitmap(thrid, 0, first.getHeight() + second.getHeight(), null); return result; } public void saveBitmap(Bitmap mBitmap) { LogUtils.e(mBitmap.getByteCount()); String dir_path = Environment.getExternalStorageDirectory() + File.separator + "d1ev/"; File directory = new File(dir_path); File f = new File(directory, "share.png"); try { if (!directory.exists()) { directory.mkdir();//没有目录先创建目录 } f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block } FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (Exception e) { e.printStackTrace(); } mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); Log.e("!!!", "下载图片"); // Toast.makeText(RoutePlanMapActivity.this,"保存成功",Toast.LENGTH_SHORT).show(); try { fOut.flush(); } catch (IOException e) { e.printStackTrace(); } try { fOut.close(); } catch (IOException e) { e.printStackTrace(); } MediaStore.Images.Media.insertImage(getContentResolver(), mBitmap, "", ""); Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(new File(dir_path)); intent.setData(uri); getApplicationContext().sendBroadcast(intent); } public void zoomToSpan(List list) { if (list != null && list.size() > 0) { if (amap == null) return; // LatLngBounds bounds = LatLngBounds.builder().include(new LatLng(boundArray[1], boundArray[0])).include(new LatLng(boundArray[3], boundArray[2])).build(); // amap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10)); } } private LatLngBounds getLatLngBounds(List list) { LatLngBounds.Builder b = LatLngBounds.builder(); for (int i = 0; i < list.size(); i++) { b.include(new LatLng(Double.parseDouble(list.get(i).getPoi_wei()), Double.parseDouble(list.get(i).getPoi_jing()))); } return b.build(); } public void getAddress(final LatLonPoint latLonPoint) { RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 200, GeocodeSearch.AMAP);// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系 geocoderSearch.getFromLocationAsyn(query);// 设置同步逆地理编码请求 } @Override public void onRegeocodeSearched(RegeocodeResult result, int i) { if (i == 1000) { if (result != null && result.getRegeocodeAddress() != null && result.getRegeocodeAddress().getFormatAddress() != null) { // tv_address.setText(result.getRegeocodeAddress().getFormatAddress()); // tv_name.setText("[当前位置]"); // rl_now.setClickable(true); pl = result.getRegeocodeAddress().getPois(); if (tag.equals("start")) { tv_start.setText(pl.get(0).getTitle()); save_start_name = pl.get(0).getTitle(); } else if (tag.equals("end")) { tv_end.setText(pl.get(0).getTitle()); save_end_name = pl.get(0).getTitle(); } // adapter = new RouteSelectPointActivity.POIAdapter(); // list_poi.setAdapter(adapter); // list_poi.setEnabled(true); } } } @Override public void onGeocodeSearched(GeocodeResult geocodeResult, int i) { } private void getShareIntegral() { String url = MainApplication.url + "/zhannew/basic/web/index.php/member/insert-task?userid=" + MainApplication.userId; OkHttpUtils.get().url(url).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { LogUtils.e(response); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if ("01".equals(rtnCode)) { String plusScore = JsonUtils.getKeyResult(response, "plusScore"); if (!plusScore.equals("")) { if (sharePlatform.equals("qq")) { sharePoint = plusScore; } else { tv_point.setText(plusScore); rl_point.setVisibility(View.VISIBLE); rl_point.startAnimation(animation); new Handler().postDelayed(new Runnable() { public void run() { rl_point.setVisibility(View.GONE); } }, 1500); } } } else { } } }); } private void getRouteGuide() { String url = MainApplication.url + "/zhannew/basic/web/index.php/member/route-guide?userid=" + MainApplication.userId; OkHttpUtils.get().url(url).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { // Log.e(TAG, "onResponse: response="+response ); } }); } private void saveRoute(String json) { String url = MainApplication.url + "/zhannew/basic/web/index.php/question/create-guide?phone=" + MainApplication.userPhone + "&password=" + URLEncoder.encode(MainApplication.userPassword) + "&json_log=" + json + "&sign=" + MainMapActivity.getMD5(json) + "&id=" + save_id; OkHttpUtils.get().url(url).build().connTimeOut(5000).readTimeOut(5000).execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { Log.e(TAG, "onResponse: " + response); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if ("01".equals(rtnCode)) { save_id = JsonUtils.getKeyResult(response, "rtnMsg"); ToastUtil.showToast(getApplicationContext(), "保存成功", Toast.LENGTH_SHORT); } else { ToastUtil.showToast(getApplicationContext(), "保存失败", Toast.LENGTH_SHORT); } } }); } @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { MobclickAgent.onEvent(getApplicationContext(), "0310"); isHighWay = b; list_zhan.clear(); zhanDataList.clear(); routeOne.clear(); routeTwo.clear(); routeThree.clear(); zhan_num = 0; if (null != routeIds) { select = routeNum; amap.clear(); for (int i = 0; i < routeIds.length; i++) { AMapNaviPath path = (aMapNavi.getNaviPaths()).get(routeIds[i]); //你可以通过这个AMapNaviPath生成一个RouteOverLay用于加在地图上 routeOverLay = new RouteOverLay(amap, path, this); routeOverLay.setStartPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstarr))); routeOverLay.setEndPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstopr))); routeOverLay.setWayPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_zhanwei))); routeOverLay.addToMap(); routeOverlays.put(routeIds[i], routeOverLay); } if (!calculateSuccess) { Toast.makeText(this, "请先算路", Toast.LENGTH_SHORT).show(); return; } if (routeIndex >= routeIds.length) routeIndex = 0; //突出选择的那条路 for (RouteOverLay routeOverLay : routeOverlays.values()) { routeOverLay.setTransparency(0.3f); } routeOverlays.get(routeIds[routeNum - 1]).setTransparency(0.8f); //必须告诉AMapNavi 你最后选择的哪条路 aMapNavi.selectRouteId(routeIds[routeNum - 1]); // Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllTime() + "s", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[2]).getStrategy() + "z", Toast.LENGTH_SHORT).show(); final List nlll = (aMapNavi.getNaviPaths()).get(routeIds[routeNum - 1]).getCoordList(); // Toast.makeText(this, (aMapNavi.getNaviPaths()).get(routeIds[2]).getStrategy(), Toast.LENGTH_SHORT).show(); routeIndex++; chooseRouteSuccess = true; dialog.show(); new Handler().postDelayed(new Runnable() { @Override public void run() { getZhanPoint(nlll); } }, 500); } } @Override public View getInfoWindow(Marker marker) { LogUtils.e(marker.getTitle()); Bundle bundle = (Bundle) marker.getObject(); final zhan_list markerInfo = (zhan_list) bundle.getSerializable("info"); View infoWindow = getLayoutInflater().inflate(R.layout.evsdk_layout_infowindow, null); getZhanInfo(String.valueOf(markerInfo.getId()), markerInfo, marker, infoWindow); // routeShowPresenter.getSingleZhanInfo(String.valueOf(markerInfo.getId()), BaseConstants.DENZA_VERSION, infoWindow, marker); try { Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } return infoWindow; } @Override public View getInfoContents(Marker marker) { return null; } }