Browse Source

代码优化

huyuguo 4 years ago
parent
commit
31983f6f69

+ 9 - 228
app/src/main/java/com/electric/chargingpile/activity/RoutePlanMapActivity.java

@ -21,7 +21,9 @@ import android.os.Bundle;
21 21
import android.os.Environment;
22 22
import android.os.Handler;
23 23
import android.provider.MediaStore;
24
24 25
import androidx.appcompat.app.AlertDialog;
26
25 27
import android.util.Log;
26 28
import android.view.LayoutInflater;
27 29
import android.view.MotionEvent;
@ -137,8 +139,6 @@ import cn.sharesdk.wechat.friends.Wechat;
137 139
import cn.sharesdk.wechat.moments.WechatMoments;
138 140
import okhttp3.Call;
139 141
140
//import com.electric.chargingpile.util.TTSController;
141
142 142
/**
143 143
 * 创建时间:15/12/7 18:11
144 144
 * 项目名称:newNaviDemo
@ -153,7 +153,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
153 153
    NaviLatLng endLatlng;
154 154
    NaviLatLng startLatlng;
155 155
    NaviLatLng zhongLatlng;
156
    NaviLatLng zhongLatlng1;
157 156
    List<NaviLatLng> startList = new ArrayList<NaviLatLng>();
158 157
    List<NaviLatLng> endList = new ArrayList<NaviLatLng>();
159 158
    List<NaviLatLng> zhongList = new ArrayList<NaviLatLng>();
@ -164,25 +163,14 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
164 163
    private HashMap<Integer, RouteOverLay> routeOverlays = new HashMap<Integer, RouteOverLay>();
165 164
    private int routeIndex;
166 165
    private int[] routeIds;
167
    //    private TTSController ttsManager;
168 166
    private boolean chooseRouteSuccess;
169
    private boolean mapClickStartReady;
170
    private boolean mapClickEndReady;
171
    private Marker mStartMarker;
172
    private Marker mWayMarker;
173
    private Marker mEndMarker;
174 167
    private GeocodeSearch geocoderSearch;
175 168
    private boolean calculateSuccess;
176 169
    private String start_name, start_address, start_jing, start_wei, end_name, end_address, end_jing, end_wei;
177 170
    String poi_jing, poi_wei;
178
    private float minZoomLevel;
179
    private float maxZoomLevel;
180
    private UiSettings mUiSettings;
181
    TextView tv, tv_infowindow;
182 171
    private AMapLocationClient mlocationClient;
183 172
    private LocationSource.OnLocationChangedListener mListener;
184 173
    private AMapLocationClientOption mLocationOption;
185
    LatLng target = null;
186 174
    private Marker mMarkerCity = null;
187 175
    private MarkerOptions oocity = null;
188 176
    LatLng center;
@ -192,27 +180,20 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
192 180
    private List<Zhan> list_zhong = new ArrayList<Zhan>();
193 181
    private RoutePlanInfo routePlanInfo;
194 182
    private Zhan zhan;
195
    private RelativeLayout rl_route1, rl_route2, rl_route3, rl_submit, rela_paopao, rl_zhong;
183
    private RelativeLayout rl_route1, rl_route2, rl_route3, rela_paopao;
196 184
    private View view1, view2;
197 185
    private RouteOverLay routeOverLay;
198
    private ImageView iv_back, iv_zhong;
199
    private TextView detail_name, tv_fastNum, tv_slowNum, tv_charge, tv_service, tv_park, tv_cost_way, tv_zhong;
186
    private ImageView iv_back;
200 187
    String p1 = "", p2 = "", p3 = "";
201
    private Marker currentClickedMarker;
202
    private Marker detailMarker;
203 188
    private int select;
204 189
    private LoadingDialog dialog;
205
    private LinearLayout ll_paoxiang, ll_share_ui;
206
    private RelativeLayout ll_comment, tv_notice;
207
    private TextView tv_num, tv_daohang, tvOne, tvTwo, tvThree, tv_start, tv_end;
208
    private double bd_lon, bd_lat, bd_jing, bd_wei;
209
    private PopupWindow popupWindow;
210
    private View popupWindowView;
211
    private Button cancleButton;
190
    private LinearLayout ll_share_ui;
191
    private RelativeLayout tv_notice;
192
    private TextView tv_num, tv_start, tv_end;
212 193
    private ImageView mIvMarkerBgYes, iv_screen;
213 194
    private ScrollView sv;
214 195
    private View mMarkerViewYes;
215
    private TextView tv_iknow, tv_setting, tv_route_name, tv_route_fast, tv_route_slow, tv_route_costway, tv_distance, tv_screenShot;
196
    private TextView tv_iknow, tv_route_fast, tv_route_slow, tv_route_costway, tv_distance, tv_screenShot;
216 197
    private RelativeLayout rl_yinying, rl_infowindow, rl_details, rl_routebtn, rl_share;
217 198
    private boolean canRoute = false;
218 199
    private boolean canSave = false;
@ -222,15 +203,9 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
222 203
    private RoueteInfoAdapter roueteInfoAdapter;
223 204
    private float mLastTimeY;
224 205
    private TextView shaixuan_label;
225
226
    public void setEndLatlng(NaviLatLng endLatlng) {
227
        this.endLatlng = endLatlng;
228
    }
229
230 206
    private int zhan_num = 0;
231 207
    private String tag = "";
232 208
    private ImageView iv_setting, iv_screenShot;
233
    private String mTime = "";
234 209
    private List<Zhan> list_zhan = new ArrayList<Zhan>();
235 210
    ;
236 211
    private List<zhan_list> zhanDataList = new ArrayList<zhan_list>();
@ -254,7 +229,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
254 229
    private LinearLayout llOpen, ll;
255 230
    private RelativeLayout rlRouteTip, activity_route_plan;
256 231
    private MyAutoLayout ll_route;
257
    private Zhan newZhan;
258 232
    private int noNameCount = 0;
259 233
    private int haveNameCount = 0;
260 234
    private final String CAN_PAY_MARKER = "canPayMarker";
@ -281,9 +255,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
281 255
        dialog.show();
282 256
        mapView = (MapView) findViewById(R.id.mapview);
283 257
        mapView.onCreate(savedInstanceState);// 此方法必须重写
284
//        ttsManager = TTSController.getInstance(getApplicationContext());
285
//        ttsManager.init();
286
//        ttsManager.startSpeaking();
287 258
288 259
        // 初始化Marker添加到地图
289 260
        initViews();
@ -296,7 +267,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
296 267
297 268
    private void initViews() {
298 269
        ll = findViewById(R.id.ll);
299
//        llView = findViewById(R.id.ll_view);
300 270
        activity_route_plan = findViewById(R.id.activity_route_plan);
301 271
        ll_route = findViewById(R.id.ll_route);
302 272
        tvRouteTips = findViewById(R.id.tv_route_tips);
@ -328,7 +298,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
328 298
        tv_start = (TextView) findViewById(R.id.tv_start);
329 299
        tv_end = (TextView) findViewById(R.id.tv_end);
330 300
        rl_infowindow = (RelativeLayout) findViewById(R.id.rl_infowindow);
331
        tv_route_name = (TextView) findViewById(R.id.tv_route_name);
332 301
        tv_route_fast = (TextView) findViewById(R.id.tv_window_fast);
333 302
        tv_route_slow = (TextView) findViewById(R.id.tv_window_slow);
334 303
        tv_route_costway = (TextView) findViewById(R.id.tv_window_costway);
@ -355,23 +324,11 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
355 324
        });
356 325
357 326
        tv_zhan_num = (TextView) findViewById(R.id.tv_zhan_num);
358
//        tv_screenShot = (TextView) findViewById(R.id.tv_screenShot);
359
//        tv_screenShot.setOnClickListener(this);
360 327
        mMarkerViewYes = LayoutInflater.from(this).inflate(R.layout.view_custom_yes, null);
361 328
        mMarkerViewYes.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
362 329
                LinearLayout.LayoutParams.WRAP_CONTENT));
363 330
        mIvMarkerBgYes = (ImageView) mMarkerViewYes.findViewById(R.id.iv_icon);
364 331
        rela_paopao = (RelativeLayout) findViewById(R.id.rela_paopao);
365
        detail_name = (TextView) findViewById(R.id.detail_name);
366
        tv_fastNum = (TextView) findViewById(R.id.tv_fastNum);
367
        tv_slowNum = (TextView) findViewById(R.id.tv_slowNum);
368
        tv_charge = (TextView) findViewById(R.id.tv_charge);
369
        tv_service = (TextView) findViewById(R.id.tv_service);
370
        tv_park = (TextView) findViewById(R.id.tv_park);
371
        tv_cost_way = (TextView) findViewById(R.id.tv_cost_way);
372
        rl_zhong = (RelativeLayout) findViewById(R.id.rl_zhong);
373
        tv_zhong = (TextView) findViewById(R.id.tv_zhong);
374
        iv_zhong = (ImageView) findViewById(R.id.iv_zhong);
375 332
        ll_share_ui = (LinearLayout) findViewById(R.id.ll_share_ui);
376 333
377 334
@ -395,10 +352,7 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
395 352
        view1 = findViewById(R.id.view_1);
396 353
        view2 = findViewById(R.id.view_2);
397 354
398
        ll_paoxiang = (LinearLayout) findViewById(R.id.ll_paoxiang);
399
        ll_comment = (RelativeLayout) findViewById(R.id.ll_comment);
400 355
        tv_num = (TextView) findViewById(R.id.tv_num);
401
        tv_daohang = (TextView) findViewById(R.id.tv_daohang);
402 356
403 357
        tv_navigation_route = (TextView) findViewById(R.id.tv_navigation_route);
404 358
        tv_navigation_route.setOnClickListener(this);
@ -430,8 +384,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
430 384
                                showListData(routeOverlays, routeNum);
431 385
                                ivListStatus.setImageResource(R.drawable.icon_route_list_open);
432 386
                                tvOpen.setText("显示地图");
433
//                Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_route);
434
//                animation1.setDuration(2000);
435 387
                                lvRouteInfo.setVisibility(View.VISIBLE);
436 388
                                AnimatorStart();
437 389
                            } else {
@ -468,10 +420,7 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
468 420
            myLocationStyle.myLocationIcon(com.amap.api.maps.model.BitmapDescriptorFactory
469 421
                    .fromResource(R.drawable.point_icon));// 设置小蓝点的图标
470 422
            amap.setMyLocationStyle(myLocationStyle);
471
            mUiSettings = amap.getUiSettings();
472 423
            //获得地图的最大和最小缩放级别
473
            maxZoomLevel = amap.getMaxZoomLevel();
474
            minZoomLevel = amap.getMinZoomLevel();
475 424
            geocoderSearch = new GeocodeSearch(this);
476 425
            geocoderSearch.setOnGeocodeSearchListener(this);
477 426
            setUpMap();
@ -571,8 +520,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
571 520
572 521
            }
573 522
            if (list_zhong.size() > 0) {
574
//                tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_green);
575
//                tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_green);
576 523
                canRoute = true;
577 524
                canSave = true;
578 525
            }
@ -780,7 +727,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
780 727
        super.onDestroy();
781 728
        mapView.onDestroy();
782 729
        aMapNavi.stopNavi();
783
//        ttsManager.destroy();
784 730
        aMapNavi.destroy();
785 731
    }
786 732
@ -798,7 +744,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
798 744
        if (strategyFlag >= 0) {
799 745
            aMapNavi.calculateDriveRoute(startList, endList, null, strategyFlag);
800 746
            dialog.show();
801
//            ToastUtil.showToast(getApplicationContext(),"111",Toast.LENGTH_SHORT);
802 747
        }
803 748
    }
804 749
@ -820,13 +765,7 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
820 765
821 766
            //你可以通过对应的路径ID获得一条道路路径AMapNaviPath
822 767
            AMapNaviPath path = null;
823
//
824 768
            path = (aMapNavi.getNaviPaths()).get(routeIds[i]);
825
//            LogUtils.e(Arrays.toString(path.wayPointIndex));
826
//            LogUtils.e(path.getStepsCount());
827
//            LogUtils.e(Arrays.toString(path.getWayPointIndex()));
828
//            path.getSteps().get(1).getIconType();
829
830 769
            //你可以通过这个AMapNaviPath生成一个RouteOverLay用于加在地图上
831 770
            RouteOverLay routeOverLay = new RouteOverLay(amap, path, this);
832 771
            routeOverLay.setStartPointBitmap(drawableToBitamp(getResources().getDrawable(R.drawable.icon_newstarr)));
@ -842,22 +781,12 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
842 781
            routePlanInfo.setDistance(routeOverlays.get(routeIds[i]).getAMapNaviPath().getAllLength() + "");
843 782
844 783
            list.add(routePlanInfo);
845
846
//            routeOverlays.get(routeIds[i]).getAMapNaviPath().getSteps().get(i).getLength();
847
//            routeOverlays.get(routeIds[i]).getAMapNaviPath().getSteps().get(i).getIconType();
848
849 784
        }
850 785
        Log.e("list_size===", list.size() + "");
851 786
        updateView(list);
852 787
853 788
        routeOverlays.get(routeIds[0]).zoomToSpan();
854 789
        aMapNavi.selectRouteId(routeIds[0]);
855
856
857
//        LogUtils.e(routePointInfo.toString());
858
//
859
//        LogUtils.e(routePointInfoList.size());
860
861 790
        routeIndex = 0;
862 791
        calculateSuccess = true;
863 792
@ -907,9 +836,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
907 836
                routePointInfo.setRouteLength(getMToKm(String.valueOf(routeLength)));
908 837
                routePointInfo.setRouteTime(getSToHm(String.valueOf(routeTime)));
909 838
                routePointInfoList.add(routePointInfo);
910
911
//                LogUtils.e(routePointInfo.toString());
912
913 839
                routeLength = 0;
914 840
                routeTime = 0;
915 841
@ -1151,17 +1077,9 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1151 1077
1152 1078
        //必须告诉AMapNavi 你最后选择的哪条路
1153 1079
        aMapNavi.selectRouteId(routeIds[routeIndex]);
1154
//        Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[routeIndex]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[routeIndex]).getAllTime() + "s", Toast.LENGTH_SHORT).show();
1155
//        Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[routeIndex]).getStrategy() + "z", Toast.LENGTH_SHORT).show();
1156 1080
        List<NaviLatLng> nl = (aMapNavi.getNaviPaths()).get(routeIds[routeIndex]).getCoordList();
1157
//        Toast.makeText(this, nl.size() + "", Toast.LENGTH_SHORT).show();
1158
1159
1160 1081
        routeIndex++;
1161
1162 1082
        chooseRouteSuccess = true;
1163
//        getRouteZhan(nl);
1164
1165 1083
    }
1166 1084
1167 1085
    private void getRouteZhan(List<NaviLatLng> nl) {
@ -1220,17 +1138,8 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1220 1138
                String conditionSql = " ( status = '4' and suit_car != '特斯拉' )  ";
1221 1139
1222 1140
                RangConditionStr = RangConditionStr.substring(0, RangConditionStr.lastIndexOf('O'));
1223
1224
1225 1141
                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;
1226
1227
//                new Thread(new Runnable() {
1228
//                    @Override
1229
//                    public void run() {
1230 1142
                getZhanListData(sql);
1231
//                    }
1232
//                }).start();
1233
1234 1143
                count = 0;
1235 1144
                RangConditionStr = "";
1236 1145
            }
@ -1249,9 +1158,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1249 1158
                }
1250 1159
            }).start();
1251 1160
        }
1252
1253
//        initOver(list_zhan);
1254
1255 1161
    }
1256 1162
1257 1163
    private void getZhanData() {
@ -1369,12 +1275,9 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1369 1275
                continue;
1370 1276
            }
1371 1277
            Double zhan_jing = Double.parseDouble(zhanDataList.get(i).getPoi_jing());
1372
//            Log.e(TAG, "getZhanPoint: zhan_jing="+zhan_jing );
1373 1278
            Double zhan_wei = Double.parseDouble(zhanDataList.get(i).getPoi_wei());
1374
//            Log.e(TAG, "getZhanPoint: zhan_wei="+zhan_wei );
1375 1279
            for (int j = 0; j < rectList.size(); j++) {
1376 1280
                Double mMinLat = rectList.get(j).getMinLat();
1377
//                Log.e(TAG, "getZhanPoint: mMinLat="+mMinLat );
1378 1281
                Double mMinLon = rectList.get(j).getMinLon();
1379 1282
                Double mMaxLat = rectList.get(j).getMaxLat();
1380 1283
                Double mMaxLon = rectList.get(j).getMaxLon();
@ -1413,32 +1316,19 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1413 1316
        try {
1414 1317
            SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
1415 1318
1416
//            Log.e("sql===",sql);
1417 1319
            Cursor cursor = db.rawQuery(sql, null);
1418 1320
            Zhan zhan;
1419 1321
            while (cursor.moveToNext()) {
1420 1322
                zhan = new Zhan();
1421 1323
1422 1324
                zhan.setPoi_jing(cursor.getString(cursor.getColumnIndex("poi_jing")));
1423
//                Log.e(k+"==",cursor.getString(cursor.getColumnIndex("poi_jing")));
1424 1325
                zhan.setPoi_wei(cursor.getString(cursor.getColumnIndex("poi_wei")));
1425
//                Log.e(k+"==",cursor.getString(cursor.getColumnIndex("poi_wei")));
1426 1326
                zhan.setZhan_id(cursor.getString(cursor.getColumnIndex("id")));
1427 1327
                zhan.setStatus(cursor.getString(cursor.getColumnIndex("status")));
1428 1328
                zhan.setSuit_car(cursor.getString(cursor.getColumnIndex("suit_car")));
1429 1329
                zhan.setOwn_pay(cursor.getString(cursor.getColumnIndex("own_pay")));
1430 1330
                list_zhan.add(zhan);
1431 1331
            }
1432
//            Log.e("size===",list_db.size()+"");
1433
//            Log.e("list===", list.size() + "");
1434
1435
//            new Thread(new Runnable() {
1436
//                @Override
1437
//                public void run() {
1438
//                    initOver(list);
1439
//                }
1440
//            }).start();
1441
1442 1332
            cursor.close();
1443 1333
            db.close();
1444 1334
        } catch (Exception e) {
@ -1529,7 +1419,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1529 1419
                    p3 = my[2];
1530 1420
                }
1531 1421
1532
                Log.e("ssss", p1 + "---" + p2 + "---" + p3);
1533 1422
                for (int i = 0; i < list.size(); i++) {
1534 1423
                    if (!list.get(i).getPoi_wei().equals("") && !list.get(i).getPoi_jing().equals("")
1535 1424
                            && !String.valueOf(list.get(i).getId()).equals(p1) && !String.valueOf(list.get(i).getId()).equals(p2) && !String.valueOf(list.get(i).getId()).equals(p3)) {
@ -1540,9 +1429,7 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1540 1429
                            ll = new LatLng(Double.parseDouble(list.get(i).getPoi_wei()), Double.parseDouble(list.get(i).getPoi_jing()));
1541 1430
                        } else if (position <= 13) {
1542 1431
                            double dwei = Double.parseDouble(list.get(i).getPoi_wei());
1543
//                System.out.print("wei:"+l.get(i).getPoi_wei());
1544 1432
                            double djing = Double.parseDouble(list.get(i).getPoi_jing());
1545
//                System.out.println("jing:"+l.get(i).getPoi_jing());
1546 1433
                            getGaode(djing, dwei);
1547 1434
1548 1435
                            ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
@ -1680,21 +1567,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1680 1567
1681 1568
    }
1682 1569
1683
//    @Override
1684
//    public void onArriveDestination(NaviStaticInfo naviStaticInfo) {
1685
//
1686
//    }
1687
//
1688
//    @Override
1689
//    public void onArriveDestination(AMapNaviStaticInfo aMapNaviStaticInfo) {
1690
//
1691
//    }
1692
//
1693
//    @Override
1694
//    public void onCalculateRouteSuccess() {
1695
//
1696
//    }
1697
1698 1570
    @Override
1699 1571
    public void onCalculateRouteFailure(int errorInfo) {
1700 1572
@ -1795,12 +1667,10 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1795 1667
1796 1668
    public void chooseStart(View view) {
1797 1669
        Toast.makeText(this, "请在地图上点选起点", Toast.LENGTH_SHORT).show();
1798
        mapClickStartReady = true;
1799 1670
    }
1800 1671
1801 1672
    public void chooseEnd(View view) {
1802 1673
        Toast.makeText(this, "请在地图上点选终点", Toast.LENGTH_SHORT).show();
1803
        mapClickEndReady = true;
1804 1674
    }
1805 1675
1806 1676
    public void goToGPSActivity(View view) {
@ -1816,7 +1686,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1816 1686
1817 1687
    @Override
1818 1688
    public void activate(OnLocationChangedListener onLocationChangedListener) {
1819
//        Toast.makeText(getApplicationContext(), "activate", Toast.LENGTH_SHORT).show();
1820 1689
        mListener = onLocationChangedListener;
1821 1690
        if (mlocationClient == null) {
1822 1691
            mlocationClient = new AMapLocationClient(this);
@ -1826,7 +1695,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1826 1695
            //设置为高精度定位模式
1827 1696
            mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
1828 1697
            mLocationOption.setGpsFirst(true);
1829
//            mLocationOption.setOnceLocation(true);
1830 1698
            mLocationOption.setInterval(1500);
1831 1699
1832 1700
            //设置是否强制刷新WIFI,默认为强制刷新
@ -1866,32 +1734,14 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1866 1734
                } catch (NullPointerException e) {
1867 1735
                    e.printStackTrace();
1868 1736
                }
1869
//                ProfileManager.getInstance().setAtCity(getApplicationContext(), MainApplication.atCity);
1870 1737
                center = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude());
1871
//                Toast.makeText(getApplicationContext(), "!!!" + amapLocation.getLongitude() + "---" + amapLocation.getLatitude(), Toast.LENGTH_SHORT).show();
1872 1738
                mlocationClient.stopLocation();
1873 1739
                dialog.cancel();
1874 1740
1875 1741
                initDatas();
1876
//                Log.e("!@#$",amapLocation.getLatitude()+"```"+amapLocation.getLongitude());
1877
////                Toast.makeText(this, amapLocation.getAddress(), Toast.LENGTH_SHORT).show();
1878
////                Toast.makeText(this, amapLocation.getCity(), Toast.LENGTH_SHORT).show();
1879
//                ete("{\"fun\":\"timer\"}");
1880
//                if (isFirstLoc) {
1881
//                    //设置缩放级别
1882
//                    aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
1883
//                    //将地图移动到定位点
1884
//                    aMap.moveCamera(CameraUpdateFactory.changeLatLng(center));
1885
//
1886
//                    //点击定位按钮 能够将地图的中心移动到定位点
1887
//                    mListener.onLocationChanged(amapLocation);
1888
//                    isFirstLoc = false;
1889
//                }
1890
//                initDatas();
1891 1742
            } else {
1892 1743
                String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
1893 1744
                Log.e("AmapErr", errText);
1894
//                mLocationErrText.setVisibility(View.VISIBLE);
1895 1745
                Toast.makeText(this, errText, Toast.LENGTH_SHORT).show();
1896 1746
            }
1897 1747
        }
@ -1902,10 +1752,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
1902 1752
        amap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
1903 1753
        // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
1904 1754
        amap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
1905
//        aMap.moveCamera();
1906
//        amap.moveCamera(CameraUpdateFactory.zoomTo(14));
1907
1908
        Log.d("??", "!");
1909 1755
    }
1910 1756
1911 1757
    @Override
@ -2003,7 +1849,7 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2003 1849
                                for (int i = 0; i < changedScreenList.length; i++) {
2004 1850
                                    if (changedScreenList[i]) {
2005 1851
                                        String t = "";
2006
                                        if (i==0){
1852
                                        if (i == 0) {
2007 1853
                                            t = "红包站点";
2008 1854
                                        } else if (i == 1) {
2009 1855
                                            t = "免费停车";
@ -2029,12 +1875,8 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2029 1875
            case R.id.rl_route_tip:
2030 1876
                ivListStatus.setImageResource(R.drawable.icon_route_list_open);
2031 1877
                tvOpen.setText("显示地图");
2032
//                Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_route);
2033
//                animation1.setDuration(2000);
2034 1878
                lvRouteInfo.setVisibility(View.VISIBLE);
2035 1879
                AnimatorStart();
2036
2037
//                llOpenView.startAnimation(animation1);
2038 1880
                break;
2039 1881
            case R.id.ll_open:
2040 1882
                if (canRoute == false) {
@ -2044,8 +1886,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2044 1886
                        showListData(routeOverlays, routeNum);
2045 1887
                        ivListStatus.setImageResource(R.drawable.icon_route_list_open);
2046 1888
                        tvOpen.setText("显示地图");
2047
//                Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_route);
2048
//                animation1.setDuration(2000);
2049 1889
                        lvRouteInfo.setVisibility(View.VISIBLE);
2050 1890
                        AnimatorStart();
2051 1891
@ -2075,7 +1915,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2075 1915
                dialog.show();
2076 1916
                new Handler().postDelayed(new Runnable() {
2077 1917
                    public void run() {
2078
//                        showSimpleBottomSheetGrid();
2079 1918
                        mapScreenShot();
2080 1919
                    }
2081 1920
                }, 1000);
@ -2123,12 +1962,7 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2123 1962
2124 1963
                    //必须告诉AMapNavi 你最后选择的哪条路
2125 1964
                    aMapNavi.selectRouteId(routeIds[0]);
2126
//                Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllTime() + "s", Toast.LENGTH_SHORT).show();
2127
//                Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getStrategy() + "z", Toast.LENGTH_SHORT).show();
2128 1965
                    final List<NaviLatLng> nl = (aMapNavi.getNaviPaths()).get(routeIds[0]).getCoordList();
2129
//                Toast.makeText(this, (aMapNavi.getNaviPaths()).get(routeIds[0]).getStrategy(), Toast.LENGTH_SHORT).show();
2130
2131
2132 1966
                    routeIndex++;
2133 1967
2134 1968
                    chooseRouteSuccess = true;
@ -2250,13 +2084,7 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2250 2084
2251 2085
                    //必须告诉AMapNavi 你最后选择的哪条路
2252 2086
                    aMapNavi.selectRouteId(routeIds[2]);
2253
//                Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllTime() + "s", Toast.LENGTH_SHORT).show();
2254
//                Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[2]).getStrategy() + "z", Toast.LENGTH_SHORT).show();
2255 2087
                    final List<NaviLatLng> nlll = (aMapNavi.getNaviPaths()).get(routeIds[2]).getCoordList();
2256
2257
//                Toast.makeText(this, (aMapNavi.getNaviPaths()).get(routeIds[2]).getStrategy(), Toast.LENGTH_SHORT).show();
2258
2259
2260 2088
                    routeIndex++;
2261 2089
2262 2090
                    chooseRouteSuccess = true;
@ -2286,7 +2114,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2286 2114
                        MobclickAgent.onEvent(getApplicationContext(), "0308");
2287 2115
                        if ("0".equals(save_id)) {
2288 2116
                            if (noNameCount == haveNameCount)
2289
//                                LogUtils.e(noNameCount+"---"+haveNameCount);
2290 2117
                                creatSaveData();
2291 2118
                        } else {
2292 2119
                            AlertDialog.Builder builder = new AlertDialog.Builder(RoutePlanMapActivity.this);
@ -2297,7 +2124,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2297 2124
                                @Override
2298 2125
                                public void onClick(DialogInterface dialog, int which) {
2299 2126
                                    if (noNameCount == haveNameCount)
2300
//                                        LogUtils.e(noNameCount+"---"+haveNameCount);
2301 2127
                                        creatSaveData();
2302 2128
                                }
2303 2129
                            });
@ -2317,7 +2143,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2317 2143
                } else {
2318 2144
                    if (select == 0) {
2319 2145
                        exchangeView(1);
2320
//                        amap.clear();
2321 2146
                        for (int i = 0; i < routeIds.length; i++) {
2322 2147
                            AMapNaviPath path = (aMapNavi.getNaviPaths()).get(routeIds[i]);
2323 2148
                            //你可以通过这个AMapNaviPath生成一个RouteOverLay用于加在地图上
@ -2344,22 +2169,12 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2344 2169
2345 2170
                        }
2346 2171
                        routeOverlays.get(routeIds[0]).setTransparency(0.8f);
2347
2348
2349 2172
                        //必须告诉AMapNavi 你最后选择的哪条路
2350 2173
                        aMapNavi.selectRouteId(routeIds[0]);
2351
//                Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllTime() + "s", Toast.LENGTH_SHORT).show();
2352
//                Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getStrategy() + "z", Toast.LENGTH_SHORT).show();
2353 2174
                        List<NaviLatLng> nnll = (aMapNavi.getNaviPaths()).get(routeIds[0]).getCoordList();
2354
//                Toast.makeText(this, (aMapNavi.getNaviPaths()).get(routeIds[0]).getStrategy(), Toast.LENGTH_SHORT).show();
2355
2356
2357 2175
                        routeIndex++;
2358 2176
2359 2177
                        chooseRouteSuccess = true;
2360
//                        if (nnll != null) {
2361
//                            getRouteZhan(nnll);
2362
//                        }
2363 2178
                    }
2364 2179
                    if (chooseRouteSuccess && calculateSuccess) {
2365 2180
                        MobclickAgent.onEvent(getApplicationContext(), "0309");
@ -2392,12 +2207,7 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2392 2207
2393 2208
                break;
2394 2209
            case R.id.iv_back:
2395
//                tag = 0;
2396 2210
                finish();
2397
//                amap.setLocationSource(this);// 设置定位监听
2398
//            amap.setMyLocationEnabled(true);// 是否可触发定位并显示定位层
2399
////            ?aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
2400
//            mlocationClient.startLocation();
2401 2211
                break;
2402 2212
            default:
2403 2213
                break;
@ -2594,7 +2404,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2594 2404
                        }
2595 2405
                        if (strategyFlag >= 0) {
2596 2406
                            aMapNavi.calculateDriveRoute(startList, endList, zhongList, strategyFlag);
2597
//                                                Toast.makeText(getApplicationContext(), "策略:" + strategyFlag, Toast.LENGTH_LONG).show();
2598 2407
                        }
2599 2408
                        rl_infowindow.setVisibility(View.GONE);
2600 2409
                    } else {
@ -2726,34 +2535,6 @@ public class RoutePlanMapActivity extends Activity implements LocationSource, AM
2726 2535
2727 2536
    }
2728 2537
2729
    private void getBaidu(Double jing, Double wei) {
2730
        double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
2731
        double x = jing;
2732
        double y = wei;
2733
        double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
2734
        double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
2735
        bd_lon = z * Math.cos(theta) + 0.0065;
2736
        bd_lat = z * Math.sin(theta) + 0.006;
2737
    }
2738
2739
    private boolean isAvilible(Context context, String packageName) {
2740
        //获取packagemanager
2741
        final PackageManager packageManager = context.getPackageManager();
2742
        //获取所有已安装程序的包信息
2743
        List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
2744
        //用于存储所有已安装程序的包名
2745
        List<String> packageNames = new ArrayList<String>();
2746
        //从pinfo中将包名字逐一取出,压入pName list中
2747
        if (packageInfos != null) {
2748
            for (int i = 0; i < packageInfos.size(); i++) {
2749
                String packName = packageInfos.get(i).packageName;
2750
                packageNames.add(packName);
2751
            }
2752
        }
2753
        //判断packageNames中是否有目标程序的包名,有TRUE,没有FALSE
2754
        return packageNames.contains(packageName);
2755
    }
2756
2757 2538
    public static Bitmap getBitmapFromView(View view) {
2758 2539
        view.destroyDrawingCache();
2759 2540
        view.measure(View.MeasureSpec.makeMeasureSpec(0,