电子产业一站式赋能平台

PCB联盟网

搜索
查看: 253|回复: 0
收起左侧

基于Mobile SDK V4版固件开发大疆无人机手机端遥控器(3)

[复制链接]

1001

主题

1001

帖子

8805

积分

高级会员

Rank: 5Rank: 5

积分
8805
发表于 2023-6-15 12:00:00 | 显示全部楼层 |阅读模式

fyzoxtpof3t6406114041.gif

fyzoxtpof3t6406114041.gif
" p1 w' Z& x6 K
点击上方蓝色字体,关注我们
* D. j6 {9 M& Q8 Y" q+ l
( ^1 r) |. Y; g! U
( L; Y  C3 i" a2 k$ B第三篇文章准备单独拿出来写,因为在大疆为人机的所有功能中,航线规划的功能最为复杂,也相当的繁琐,这里需要说仔细一点,可能会将代码进行多步分解。
0 b: R! h7 N1 _/ J- C8 B# B' J1
1 V1 W/ g- Z6 @1 C6 R3 ?* t航线规划8 F' {/ I& k) {+ q3 f0 Z
航线打点 * a: w! v' R1 n1 n1 y8 _/ D

& |3 b# B: f5 D$ W在地图中手动选择点位选择完成航线打点;若打点位置错了可进行点位删除。& r) v' U. `4 w$ b# Q4 p) z

5r4spa25bvt6406114142.png

5r4spa25bvt6406114142.png
! t+ d3 ^" B& v& w- X
( [3 [. V+ k2 @7 b# s
航点设置 ; v% [! P: J/ _
+ |2 t0 G5 |) p0 U7 n! A! E
可对航线点位进行设置,如飞行高度,速度(慢速:3m/s;中速: 7m/s;高速:10 m/s)、任务结束后操作及航向,点击[设置]按钮完成设置。
  q" A6 i3 X& f* v6 X

wzh4hjsephy6406114242.png

wzh4hjsephy6406114242.png
- ?  f: Q: c) V+ j8 I
设置完成后会显示总距离及飞行总时间。
* G0 ^4 i5 w6 i( {" s4 W

umdsyiqt0456406114342.png

umdsyiqt0456406114342.png

) }' c: r4 l: v9 l! {
4 z/ r! Z! s: ~; C( I航线上传
1 v& w; k" I% V+ D8 b  y3 D3 @( D/ O. b' h1 {1 {4 l6 D8 w3 J/ `& C" J
点击[上传]按钮,进行航线上传。可以进入本地存储中选择航线文件进行上传,航线文件为 .kml结尾。( p. y9 ~( m! ]

3p4bhoheq4f6406114442.png

3p4bhoheq4f6406114442.png
+ w& \$ g% `. v1 @$ J+ x. q
, A' K5 `% I$ O
航线执行   O! O+ u) G+ M' t1 _; Y
$ C& _& T8 [" W
点击 [开始]按钮,则可对航线进行执行。若中途需要暂停也可点击[暂停]安装进行暂停操作。' M1 r9 W" C. K0 x3 {5 M1 ]" X

zpfhgf3xppn6406114543.png

zpfhgf3xppn6406114543.png

6 Z' Y- n+ M) L$ \5 ?* i
2 D3 e: k+ i* S6 @9 W$ m6 H) I' z! \1 @航线管理1 P4 N; w) g& U5 K/ U( N
) F! T! I8 e& l7 M
按钮即可进入航线管理界面。" `, C, X6 A: D# s/ C
7 |) E8 e: f: u/ f: i! L6 f

dhtzr1c1c056406114643.png

dhtzr1c1c056406114643.png
2 f+ u  X+ n" R7 R

6 G* }- Y9 b) |' d获取航线
+ U3 e6 d' A8 [1 m) H. e/ `  K+ R! Q- m' K- V
点击[获取]按钮,即可将航线信息展示到地图界面中。
' r( h) R6 l& l, Y  w
- O  }2 c+ H+ K2 b( q: j1 q
% o  }* u( @6 l* J( R  h  \% [/ F2
/ n  X) A" K* J1 J0 W" N主要功能代码) ^+ L* j  [6 \" n4 H
创建activity_setting_route.xml及SettingRouteActivity文件。
" A& @* G. d4 e" @5 ~, Z

3 v: e& }. ?6 c
% m/ I; e' Z. dactivity_setting_route.xml7 o" R4 u+ Z6 s4 l- N

! ?2 w# \+ F8 D6 LLinearlayout xmlns:android="http://schemas.android.com/apk/res/android"
' B( a. h, q; `- `    xmlns:app="http://schemas.android.com/apk/res-auto"7 M0 t8 ^( m/ ~# W3 C/ o
    xmlns:tools="http://schemas.android.com/tools"7 o, ^; d0 F) x% F, k
    android:layout_width="match_parent"1 S- {3 v! K/ h1 h. f5 g# ]
    android:layout_height="match_parent". E5 P" Z: {  k2 s
    android:orientation="vertical"3 w$ a; i: M% @- U  `% i; L, X7 U% Y
    tools:context=".ui.SettingRouteActivity">' n! Q* B( ]9 ~+ q) k; h
    include9 _+ u' ^; Y! r7 I' G" ]  @
        android:id="@+id/layout_route"7 m3 R  g" u/ S+ m7 G
        layout="@layout/activity_toolbar">include>
/ f7 A# O; O) ~( C/ ~- F    RelativeLayout
. b8 O1 m6 ~4 I9 `) w        android:layout_width="match_parent"
! c3 ^$ z5 `8 k- \* N        android:layout_height="match_parent">
, W4 d" C% g. r$ B) u" X. [: ?1 l6 H        com.amap.api.maps.MapView
& U& _2 I9 D* ]" Y1 |% ^4 U            android:id="@+id/map"/ h) X* R7 T% }3 |
            android:layout_width="match_parent"
1 O8 Q4 c; D  U- A3 q4 z& K            android:layout_height="match_parent" />
7 `2 H" t/ x5 F+ Z6 ?        LinearLayout
5 N+ ], H6 p2 c% |# R            android:layout_width="wrap_content"
7 h0 V! V) n0 g8 L+ p5 B5 O            android:layout_height="wrap_content"
6 K6 t2 |* v$ R% k$ C% S9 \4 O            android:layout_alignParentTop="true"3 e$ B+ C% G: q# o! O) Z8 N
            android:layout_centerInParent="true"% G: z  s. D" Q2 q
            android:layout_marginTop="5dp">8 W* k/ c% ?: B8 K7 c
            Button
# S  [2 w7 C% o; m0 {( b; r                android:id="@+id/btn_delete"
0 y! R5 |' w/ u2 r6 E1 R# r  i                android:layout_width="60dp"
3 U! e, P8 T# z) v                android:layout_height="30dp"+ j8 u$ Y/ k, v5 p- ~' D
                android:visibility="gone"
( r1 N5 X" x: y! ]8 _7 b) h9 B                android:text="删除"
; D  L6 Y) i" m                android:textColor="@color/white"
5 j* N4 J* _# B                android:background="@drawable/button_task_background">Button>9 q; H/ ]' x! Z6 I7 k' x1 {( _% n
            Button
: \& J4 k4 [  {; _: l                android:id="@+id/btn_finish"
: ^' Y" ~3 `2 W  w4 Q( C: v                android:layout_width="60dp"
0 U. P) \; \8 G# a* h5 n. c                android:layout_height="30dp"
3 |5 F/ |4 D3 D                android:visibility="gone"$ W5 k; f* o# O1 C7 n
                android:textColor="@color/white"
! t- l' L; V! ~1 T# `4 {                android:background="@drawable/button_task_background"
) a8 r1 a2 b& O4 e  X: I                android:text="完成">Button>: _2 f, J' b7 ?; S  Y/ o( d  P2 w
            Button
  y# f$ R8 F- U: P  S- h. T, \                android:id="@+id/btn_setting"
- c- V* W: I$ v4 B% n3 V                android:layout_width="60dp"1 l" s+ Q3 ?8 f" p( A4 H& w
                android:layout_height="30dp"1 f* k% o4 [# `. _  N2 I+ J
                android:visibility="gone"* W& i( M# z$ F; y  p; E
                android:textColor="@color/white"6 b* i! j% o  K$ ]" F" {
                android:background="@drawable/button_task_background"5 E3 Z  l" m2 Y/ U6 A3 U
                android:text="设置">Button>
* V; j5 \3 E) Q9 e            Button8 a4 }  T8 g5 q( _5 ]- L/ M
                android:id="@+id/btn_upload"
" v9 f* _  Q' k/ F                android:layout_width="60dp"9 r; O& x  i! f( Y! Z
                android:layout_height="30dp". N4 d0 ~. x. i6 E4 j! y- p
                android:visibility="gone"
9 u3 h; ~8 L: R4 q' c" H                android:textColor="@color/white", F1 r, y) H, v6 \
                android:background="@drawable/button_task_background"4 I% @9 D+ l0 j" d
                android:text="上传">Button>
9 O( @; s+ F7 `9 d5 O9 x            Button7 g6 j# `7 f3 K! u
                android:id="@+id/btn_start"5 x9 ~+ j& e; R8 l
                android:layout_width="60dp"* \: Q, C; u) u. f! \) g
                android:layout_height="30dp"
5 j; ]7 P+ n1 o3 ~" W. r                android:visibility="gone"" ^7 b1 i. V' L5 J' q
                android:textColor="@color/white"
+ G& v2 D( y1 o; R                android:background="@drawable/button_task_background"" s' m/ @. k4 X8 M; I' k
                android:text="开始">Button>
' ]* h& P$ h2 o; v2 Y            Button0 c# \4 f6 o' _) B
                android:id="@+id/btn_stop"6 N, @2 \& R- W; L5 I
                android:layout_width="60dp"
2 }/ G1 |# X# B8 J- }: Q& Y/ Z; o                android:layout_height="30dp"" k! B0 w9 q- Y
                android:visibility="gone") z6 ~) }. p! f% a7 U
                android:textColor="@color/white"
2 z" R# K" J1 l                android:background="@drawable/button_task_background"& Z5 m$ k9 q7 O" `& J
                android:text="暂停">Button>
# V  T4 H* @/ ^/ |# P3 X: \: V        LinearLayout>
% X! A9 ~% f) p9 O        LinearLayout
- S5 e9 n5 ]3 ~5 ^+ L            android:id="@+id/ll_information"
# i4 W$ G% S0 w7 F            android:layout_width="wrap_content"
# _3 N3 l! k9 C8 [0 n7 Q            android:layout_height="wrap_content"
/ G- V& }5 s/ p            android:layout_alignParentBottom="true"
" B# A+ B; K+ A: E            android:layout_centerInParent="true": j4 V& n( P  ?
            android:layout_marginBottom="5dp", |5 \( b; k+ `
            android:padding="10dp"
( N) H) a! H* [, E            android:visibility="gone"
5 P) M. U. E& ]- D5 C1 `            android:background="@color/color_nav_Item_unselected">
9 B/ Y1 V0 ^9 B8 X! \) f            TextView& D! G4 u7 ^8 Q4 }& M0 W
                android:id="@+id/tv_height"; h( i7 ^$ S# P: q8 w/ V% H2 J
                android:layout_width="wrap_content"
6 l9 S8 X& j  E  v+ B4 v& a                android:layout_height="wrap_content"* ]% `4 m& ^% T! P( U; E
                android:text="高度:"- W1 @4 a, O- {1 {" A
                android:textColor="@color/white"
; Z/ M. x/ f0 r9 |                >TextView>
, ~- O/ e4 x: j9 H            TextView9 |3 B+ E9 J8 ]+ t
                android:id="@+id/tv_speed"7 a9 N8 h- A9 T4 f' E9 I
                android:layout_width="wrap_content"
8 b% ~' T0 X7 Y9 G) g                android:layout_height="wrap_content"
) o# D" ?/ }( M4 R: E# _  S                android:text="速度:"( ^7 s, i9 M/ O7 r) }0 r" y
                android:textColor="@color/white"" ?8 F* T; X2 z; d
                android:layout_marginLeft="10dp"
2 b( o) u3 y/ L  X8 g; Z                >TextView>
( E; l7 L+ V" n1 s* f            TextView/ S( s+ e9 w: S* g: N, ?* m8 f( w% _
                android:id="@+id/tv_count"* s$ i1 D& O' ?9 f8 p
                android:layout_width="wrap_content"1 j& J. z, ]# m( t+ ~4 T1 Z# h
                android:layout_height="wrap_content"
$ @1 X4 ]" j6 f5 B1 p                android:text="航点数:". V+ s8 z* o) S; Q2 V- A
                android:textColor="@color/white"
9 J9 `1 N' O3 w0 J                android:layout_marginLeft="10dp"* h4 f! M4 D8 i! [) c) {# Z  U
                >TextView>& r! m. q4 q! T2 y7 c1 t- I0 v
            TextView. n2 c7 f# h+ |" J' B$ g7 A* a6 C
                android:id="@+id/tv_distance"( V' T- p0 F! B0 B6 z
                android:layout_width="wrap_content"3 Q( i4 z- H6 B& r6 {2 K% y
                android:layout_height="wrap_content"
2 u- h+ z" B; v; m4 d) W                android:text="总距离:"
: B! w7 G+ r  B                android:textColor="@color/white"7 Y9 f: {4 \' `3 L
                android:layout_marginLeft="10dp"
* b& F; D/ I- ~6 X+ e# o* E: A, {                >TextView>& ]8 p" Q0 B0 `
            TextView
# |. k! }0 h2 w1 \                android:id="@+id/tv_time"
* S: d: U) r# \, ~  [$ U                android:layout_width="wrap_content"
+ ?8 T/ a8 R2 F; s1 g2 _* c                android:layout_height="wrap_content"  f5 U4 V# O  K! L& }. }
                android:text="总时间:"3 x! ^& f5 y0 }% m9 O; q7 g
                android:textColor="@color/white"1 \. P( L. X2 p4 c% n/ W* T
                android:layout_marginLeft="10dp"
) m5 ^1 O. s. B                >TextView>$ [4 L/ u( j  F5 P9 p$ e( v) i
        LinearLayout>! P* o7 X# M! i! `. D
    RelativeLayout>
7 ^- X  _1 F0 d. T; PLinearLayout>5 z* v- v# f0 _, U
SettingRouteActivity
+ ]; T2 R$ R# \/ _" S% \( V" }! r. N: y: u9 c" J* a( C4 `
public class SettingRouteActivity extends BaseActivity implements AMap.OnMarkerClickListener, View.OnClickListener, AMap.OnMapClickListener, LocationSource, AMapLocationListener, AMap.InfoWindowAdapter {9 V# m6 X/ }& ~6 V
    @BindView(R.id.layout_route)
; n3 \% ]: X* {( d2 x8 A; S        View mViewLayoutToolbar;
4 d% @7 f: z8 K: V        @BindView(R.id.ll_route)# \% K- J8 u( ~+ |+ k* T( z! l* p
        LinearLayout mLinearLayout;' ?4 b. K* K. Y3 |$ i8 r. F
        @BindView(R.id.tv_toolbar_title)
- }5 d8 z# j7 I+ N" ?) D+ c! ?/ R        TextView mTextViewToolbarTitle;
, K# X" ^5 J) L* S    //    @BindView(R.id.map). c- z: t3 e5 G' e/ m
    //    MapView mMapView;
& }; o$ P+ d7 J- _  a* y        @BindView(R.id.btn_delete)% a, Q8 t5 G0 R4 t4 |
        Button mButtonDelete;
; h, z0 S3 ]% e" N. B3 t3 ~* v' y        @BindView(R.id.btn_finish)9 a: M+ T% K+ F
        Button mButtonFinish;
# Z: u! t- |% i        @BindView(R.id.btn_setting)  T: C% h. D, J1 \) S) U
        Button mButtonSetting;) K3 S1 }" @# F1 t, v8 A  w0 ]
        @BindView(R.id.btn_upload)1 P7 t* ?, W* }# D! U. S
        Button mButtonUpload;; z3 }' z+ U" ^8 `  G+ Y
        @BindView(R.id.btn_start)
; p. ?0 H$ {1 z4 I9 ?        Button mButtonStart;
7 x+ j! @  G0 K, n        @BindView(R.id.btn_stop)
; Q: \* v- E0 C2 O# _* ]; ^        Button mButtonStop;) b* q+ G  p; u) Z
        @BindView(R.id.ll_information)* I# ?0 d( }  ?2 `# H
        LinearLayout mLinearLayoutInformation;' W5 K2 }  z# o, _0 \& t0 a
        @BindView(R.id.tv_height)
4 {0 L7 F' T/ R4 Y) b5 n        TextView mTextViewHeight;% l% e# }9 {$ X" A6 O
        @BindView(R.id.tv_speed)
9 c( c3 ]; n9 o4 r/ U- y        TextView mTextViewSpeed;. b+ ]6 C: _1 S" n$ i
        @BindView(R.id.tv_count)
* x/ l: \: x6 }, m" M# z        TextView mTextViewCount;
3 ]% z; b# I& T( T* p& x* E        @BindView(R.id.tv_distance)( x4 Z# m# l& y3 N. O
        TextView mTextViewDistance;
* X( O" c+ U+ y1 Z        @BindView(R.id.tv_time)  m4 a; R' d3 L, T6 A
        TextView mTextViewTime;8 I0 k; m$ u, A9 N5 c
        private MapView mMapView;" Q" s, x+ }3 `- I2 C, q
        private OnLocationChangedListener mListener;
7 B- H8 M: [# o2 Y1 u1 T        private AMapLocationClient mlocationClient;
: \$ s2 G/ f0 I7 I        private AMapLocationClientOption mLocationOption;
" ]" C* h7 g; F% @; s        private double D_latitude, D_longitude;
* b& v3 D: g/ |# T9 m        private UiSettings mUiSettings;
2 c% e+ e* f6 M( s# F: _        private AMap aMap;1 r5 t9 b" ]& W: A
        private Marker droneMarker = null;
. K+ ]2 v6 {" ?        private float altitude = 100.0f;
: s& j; G0 v. y* z- e        private float mSpeed = 10.0f;# K8 s1 {. g0 u& [/ V8 ~
        private boolean isAdd = false;
" i7 o1 b( p6 G. q/ @: n        private final Map[I] mMarkers = new ConcurrentHashMap[I]();4 l( G* m9 x3 |6 d3 F
        private Marker mClickMarker;
6 n$ ?$ s( e; E1 p3 K% v        private List waypointList = new ArrayList();
. O8 U( y% u2 r* ^        private List mLatLng = new ArrayList();4 q! ]7 X- [# C+ n8 I" O' N! u
        private List mPointInfo = new ArrayList();
7 n+ R! U/ A" O        public static WaypointMission.Builder waypointMissionBuilder;
1 q, o5 |9 {7 H* ]3 C+ i+ ]3 z        private FlightController mFlightController;% x1 p% q1 v, s" ~5 d, O2 p# g& }
        private WaypointMissionOperator instance;( `$ w1 N% o/ M
        private WaypointMissionFinishedAction mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;1 A! {. i$ L7 c$ B+ T
        private WaypointMissionHeadingMode mHeadingMode = WaypointMissionHeadingMode.AUTO;: e, F# N* Z, b
        private SQLiteHelper mSQLiteHelper;
6 c) \% h/ |5 ~( ~6 X        private String FinishedAction, HeadingMode;. ^: a- q$ W# Q- ?- J- T# J: C
        //自定义窗体
9 d! B) j/ s8 N- O        View infoWindow = null;# g4 {! _" r* Q1 v! W
        int speed_RG_id = 0;
1 j, J3 F) ?/ }5 S        int actionAfterFinished_RG_id = 0;
: F' ^& _; f& `        int heading_RG_id = 0;6 U) V) [" r- N8 U2 f" ^5 r
        //kim3 T2 a& b1 J6 i
        static ReadKml readKml = new ReadKml();
& ]- h- B0 V4 G5 z/ g        private static List sampleList = readKml.getCoordinateList();* @, N! j3 I3 C7 I% V) Y- B: K# @
        @Override- O* N( C( p9 e
        public void initViews() {
9 q5 c5 u; P! F( M            mLinearLayout.setVisibility(View.VISIBLE);
5 s% O  @* X2 @$ f% w# `; I            mTextViewToolbarTitle.setText("航线规划");
% Z5 o( N. @5 X. M& v! v            IntentFilter filter = new IntentFilter();# L9 Q& ]. `0 D, p
            filter.addAction(ReceiverApplication.FLAG_CONNECTION_CHANGE);
. w' s* y# G/ t1 l: ?# o            registerReceiver(mReceiver, filter);" ?! z& A5 p5 E8 J# t! \
            mMapView = findViewById(R.id.map);1 T( d1 s4 r+ m  y, Q4 h: F7 F- F
            mMapView.onCreate(InstanceState);7 `: E% O8 k! p( ~* }9 A6 o
            initMapView();
, M  }0 H" J( S5 c            addListener();  q- D  M3 h! {: W# q
            onProductConnectionChange();3 ]. S0 G' i* n* B+ u
        }
( S4 d0 F& c6 }        @Override
  c1 H; T7 Q3 V        protected void onResume() {
4 A  [4 h( v; @6 q6 I: X+ v! h            super.onResume();' C7 F. o8 x* H6 Y. J
            initFlightController();: }8 Q4 O( N3 @9 A, B) P# N! h
            mMapView.onResume();
+ O  W/ B5 Q  A+ k/ k1 S6 I8 K        }$ U) n* I" C" H. `
        /**" I  r" L% t0 A4 p( `: T' e0 c
         * 方法必须重写6 k$ s8 A# ]: \! E3 l% e7 K4 a/ O
         */
7 A' \0 N  a$ g( ]. i  Y        @Override; F) x* C1 Z. d$ y" X
        protected void onSaveInstanceState(Bundle outState) {
/ u2 E$ y( o+ @% V) d# N5 M# S            super.onSaveInstanceState(outState);
% V3 H7 l, |* ?. b            mMapView.onSaveInstanceState(outState);' S) e1 R+ J" }5 {
        }+ f$ r1 D) X7 Y' z
        @Override
2 X' K8 P. F) \+ r        protected void onPause() {+ K. j# q5 L7 S6 V
            super.onPause();
8 I2 f7 |+ C( q; h! P9 a            mMapView.onPause();
* B' F' h9 D/ r% B$ {            deactivate();$ Y; _1 _  ~+ |8 K: _
        }
6 J  n( i0 V/ e9 ]3 S/ M        @Override
8 J% H. W; Q) ?        protected void onDestroy() {
# m* o( \9 L) j. t0 \' Z% ?8 ~+ }! A            super.onDestroy();" \! \8 F! U" t$ l# L3 ~. O
            unregisterReceiver(mReceiver);* Q' ]. [( D3 y- n
            removeListener();
# K. n, O$ B4 K            mMapView.onDestroy();. t+ c( r& Y2 x
            if (null != mlocationClient) {7 G- H5 a( o* T' _5 x
                mlocationClient.onDestroy();8 o1 ^& U- t8 S* {# P: t  l
            }
0 p% k; z# x( x. k( w2 n: U1 a        }$ c9 T, C% E, q
        @Override% }% w$ ~  |$ i' f7 s
        public void initDatas() {. h. Q( m7 ^! E0 x' `2 P+ B3 M
        }
5 [7 c9 Z0 ]' d) U, k; l, {' a# {        @Override
2 ^- ^$ P/ b/ E$ F$ K6 H4 s        protected void requestData() {" m9 D! e$ ]3 P  ~
        }+ ?( l& N3 ]) C1 K
        private void initMapView() {6 `' V8 j! b$ ]' n- z7 g) p
            if (aMap == null) {
( Y) M" B% Z, l4 k                aMap = mMapView.getMap();
$ f6 }9 R( j. C+ d" ~% ~                mUiSettings = aMap.getUiSettings();
4 M& M$ ~9 e& _1 N0 W) O2 i8 d                mUiSettings.setMyLocationButtonEnabled(true);
9 J0 j3 u5 J% D) t# n2 @8 p7 ?* R                mUiSettings.setScaleControlsEnabled(true);
! w7 O, o) @5 ^7 O; _8 q                aMap.setOnMapClickListener(this);// add the listener for click for amap object
  G, h' Z- o  J' l                aMap.setLocationSource(this);
7 G; P7 G: p+ i' n* W                aMap.setMyLocationEnabled(true);
3 {; I4 C: w+ K% R) l) j4 a: _                aMap.setInfoWindowAdapter(this);
6 J, s1 K- D; M- M, y( j                aMap.setOnMarkerClickListener(this);1 A) a  K9 l% c: u# n0 A
                setupLocationStyle();
) G+ J- y# k8 ^5 _- }7 q4 j            }
/ T1 o1 G, b2 B& L        }3 X& C- i1 \3 a4 h4 \
        private void setupLocationStyle() {
3 a8 r6 S/ q. A  v            // 自定义系统定位蓝点/ R- m; F9 Q' m  ]9 U  w
            MyLocationStyle myLocationStyle = new MyLocationStyle();
/ }7 }. v9 p1 q$ f5 I            // 自定义定位蓝点图标
3 J! j0 K5 E* P. P$ w; P1 P            myLocationStyle.myLocationIcon(BitmapDescriptorFactory.
$ S' W! w; k3 o9 y, o5 c                    fromResource(R.mipmap.icv_gps_point_36dp));! S# [. u! w2 u! u% U
            // 自定义精度范围的圆形边框颜色
' S! n7 F- h5 }, X' L7 I            myLocationStyle.strokeColor(Color.parseColor("#00000000"));$ ]2 v; ]/ p" ~: w  Y; m/ d
            //自定义精度范围的圆形边框宽度8 [0 ^7 v3 I) b& G
            myLocationStyle.strokeWidth(5);
1 j2 i0 F. h/ C; B            // 设置圆形的填充颜色
4 W) p" Z7 F# y) W# P5 ~9 R            myLocationStyle.radiusFillColor(Color.parseColor("#00000000"));' O) B* t( R  q: C* a) h
            // 将自定义的 myLocationStyle 对象添加到地图上7 L+ T# z$ p0 Y# H7 a
            aMap.setMyLocationStyle(myLocationStyle);
; V8 ~/ j0 g. ~        }
3 z) W/ D8 y" [. q, T1 ?$ Z        @OnClick({R.id.img_kml_input, R.id.img_setting_route, R.id.img_start_fly, R.id.btn_delete,' v& x1 j" M& S' `% P( |4 r7 F
                R.id.img_setting_clear, R.id.btn_finish, R.id.btn_setting, R.id.btn_upload,! M3 A  {, f4 Q  p: O# z7 c8 t' l
                R.id.btn_start, R.id.btn_stop, R.id.img_back})( }7 i  j* g& G4 f& Y/ F* l0 a
        @Override" s8 {$ f: i  B8 B, K' I5 m: O  R
        public void onClick(View v) {; M6 X7 `% I8 k+ i
            switch (v.getId()) {
  s/ W8 r; Q  w                case R.id.img_back:* ]+ p5 Y" }& [
                    SettingRouteActivity.this.finish();) O2 v& n0 w( r
                    break;! F; h& X* C' O0 `9 U% I- R
                case R.id.img_kml_input:
4 X/ A  `) W5 g6 V) l8 j                    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);  s: j4 r0 O! T8 h
                    intent.setType("*/*");//设置类型,我这里是任意类型,任意后缀的可以这样写。# ~2 f+ K4 A* S& V5 ?; d
                    intent.addCategory(Intent.CATEGORY_OPENABLE);
+ P  Q' a6 H8 N3 b7 O1 @! Q                    startActivityForResult(intent, MyStatic.REQUEST_CODE_FILE);
7 x. {0 M2 t0 N8 n0 `) @4 d) j: H1 H                    break;' b5 V' _. L$ m( N5 c# e9 n
                case R.id.img_setting_route:# O' k% V9 v3 ]% H
                    enableDisableAdd();+ I: G2 D8 p- e5 {8 `
                    break;9 I& y7 M; U" x& Y' s/ Q& Q
                case R.id.img_setting_clear:' i1 E1 @  A  u
                    runOnUiThread(new Runnable() {
: U' e5 |" X% e& z                        @Override
1 }. M1 J' V. G& {                        public void run() {: @, a8 v7 l' f6 b/ i' S/ }
                            aMap.clear();
. Y, F( P$ @- y9 k# d3 _                            mMarkers.clear();
; O; @/ o7 Q1 s- t9 h                            mPointInfo.clear();
8 v2 D( Z  N  Z! p6 S( ?                            mLinearLayoutInformation.setVisibility(View.GONE);
" r" T7 u8 Z! }8 K" w                            mButtonFinish.setVisibility(View.GONE);6 W8 @9 E$ ~& k
                            mButtonSetting.setVisibility(View.GONE);1 `4 N! m3 C. K' n, O% b8 ]* P
                            mButtonUpload.setVisibility(View.GONE);8 g" _4 s2 i; w. W' \
                            mButtonStart.setVisibility(View.GONE);' F! ~- ~- x& \1 [% H# s9 `) L
                            mButtonStop.setVisibility(View.GONE);
3 L( r& G1 W* a4 j7 r( O& q                        }
: S4 G7 L/ ?# S: t) y7 }                    });- q5 i+ e2 |# u  o) L
                    waypointList.clear();% \+ E( _3 q% A3 ~* I0 R0 ^
                    waypointMissionBuilder.waypointList(waypointList);. x6 T3 A; _' S, @
                    break;
# Y8 G3 y( U* B$ S: j: Z                case R.id.img_start_fly:
" `" c/ ^* ]0 W/ `+ Y# a; r                    atyAction(WaypointActivity.class, MyStatic.REQUEST_CODE_ID);
- L! K2 e4 A/ L7 g# t3 g                    break;
8 X! j$ N& Z% a9 w! X% u- l                case R.id.btn_delete:# D& |- c9 `6 H. A
                    runOnUiThread(new Runnable() {
" {0 C- l) e: C) @' \0 U  r" g                        @Override
- }; F8 b% i# [+ @                        public void run() {! V7 [+ i+ j/ A5 L4 t
                            aMap.clear();% y9 P; m) ]. \7 ]5 C
                        }7 m0 c- A& o* g- g. b4 y2 v$ {
                    });& A8 t( y; \# l7 @/ p7 P, [
                    for (int i = 0; i if (mMarkers.get(i).getTitle().equals(mClickMarker.getTitle())) {, A) e% Y% i5 F6 E- i8 j' D8 Q; ~# r2 L
                            for (int j = i; j 1; j++) {
3 M4 I: R; H1 ^: V" c, a                                mMarkers.put(j, mMarkers.get(j + 1));" r0 A% ^9 k. B
                            }5 X( s4 |% J' d9 D" z& X6 c! V+ E
                            mMarkers.remove(mMarkers.size() - 1);/ M  ?& a) q; p! P2 Y& F7 [
                        }
, F# g1 e3 W7 [% @) s! l% F; F: M                    }, A' n& g( _( r! y
                    for (int i = 0; i "航点" + (i + 1));
* Q. g- o9 p" h1 j                    }
  V$ N& t  g( t# F* |7 Z' B                    updateMarkWaypoint();# A1 F0 z( G( P4 d7 ?+ E/ e
                    break;7 v$ t1 ^5 x. }( S6 }. ]% u
                case R.id.btn_finish:* F5 C; i$ ]/ ^7 X7 f% o0 t0 M) h) c
                    MyLog.d("航点数:" + waypointMissionBuilder.getWaypointCount());: Y$ H6 u9 M: |1 G0 R7 X
                    MyLog.d("总距离:" + waypointMissionBuilder.calculateTotalDistance());+ T( T6 G1 v7 i
                    MyLog.d("总时间:" + waypointMissionBuilder.calculateTotalTime());5 n# g% L. r/ E( b: W2 }" e* e
                    isAdd = false;
. n; T5 u9 d0 [- K& i. }                    mButtonFinish.setVisibility(View.GONE);
2 i9 K! W, w- T+ L  @3 o" V                    mButtonSetting.setVisibility(View.VISIBLE);
  q0 D. h! B& _+ J                    mButtonUpload.setVisibility(View.VISIBLE);
& r; [; K" ?/ ]. q9 V! {                    showSettingDialog();
( U! D9 ]7 G0 a+ S                    break;3 A6 X( }1 _9 F. ^
                case R.id.btn_setting:: N$ l* @; V; M6 G4 i5 Z' g$ R
                    showSettingDialog();
* A% }: c% x% r. s7 ~                    break;
5 ]5 V! x8 a' a8 W                case R.id.btn_upload:
- \- R/ u+ m3 U! k# a4 w                    uploadWayPointMission();5 r1 o" v) H! f( w1 k+ }. |
                    break;
& w" Z7 ~: w: q* u5 i8 Z* o                case R.id.btn_start:
. J, V8 l0 X6 H0 h                    startWaypointMission();
3 W- O4 \; H9 g( E                    break;4 `4 U1 y* A1 J" D  d7 G- R) D
                case R.id.btn_stop:7 o$ v" }  Z% I, i9 w
                    stopWaypointMission();# t7 z  e5 |( }
                    break;
1 `+ @& L, n# ~1 X" D1 h- m& A/ u            }
8 n! k- @" Y7 n7 R: Q* ~  J) S- [& L        }2 V6 m) B$ C5 }0 h, Z
        private void enableDisableAdd() {
6 x7 w$ W5 F- k3 b# ~            if (isAdd == false) {
: k7 ]  U+ L; j  ?8 p                isAdd = true;  B9 D5 M( @+ u) U. \9 H! ^1 W
                mButtonFinish.setVisibility(View.VISIBLE);
- }1 U' G% N& O: @$ S            } else {- I/ _1 m+ U" K
                isAdd = false;
( H1 S, g# c0 o0 x' V, H/ c            }+ I( J2 \4 r0 Z' U( t( O* S
        }% j( M/ M) s  V+ Q+ G$ h0 D
        private void initFlightController() {
+ f+ [) i4 g; {            BaseProduct product = ReceiverApplication.getProductInstance();
3 ]  j! g/ v+ n6 l6 n6 n: x/ G            if (product != null && product.isConnected()) {- X3 E/ k$ z  c) b7 Z# j
                if (product instanceof Aircraft) {
7 y" l+ ^# b# ?5 ^4 O                    mFlightController = ((Aircraft) product).getFlightController();/ }' j( {$ U) i; b# k9 w+ D
                }- ]% D# ~* y: z0 T0 C6 a# B7 k
            }
' X6 n0 E7 i& }$ ~% S4 H            if (mFlightController != null) {7 P- I, {& c2 A, O# Z
                mFlightController.setStateCallback(
; X2 \5 u0 `# k; x                        new FlightControllerState.Callback() {7 |8 d& c. T% s5 x  r) J
                            @Override5 l- D( Q) V/ z3 k
                            public void onUpdate(FlightControllerState
) i1 g% m' ?/ E                                                         djiFlightControllerCurrentState) {4 s' W) [5 D$ W# w3 n( Z
                                if (djiFlightControllerCurrentState.getAircraftLocation().getLatitude() != 0.0 && djiFlightControllerCurrentState.getAircraftLocation().getLongitude() != 0.0) {
$ s" v  \/ x3 I$ E                                    D_latitude = djiFlightControllerCurrentState.getAircraftLocation().getLatitude();" v- d( I0 S; t- t8 L% Y
                                    D_longitude = djiFlightControllerCurrentState.getAircraftLocation().getLongitude();
$ C. c2 [/ q8 }" k                                }; ]+ @* Q! b5 y
                                updateDroneLocation();# ]  T! l; [* _9 o" `
                            }
; ^& q6 B+ R% M' k) x                        });
! F; F0 }: j  ?            }
/ L: u! r9 b! ^: ?        }) m% H5 {- F; J* R9 L
        private void updateDroneLocation() {; s- N8 Y# j! |; z( W- K* B
            LatLng pos = new LatLng(D_latitude, D_longitude);: a5 ]- {6 @8 _5 E- D: I" Z) z
            //Create MarkerOptions object' G. z9 v( }% H
            final MarkerOptions markerOptions = new MarkerOptions();& D/ |# }, K! b* {% W8 m' x
            markerOptions.position(pos);4 Q/ o; `. u9 d8 S$ S! Z9 Y
            markerOptions.icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_aircraft_write_36dp));
: f2 p( F) P( N0 u            runOnUiThread(new Runnable() {6 p4 h9 f) t& b- m: J
                @Override- j6 x% A$ N  O. P8 f
                public void run() {4 M7 d( u' Z. r( |! Q* q
                    if (droneMarker != null) {
" ]) G& Y( c6 Y                        droneMarker.remove();
# Q6 G5 f) d( n1 g; O                    }
3 d' p! i  G: ?# c5 |; k5 O                    if (checkGpsCoordination(D_latitude, D_longitude)) {  J5 }7 l4 u+ C  l" u
                        droneMarker = aMap.addMarker(markerOptions);
( z& T9 Q% M3 n" ~- ?                    }' D* d2 G4 g$ @2 B! l% P; O
                }
: b% ]& S) {  R/ h1 {            });) q9 n1 [) z/ X* ~- h
        }
& I1 {4 U) o# w% w5 H0 V6 f9 n7 S- {( c5 w        public static boolean checkGpsCoordination(double latitude, double longitude) {
# S% c% c( o+ ^3 J, E  u7 T8 U+ C            return (latitude > -90 && latitude 90 && longitude > -180 && longitude 180) && (latitude != 0f && longitude != 0f);
1 E8 h; T$ }' N; `5 R+ Z& F        }% X) d! }8 V* K% v# b0 d7 p
        protected BroadcastReceiver mReceiver = new BroadcastReceiver() {$ N3 w! a# H1 N- Y+ i2 D- `; j
            @Override
% Q+ Q8 ~7 A8 e' @            public void onReceive(Context context, Intent intent) {
7 ?+ ^& R4 E$ x+ w                onProductConnectionChange();
% V, P: ]* h: G) c$ x            }
! W; p$ y4 f' J: P# E- {3 c        };2 U6 x! u  u1 [# n
        private void onProductConnectionChange() {
& b  j6 A9 @) t            initFlightController();4 X3 E! J. H7 J% n* D4 s
        }$ n2 i$ N( q- L$ B! N. C) i! v- `, r
        private void addListener() {
: I9 H* M  A4 _            if (getWaypointMissionOperator() != null) {- s, [2 I# G3 X( `! w
                getWaypointMissionOperator().addListener(eventNotificationListener);
' V+ O: r+ ~1 X9 B- v5 V0 P) X# F            }. I/ a$ e% l! k: i3 s4 S
        }( {$ e5 i) S8 x
        private void removeListener() {
5 c( [8 D+ X& ~            if (getWaypointMissionOperator() != null) {3 ?  [) f3 z3 t+ D: I, `4 T$ r  ?
                getWaypointMissionOperator().removeListener(eventNotificationListener);
' V, T$ I& d% s$ d0 u/ W( [            }+ a$ N0 C$ p8 }- N1 t+ C% R
        }
8 ^  p3 O6 c! C+ F' V        private WaypointMissionOperatorListener eventNotificationListener = new WaypointMissionOperatorListener() {! Y: W$ ~4 E& m# Y
            @Override* u0 U4 Y: V4 L
            public void onDownloadUpdate(WaypointMissionDownloadEvent downloadEvent) {
! l/ S4 ?2 v' R( }, s            }
+ t7 K6 x% }- T: c            @Override
  H! \1 J( N* j( _: C            public void onUploadUpdate(WaypointMissionUploadEvent uploadEvent) {
! t/ s4 K( K4 Q) s. w; @            }7 }; O7 H# h& L( W0 o& o
            @Override
+ D5 e9 z$ a# a3 e* S9 e% W            public void onExecutionUpdate(WaypointMissionExecutionEvent executionEvent) {
$ j0 w& K% u8 j5 K" a$ y7 l- ^            }2 q" c+ p. U( o' ~" M' Y) m( e6 r
            @Override
" Q. P9 x. T6 j            public void onExecutionStart() {- C0 h1 U: f4 u" q. j
            }
" R& O# Q  [+ N( L2 X* o- x5 R            @Override: D$ e: h7 z1 d! f" G5 D% s4 ^
            public void onExecutionFinish(@Nullable final DJIError error) {
" V: t7 b( x* }6 a" }                showToasts("Execution finished: " + (error == null ? "Success!" : error.getDescription()));
! [: w9 p, r! Y1 D( G            }
1 ~$ G/ d0 C- v( O3 v        };( n( F5 q! I. g( z4 B
        public WaypointMissionOperator getWaypointMissionOperator() {
3 P' E; Q( f0 V: B' \( c            if (instance == null) {7 `7 e) C& o, |
                instance = DJISDKManager.getInstance().getMissionControl().getWaypointMissionOperator();) f- W5 j  \$ ^# x, W
            }
7 |5 x# ~: G( u: @3 T            return instance;4 P: Z) J/ `6 l
        }  N$ X& \# i  F$ V+ U. ~' [4 I
        @Override/ E6 W1 C8 m8 z& _: k2 Q
        public void onMapClick(LatLng point) {4 B; F  t. M: k2 Q- T$ N
            if (isAdd == true) {
- ^9 j# O  c5 [  y$ Y5 y                markWaypoint(point);
! D6 h1 ~  ~0 y& x7 H% l6 w                Waypoint mWaypoint = new Waypoint(point.latitude, point.longitude, altitude);) J' N5 E8 m! f, p0 A5 `; J# q
                //Add Waypoints to Waypoint arraylist;
' f/ L2 _5 [% `& ?% Y0 L9 G9 l0 w                if (waypointMissionBuilder != null) {( Y( ?) S& t5 y6 C  H' d
                    waypointList.add(mWaypoint);
# b2 l4 |- `: Z                    waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
& c) P4 R! a% x/ A                } else {
; k* K1 V; m# p% u) h7 p# U                    waypointMissionBuilder = new WaypointMission.Builder();4 I' n$ C8 c3 J" i
                    waypointList.add(mWaypoint);% @  n5 f' }8 V& D; F- F$ C
                    waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
0 {7 e& J  A* t                }8 S% Z) O; ?1 b( ]3 C
                mTextViewCount.setText("航点数:" + waypointMissionBuilder.getWaypointCount());
2 ?. A% C" r2 B: E. c                mTextViewDistance.setText("总距离:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");, x9 B! s( Y8 l2 d  D
                mTextViewTime.setText("总时间:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");- G! F2 ]2 b# ]6 B' ~# g3 Q
            } else {9 Z) `  l* z& a" ?# a
                if (mClickMarker != null && mClickMarker.isInfoWindowShown()) {
) B; |; O% ]) M3 _                    mClickMarker.hideInfoWindow();5 p: s' C0 d$ _2 o/ ~
                    mButtonDelete.setVisibility(View.GONE);
& z% p, ~, M: ?% g2 x                }" x3 a% I) S+ d" }
                //            showToasts("当前未开启增加点模式");' X$ H& q& k9 X8 V$ S0 h' E
            }' t* d( J2 W* M% s% `1 Z
        }9 H0 }2 ^9 u/ v  M  ?  A$ k  Z
        private void markWaypoint(LatLng point) {- N) ~$ s+ y5 R7 v% v' k! b
            MarkerOptions markerOptions = new MarkerOptions();6 X' Y# ~+ ^$ M! [6 {, p" B* \
            markerOptions.position(point);
1 F# s6 y  s3 l6 Y$ w8 ]0 M            mPointInfo.add(new PointInfo(point.latitude, point.longitude));
( F# w& R' X( f            markerOptions.title("航点" + (mMarkers.size() + 1));. T, o2 o# H& ]2 A; q
            markerOptions.snippet("事件:");
+ |/ Y' p  a( k+ K1 r0 _+ `            markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));6 j) j$ d* d+ Y& D+ L. K4 Q! h
            markerOptions.infoWindowEnable(true);
; b0 M0 Q8 x' {( h: ]: J5 n7 R- `            Marker marker = aMap.addMarker(markerOptions);
1 {* S/ E5 ]" w5 Y+ m) s            mMarkers.put(mMarkers.size(), marker);
& s* ]+ f! V2 z            marker.showInfoWindow();
0 B! g+ D, D3 p* _+ X0 q$ }" \            if (mMarkers.size() > 0) {  K  ]" U; u6 x8 j: B
                mLatLng.clear();, D' R% d3 X+ s/ F2 Z" o, _, f
                PolylineOptions PolylineOptions = new PolylineOptions();% w; j2 y3 y5 T  l, T
                for (int i = 0; i 10);
* H9 f0 w7 @4 s6 L/ k3 d                PolylineOptions.color(Color.argb(255, 1, 1, 1));
' Y" p, d# `1 {# K; H4 g                aMap.addPolyline(PolylineOptions);
+ O6 C, q: m+ H# k7 ^            }
$ x, E' S) @& S( P5 `  d3 `% @8 U        }/ F9 Y& E& x9 U  m4 K. J
        private void updateMarkWaypoint() {
7 _+ R% ?- f5 H# I$ S8 O8 X) P            mLatLng.clear();
& i+ R0 g$ G! ~            waypointList.clear();
5 f, B; l  s" g3 h6 e8 W( H/ J9 j% N            mPointInfo.clear();- h6 J! j/ C2 h! g% x
            waypointMissionBuilder.waypointList(waypointList);
# w0 s& T, n2 G- I1 x: h# n            for (int i = 0; i new PointInfo(mMarkers.get(i).getPosition().latitude, mMarkers.get(i).getPosition().longitude));, g  q& _# v  d) Q2 G- z' e" ~
                MarkerOptions markerOptions = new MarkerOptions();
; q# u4 _# ^( ^: F' |                Waypoint mWaypoint = new Waypoint(mMarkers.get(i).getPosition().latitude, mMarkers.get(i).getPosition().longitude, altitude);
4 b, r" t( e8 X& m! ^3 m$ O) o: E# W                waypointList.add(mWaypoint);
: I- d& G1 U1 U9 n( `$ a                markerOptions.position(mMarkers.get(i).getPosition());* Y3 E+ U) E" o5 s$ o
                markerOptions.title(mMarkers.get(i).getTitle());
$ K6 a4 D- @, M; c; t                markerOptions.snippet(mMarkers.get(i).getSnippet());9 U4 H6 ~, g1 w1 d
                markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));0 g* m# b2 e3 v! M$ n( B& U: i" x  W
                aMap.addMarker(markerOptions);
; L/ S' Z" j, g* {5 z& O$ J. N                mLatLng.add(mMarkers.get(i).getPosition());
2 r) A) i1 I% Q& \( |            }3 N) p  Q$ W6 a# r' \+ C* g
            if (mMarkers.size() > 0) {. I$ g% P; L& L, G- X0 ~
                PolylineOptions PolylineOptions = new PolylineOptions();
. _$ B+ T* f; W3 A                PolylineOptions.addAll(mLatLng);) I" N& ^2 ^' \- X+ B( R( @
                PolylineOptions.width(10);
7 x' b3 I! M, p" X" w                PolylineOptions.color(Color.argb(255, 1, 1, 1));
: o, J' j- T5 X                aMap.addPolyline(PolylineOptions);
5 z  |- V3 r/ X7 M2 g4 m            }
; W6 e) i; K$ ~0 y) z' n            waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
* O4 A) u" B1 }7 w) B/ N. B+ }" a            mTextViewCount.setText("航点数:" + waypointMissionBuilder.getWaypointCount());, }! @' H% F1 k% m
            mTextViewDistance.setText("总距离:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");- I8 o- z! p5 L$ f( Q: D8 W
            mTextViewTime.setText("总时间:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");
1 G2 e; M& s" B# R7 j- w) e$ M- [8 P            MyLog.d("航点数:" + waypointMissionBuilder.getWaypointCount());1 @. ], W5 G) V( Z' z
            MyLog.d("总距离:" + waypointMissionBuilder.calculateTotalDistance());" c0 p8 C% E8 w: N  `) \. E, d
            MyLog.d("总时间:" + waypointMissionBuilder.calculateTotalTime());+ [8 @9 q4 O6 b% Z1 o
            mButtonDelete.setVisibility(View.GONE);1 B* @3 x" I% h4 U. }, `: u; n
        }
; ]/ {& z9 ]) `$ H7 l4 Z  q
# O9 o; h$ x$ b0 ?        /**
) {9 |: M" g3 D* f" N0 C         * 定位成功后回调函数0 N$ n/ i& {7 j% [, h1 i- y
         */# `9 ~* H& @+ A  G! [: j
        @Override; S5 p4 B4 ^# m* T7 J
        public void onLocationChanged(AMapLocation amapLocation) {
; g- ^0 _8 ~: b5 M            if (mListener != null && amapLocation != null) {' A" X5 t  P2 V! O/ W/ [' Z/ t
                if (amapLocation != null
5 ~5 }0 c) o8 W9 T% G1 p0 U' k( F                        && amapLocation.getErrorCode() == 0) {
1 q' H6 d9 a" C" l                    D_latitude = amapLocation.getLatitude(); //获取纬度% s* D/ u3 x- N3 S& f4 r
                    D_longitude = amapLocation.getLongitude(); //获取经度  @" i- i( S% @( I
                    mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
( i5 ^3 C. a; m9 o5 P* t" t                    aMap.moveCamera(CameraUpdateFactory.zoomTo(18));  C. ?) ^- r0 N% B- U* }
                } else {6 G' g. }4 o4 q: t/ \
                    String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();- P: Q' q% o. I/ e5 A/ t* d& X
                    Log.e("AmapErr", errText);
2 M0 Y, r& F7 R; ]  V/ w9 O                }; b+ }+ P+ ]4 P
            }3 a! O8 Z% \* }4 f
        }5 p4 z0 d* I6 {9 p
        @Override* K0 }# C+ g( v6 X& w  c
        public void activate(OnLocationChangedListener listener) {
7 v6 y, P0 s. o; Y/ ~! F: b            mListener = listener;
; r& S0 m) S+ S# F. N            if (mlocationClient == null) {$ D: ?$ {' ^" ~$ j. F9 v
                try {$ w. F, q3 C1 G- v7 F
                    mlocationClient = new AMapLocationClient(this);
1 ]/ ?. H) J, j                } catch (Exception e) {
- G3 c! e! Z  S* w# f  ^0 }                    e.printStackTrace();8 j0 b3 h4 `! y
                }5 u% g# K6 N/ V. c8 A+ N% A
                mLocationOption = new AMapLocationClientOption();
  r* m* a+ v) i) L4 q                //设置定位监听
3 N: N" H5 I. s) ^                mlocationClient.setLocationListener(this);
7 Q; }& i4 G5 M' f9 V                //设置为高精度定位模式6 A5 p$ v& A' \; B
                mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);/ G6 e+ R0 i0 u0 P( c
                //设置定位参数
+ U1 c, x2 o, l                mLocationOption.setOnceLocation(true);
8 ?& [) Y* {8 G: Z; b7 w6 p+ |7 |                mlocationClient.setLocationOption(mLocationOption);
. }7 B$ X; D5 j5 Y                // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
/ ]- V1 G1 \7 ^7 [) S                // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求' c% U1 R( z( w1 x* `0 @9 `' i
                // 在定位结束后,在合适的生命周期调用onDestroy()方法" U, a# Q, }+ s: o
                // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
" q$ s5 `% `% x4 \$ N. w! V                mlocationClient.startLocation();) l4 A- b0 |; s: B9 ~3 Z
            }
8 g& a# r/ s" g        }" K' n9 _9 u" ]8 K( T$ I* v
        @Override
+ w. O- B; L- G( S( M% O        public void deactivate() {
7 `( X/ G+ ]! R1 H# g5 {; |  G            mListener = null;
3 O% N3 h6 t1 I* z5 @; {            if (mlocationClient != null) {
% V7 T/ X# Q6 k                mlocationClient.stopLocation();
" A: X$ @4 B0 a, m: C; ?                mlocationClient.onDestroy();" F) C% q+ S8 d, S" d& ~# C6 n
            }
9 d: L) \! o' N; B            mlocationClient = null;# s1 m# O5 U& |% i* d* l0 l- Z- o
        }
  b& K8 `( f; U7 ~        @Override
% Y( Y( T- M( U5 c* ^) R7 ~        public View getInfoWindow(Marker marker) {0 m! Q9 R# o6 E& e7 r
            if (infoWindow == null) {' Q; C. y* j6 M- L9 i% H
                infoWindow = LayoutInflater.from(this).inflate(R.layout.amap_info_window, null);
7 x( d: d- L9 y  ]: g( F% ?; h; W            }2 l0 d: ]: N/ ~, U* Q  }% l
            render(marker, infoWindow);
5 k8 A1 ?& \# F) I* M% x- }            return infoWindow;% ?7 X! J$ U+ m  F$ B
        }
9 V: _9 N( V1 f2 f3 t) q2 A        /**
" O8 _$ z) _0 a+ {% T: e         * 自定义infoWindow窗口  Q7 F( }( w" V9 e* N% }
         */% n; [* \/ {5 f7 X3 Q
        private void render(Marker marker, View infoWindow) {
* [1 M6 A6 D# C$ P0 F* p            TextView title = infoWindow.findViewById(R.id.info_window_title);1 z* G4 g# Y) |  a0 z6 p
            TextView content = infoWindow.findViewById(R.id.info_window_content);
( F, j5 ]; b6 w            title.setText(marker.getTitle());1 X3 g. C0 b3 i4 \2 `
            content.setText(marker.getSnippet());* ^+ [; {5 G  l
        }
  c: D" e5 {+ _" v
, [' e4 Z- l$ C% r3 k0 m        @Override# `+ e! g5 _2 E
        public View getInfoContents(Marker marker) {8 O' A$ a  m/ z3 x# {
            return null;* J3 L5 l* c8 A; v
        }' [8 A- {/ S" b7 R/ n: K/ p
        @Override9 S0 Y5 u- I' r5 j
        public boolean onMarkerClick(Marker marker) {# m$ {" z% G, K( D9 z
            marker.showInfoWindow();- _8 O9 J+ W6 B2 N" j* T
            mClickMarker = marker;$ g4 f. P1 J3 E
            mButtonDelete.setVisibility(View.VISIBLE);* Q7 O- X2 H" N5 o
            //        aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(marker.getPosition(),18,0,0)));7 g/ K" J" G/ I
            return true;
2 R/ b4 d8 |4 r        }
, H3 |4 \5 s' A6 U        private void showSettingDialog() {+ x0 [: b# r9 \! n3 n
            LinearLayout wayPointSettings = (LinearLayout) getLayoutInflater().inflate(R.layout.dialog_waypointsetting, null);. [$ e* I& H! P8 c: r3 V7 f: B  O
            final TextView wpAltitude_TV = (TextView) wayPointSettings.findViewById(R.id.altitude);2 \+ [0 |0 {, ~# J0 W  E1 I+ H
            RadioGroup speed_RG = (RadioGroup) wayPointSettings.findViewById(R.id.speed);
$ c" q0 B, m4 q4 \. b            RadioGroup actionAfterFinished_RG = (RadioGroup) wayPointSettings.findViewById(R.id.actionAfterFinished);* p4 u% U( a/ p/ I7 u
            RadioGroup heading_RG = (RadioGroup) wayPointSettings.findViewById(R.id.heading);  m9 ^  h1 w/ y; D' M& ]
            wpAltitude_TV.setText(Math.round(altitude) + "");! W# P$ m& I3 [. f1 A
            if (speed_RG_id != 0) {( L- k9 s9 T0 K
                RadioButton radioButton = (RadioButton) speed_RG.findViewById(speed_RG_id);
- x7 n% t' q: `! Q* O7 p. o                radioButton.setChecked(true);
- e  @; K/ I& k# V/ L4 z8 `. h! J            }
+ h" j9 O; l2 a" V& A) |* g! H0 G            if (actionAfterFinished_RG_id != 0) {9 ?8 i2 h1 u1 D3 E
                RadioButton radioButton = (RadioButton) actionAfterFinished_RG.findViewById(actionAfterFinished_RG_id);( V" X* V% E, M$ {
                radioButton.setChecked(true);
% T7 m$ A" w! @7 C& q5 s( H9 q# r            }7 L6 `) W1 l1 ]: I; H0 K. m
            if (heading_RG_id != 0) {: q+ [8 c6 g' L$ U3 n& H: w; t* d
                RadioButton radioButton = (RadioButton) heading_RG.findViewById(heading_RG_id);
0 j$ |- ~; N6 f& l5 w; x# S                radioButton.setChecked(true);. y! L; u0 W" Q& N1 R
            }. @  Q5 u; A5 N$ a4 w& m
            speed_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {: {: x- g9 _9 c! E8 S$ ]2 |8 |
                @Override
; c" t7 g. U* p, _                public void onCheckedChanged(RadioGroup group, int checkedId) {# ]9 S  l- y5 K1 I5 ?: `
                    if (checkedId == R.id.lowSpeed) {( `0 P  q( Y% @
                        mSpeed = 3.0f;
2 x9 |& B+ Q( V* q' t8 ]                    } else if (checkedId == R.id.MidSpeed) {
  _$ p5 j% f' @                        mSpeed = 5.0f;
+ n+ h% ]; p7 G3 x( T) K                    } else if (checkedId == R.id.HighSpeed) {
! y2 M. U1 g  }$ }                        mSpeed = 10.0f;
0 g- D# A& I  z$ P                    }0 Y" r/ a, o$ f
                    speed_RG_id = checkedId;$ i2 H( _! K3 ?
                }& o5 f. n! D- m! \
            });
" X( J6 [0 M* |$ V. E  M1 n* N            actionAfterFinished_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {# Z- _; O- ~5 ?2 p3 j
                @Override
1 [- K' U# G6 m+ J- {                public void onCheckedChanged(RadioGroup group, int checkedId) {; N4 L. l9 H0 K( t" ~
                    MyLog.d("选择动作完成");% x( c5 S9 Z% f7 k# ]+ t! n
                    if (checkedId == R.id.finishNone) {" Q3 E; x% T& g8 k" M7 I
                        mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;
) P$ R1 d7 @; f  O4 ?/ Y; ?                        FinishedAction = "0";
% k5 c! `. p. ]5 G7 A. o  m) D! W                    } else if (checkedId == R.id.finishGoHome) {
5 P9 _7 y$ T) ^# H- m                        mFinishedAction = WaypointMissionFinishedAction.GO_HOME;: T8 B* d6 z6 o7 L! c# B7 y& N
                        FinishedAction = "1";/ a3 Z& n+ Q% E0 ?' @, H
                    } else if (checkedId == R.id.finishAutoLanding) {$ i, P) q' i8 N/ w3 ~  O
                        mFinishedAction = WaypointMissionFinishedAction.AUTO_LAND;
) t' p+ u; c2 T6 F                        FinishedAction = "2";
& I4 W# A# i: `. P- H+ n5 @                    } else if (checkedId == R.id.finishToFirst) {6 v- E2 J9 R8 t4 \
                        mFinishedAction = WaypointMissionFinishedAction.GO_FIRST_WAYPOINT;
1 {2 [2 v# c# S7 T% F/ _7 f) {3 R, F                        FinishedAction = "3";
. e# O* Q. P) X8 J# N9 L  c                    }0 s( a2 ?$ a1 K0 B, m$ C! |
                    actionAfterFinished_RG_id = checkedId;0 B3 L$ w1 {1 I$ K- o1 l
                }
/ p" R% D2 c# T+ H  b% ?            });
2 J* n3 x/ v9 h  F, E            heading_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {. m- {% ^) m+ s+ g5 W
                @Override9 w- j5 Y$ q4 Q: o1 I* s
                public void onCheckedChanged(RadioGroup group, int checkedId) {) O1 J) K$ k) Y% G8 L2 D5 j
                    MyLog.d("选择标题");- |( W9 _5 l' g3 Q5 J& l
                    if (checkedId == R.id.headingNext) {
1 S/ A1 h, S) C4 K- S: T, `                        mHeadingMode = WaypointMissionHeadingMode.AUTO;5 s  m/ a9 e8 z# k) w- I
                        HeadingMode = "0";. V# G$ N* g! z$ ?9 e
                    } else if (checkedId == R.id.headingInitDirec) {! y! Z+ ?( l$ N4 P7 S
                        mHeadingMode = WaypointMissionHeadingMode.USING_INITIAL_DIRECTION;
7 B1 {$ ?0 b" A. N                        HeadingMode = "1";  w1 o  b1 {+ U
                    } else if (checkedId == R.id.headingRC) {$ ]* m" n- A& Y6 e# @7 \
                        mHeadingMode = WaypointMissionHeadingMode.CONTROL_BY_REMOTE_CONTROLLER;
# j2 ~! {+ b. x$ N$ h                        HeadingMode = "2";3 [, N4 s' H) k- s  ?1 j8 V7 u
                    } else if (checkedId == R.id.headingWP) {
1 U2 r  r) O% I- I) @                        mHeadingMode = WaypointMissionHeadingMode.USING_WAYPOINT_HEADING;0 p" |% P. Q3 b1 h' j. r; q0 B
                        HeadingMode = "3";1 T% v* J) @1 |. @# c# Q
                    }
3 ^* A  N: s- W. g8 Y5 C2 I                    heading_RG_id = checkedId;0 y6 Y% Z' j8 m- o2 f5 D7 T( s
                }
) \) U0 H' X6 ?- N0 W) y            });
2 {/ c3 k; K/ X4 W0 j            new AlertDialog.Builder(this)$ [$ @3 a( B3 Q  R* I
                    .setTitle("航点设置")* ?; |8 i3 P6 v
                    .setView(wayPointSettings)" X9 G* s3 L( Y+ |0 B1 Z: {0 m
                    .setNeutralButton("设置", new DialogInterface.OnClickListener() {
' R' a1 b( j7 U' h& _% Q                        public void onClick(DialogInterface dialog, int id) {
8 {4 f1 S4 M9 O: ~' t; j1 h                            String altitudeString = wpAltitude_TV.getText().toString();
. Z' X1 r! r- f- o! [7 f' a  q: g                            altitude = Integer.parseInt(nulltoIntegerDefalt(altitudeString));, |, r2 m5 [! K
                            MyLog.e("altitude " + altitude);2 s; ^  X, F) P' `
                            MyLog.e("speed " + mSpeed);
8 _$ b6 f7 B& m5 d                            MyLog.e("mFinishedAction " + mFinishedAction);9 m, l  \/ ]# }
                            MyLog.e("mHeadingMode " + mHeadingMode);! ^, g; |- P  r# K
                            configWayPointMission();
. i5 P4 s; J4 ?                        }
2 h( Z, H% @- ^                    })
( e2 F8 C" B/ |) ?$ z                    .setCancelable(false)3 r/ I0 f) z: z( N
                    .create()$ F3 n4 m9 T9 Y2 w
                    .show();
8 I( l6 j# i/ I5 z        }
  i0 F, ^" u' {3 x7 h7 N        String nulltoIntegerDefalt(String value) {  E0 R& @7 n) v9 C, ^% s8 c. Y
            if (!isIntValue(value)), w% t- o% h# @
                value = "0";: K( Y4 W/ ?$ }8 ]9 \
            return value;" m9 k/ e  ~1 E1 r; W+ s1 R3 K
        }' ^( O1 x! g/ v  K7 ?0 s6 v
        boolean isIntValue(String val) {. ~2 M  a: n+ y! D4 `
            try {
! }* Z9 @/ a7 s                val = val.replace(" ", "");1 l# l8 ?$ Z9 a) A2 p0 a' o
                Integer.parseInt(val);
4 U3 \% l3 H3 O" P            } catch (Exception e) {
( K) m1 ~: R) _  R" Y" ?                return false;( F; I: I( c( |
            }' h5 {3 y7 o) b& C- z
            return true;
$ I" L6 ]% @) }  K        }7 S2 Z$ b' N3 d' Y! B9 h7 l
        private void configWayPointMission() {
3 `. E& k6 V( x            if (waypointMissionBuilder == null) {
/ ^5 R2 p6 O$ c* ]0 n: A# i                waypointMissionBuilder = new WaypointMission.Builder().finishedAction(mFinishedAction)
$ F: O8 u4 F6 H8 y$ r* D: S0 V0 a                        .headingMode(mHeadingMode)
% _' _6 z2 N; b3 r; |5 c/ @                        .autoFlightSpeed(mSpeed)$ h0 P& w1 U  N1 n3 `& R- A- z& Y
                        .maxFlightSpeed(mSpeed)$ l( @4 |0 B" j" _! ?
                        .flightPathMode(WaypointMissionFlightPathMode.NORMAL);; B6 H& V7 c" C1 w
            } else {
/ W# w9 h. i# G4 X% ^& A/ n                waypointMissionBuilder.finishedAction(mFinishedAction)8 e1 T! @; t  v$ {! K4 P, `
                        .headingMode(mHeadingMode)5 j  ?, J, [" T: P
                        .autoFlightSpeed(mSpeed)
' c& N, n& M7 T( k/ j* @) y                        .maxFlightSpeed(mSpeed)* f3 v+ Q( K* ~+ m- X
                        .flightPathMode(WaypointMissionFlightPathMode.NORMAL);
0 J7 S& v  J+ K& O. d9 Z; w            }
/ p/ g  v5 I  B1 F( i: B9 u. Q            if (waypointMissionBuilder.getWaypointList().size() > 0) {7 k, u) U9 I7 t: L( Y
                for (int i = 0; i if (error == null) {
: f/ b6 }  K- @9 D/ b5 G7 B" e- w                if (mLinearLayoutInformation.getVisibility() == View.GONE) {0 Q  u7 S" W; |/ F0 \& e
                    mLinearLayoutInformation.setVisibility(View.VISIBLE);
  m5 r7 q& ]/ c/ ?! W                }
8 Y. b; ]. P& }                mTextViewHeight.setText("高度:" + altitude + "m");% i* q% t# ^2 P8 D) E
                mTextViewSpeed.setText("速度:" + mSpeed + "m/s");
" m3 P0 \$ s7 _0 g9 E0 e7 F$ H4 J                mTextViewCount.setText("航点数:" + waypointMissionBuilder.getWaypointCount());+ N3 X* E' b) s, U7 g  z
                mTextViewDistance.setText("总距离:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");  [! L# d4 j" `4 M3 {* D5 @
                mTextViewTime.setText("总时间:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");  N: I+ c& i# }3 G" s
                MyLog.d("航点数:" + waypointMissionBuilder.getWaypointCount());
# A0 S1 u. N1 {                MyLog.d("总距离:" + waypointMissionBuilder.calculateTotalDistance());* f/ h0 m0 V. y  S* R7 H9 [
                MyLog.d("总时间:" + waypointMissionBuilder.calculateTotalTime());
& N5 K  M4 H' X6 b  W2 z4 ?                showToasts("航路点配置成功");
/ e5 s  I1 G! b9 U3 J0 f            } else {
% A8 \, p( ^( ?8 D) D                showToasts("航路点配置失败 " + error.getDescription());: y; U3 m& @  W+ J
            }3 i& S% u' {) c& c
        }
' z+ v1 N0 L% U# n  d! O3 U        private void uploadWayPointMission() {  \! ?, L  f  Y  W2 v
            getWaypointMissionOperator().uploadMission(new CommonCallbacks.CompletionCallback() {
' m/ N0 R) N% e% x4 N, J4 d  e                @Override6 y. G- P( w8 X  q: j
                public void onResult(DJIError error) {
8 k/ U! d% j% m6 {$ q                    if (error == null) {) e7 i0 h  X8 {6 ]* q3 s( @  Y
                        runOnUiThread(new Runnable() {
1 e9 M* r. L5 L  t                            @Override
( v5 g2 o6 o" k0 V! l. p; O) K0 K                            public void run() {
, Y( D  M1 U& H. u" c                                mButtonSetting.setVisibility(View.GONE);
. `  x3 f" ^! j$ [5 f. f                                mButtonUpload.setVisibility(View.GONE);
  p" l9 _5 z/ `                                mButtonStart.setVisibility(View.VISIBLE);
( R' C+ y7 H. u                                mButtonStop.setVisibility(View.VISIBLE);
' Q+ Z1 _; `0 ]! P                            }$ j$ r. \+ x+ }
                        });( G0 y6 j* P1 c
                        showToasts("任务上传成功!");
  U4 G$ E' d7 Y8 t                        mSQLiteHelper = new SQLiteHelper(SettingRouteActivity.this);5 y& z7 S- u, z! q
                        MyLog.d("航点值:" + GsonUtil.GsonString(mPointInfo));* e" w& |/ ^7 v1 s- S
                        mSQLiteHelper.doInsert(GsonUtil.GsonString(mPointInfo), altitude, mSpeed, HeadingMode, FinishedAction,
- g$ R9 |4 i/ _" ]' ^9 u) f' x                                waypointMissionBuilder.getWaypointCount(), Math.round(waypointMissionBuilder.calculateTotalDistance()),3 [; a' x5 k# }/ T" C: J5 P+ b
                                Math.round(waypointMissionBuilder.calculateTotalTime()), DateUtils.getCurrentDate());
) T! n) z; o% h. J6 I                        mSQLiteHelper.close();2 x" T2 V3 d6 U$ R8 j/ n$ j9 r
                    } else {
( p! Y) U" K: ]2 d                        showToasts("任务上传失败, error: " + error.getDescription() + " retrying...");
7 N4 P) E  x; V* s% A                        getWaypointMissionOperator().retryUploadMission(null);9 c: s" R) q+ k, F
                    }
( [. T; \9 l( x1 @1 z1 c/ i/ P: s) t                }6 y2 I) s8 g& L- b" B) |3 _0 K
            });
4 R+ b& {+ p! M! |) _# C: I        }3 W- p8 ^& q3 p0 L( K% C& i5 w
        private void startWaypointMission() {
5 z! F9 X2 x- h% Z# A            getWaypointMissionOperator().startMission(new CommonCallbacks.CompletionCallback() {
, y3 V1 h4 r; W! B* E2 H7 R0 x9 i7 v                @Override
+ \7 I! u: R2 |2 i                public void onResult(DJIError error) {' H' D: _( Y1 U# a7 r2 `  c$ ]
                    showToasts("任务开始: " + (error == null ? "成功" : "失败:" + error.getDescription()));1 j9 Z! W7 C& }- g' F+ a
                }
1 [. K1 X0 V9 `5 j, P5 f            });8 s* t- I" C& b, W! u
        }
% W4 }5 S% w9 F! p        private void stopWaypointMission() {
$ W2 r& m; t- H0 I            getWaypointMissionOperator().stopMission(new CommonCallbacks.CompletionCallback() {
9 F, {- `% k2 H( q                @Override
% @+ L% R6 {1 _) d) N9 {. H3 ~                public void onResult(DJIError error) {% Z# N( u% N& @5 V, p1 O
                    showToasts("任务暂停: " + (error == null ? "成功" : "失败" + error.getDescription()));
* Q7 U* O- |% N                }7 |( [: k, \2 D- d/ ^
            });
% r: o) Z$ C8 U) J        }( @; ^* A; b% }# _' I
        @Override
; ]9 Y8 N3 U2 A9 |7 N. U        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  T' O- D- y& G! X  E% u            switch (requestCode) {
5 J2 c6 e5 ^* z# E2 k                case 101:
+ P! s- S( V( S' |, _( v' A                    int Id = data.getExtras().getInt("id");1 [' y( ^. l! z; W4 h
                    MyLog.d("返回的ID:" + Id);
" _8 F4 _( ]1 E1 N) d                    if (Id > -1) {  I, _" [) ^4 N3 D# p4 I  n8 z
                        refreshMapPoint(Id);, H" k0 a! o. O: n. Y
                    }* D" l6 ^# ]" q6 h# |2 ~
                    break;
( t. p. L1 T7 d0 f                case 102:
' z% o$ ]- ~1 l, j                    if (data.getData() != null) {) ?% ?' h8 d7 F0 i( \
                        Uri uri = data.getData();//得到uri,后面就是将uri转化成file的过程。
4 z/ B. }' ~% l                        String img_path = uri.getPath();$ X- I* {/ K9 X9 l
                        try {
+ Z, B* M: }& B                            if (!TextUtils.isEmpty(img_path)) {
) n' t; m. l0 N% M0 D2 C                                readKml.parseKml(img_path);
5 I1 F2 Z8 l5 ]' _9 C. F2 [                                addSampleMarker();1 }* m7 v8 U; ]! F& N* F: q
                            }
8 M( @$ ^0 X2 q9 p% Q3 }/ s6 K                        } catch (Exception e) {, n( I2 J7 C) x
                            e.printStackTrace();
- b5 A* F% }" R9 M& m9 O$ E                        }# B% ~& T: y4 u
                    }
, C9 x( t, Z: `3 X" I                    break;/ O0 Y0 R6 \( ]$ J  w* Y  W
                default:7 R+ r' V, f$ r
                    break;
4 Q) y6 \! l3 D8 F  H  w8 }- h            }* ^- L4 j7 k- |" O$ D/ g
        }& u" _4 G( T! \4 X
        private void refreshMapPoint(int id) {6 W. [% H- c4 X0 c
            aMap.clear();* G/ A  O9 I1 {3 ^5 f
            mMarkers.clear();; Q! F( `' l% V$ D/ S
            mPointInfo.clear();
( [' v+ g" j4 c            mLinearLayoutInformation.setVisibility(View.GONE);: m4 M9 o: ^% i* i+ U; b
            mButtonFinish.setVisibility(View.GONE);
+ Q. m: G/ I  V) u            mButtonSetting.setVisibility(View.GONE);9 e3 Y. J' @4 X
            mButtonUpload.setVisibility(View.GONE);
2 {3 A6 h  r/ D  Y, t            mButtonStart.setVisibility(View.GONE);( O4 e0 \9 h2 ?! f, B, D% J
            mButtonStop.setVisibility(View.GONE);; W8 A2 @' M! x' }5 E' a+ f
            waypointList.clear();3 |9 [  W  a5 X. w, v
            mSQLiteHelper = new SQLiteHelper(SettingRouteActivity.this);$ z0 K7 O. i7 }7 M) M
            Cursor c = mSQLiteHelper.doSelectWaypoint(id);/ T1 _+ D( P5 }! l" C$ v& F! O; M8 a
            if (c != null) {, @4 e& i- p" N! v
                if (c.moveToNext()) {8 n+ l: J9 Z% G: J/ {4 d# N; ?
                    MyLog.d("航点:" + "{'pointInfo':" + c.getString(1) + "}");, j3 E' d5 n3 Z5 y$ v& Q; ^0 L
                    mPointInfo.addAll(GsonUtil.GsonToBean("{'pointInfo':" + c.getString(1) + "}", Root.class).getPointInfo());7 Y! K& K" a& i  r: h0 v) \
                    altitude = c.getFloat(2);  S, g/ _2 H% a/ w. s4 }* h
                    mSpeed = c.getFloat(3);
3 |6 m* g# }5 x0 A. c# `3 B                    switch (c.getString(4)) {* j! f) i" v: e- M% ~& P
                        case "0":4 ?" c4 V4 `9 T+ x0 _5 N
                            mHeadingMode = WaypointMissionHeadingMode.AUTO;
, N% T% u2 M; J! d                            break;0 X- y0 E( @/ z# B7 v5 d
                        case "1":- t- l3 T% A5 e' c. L+ z
                            mHeadingMode = WaypointMissionHeadingMode.USING_INITIAL_DIRECTION;
3 F$ j8 Z3 K# ~' M                            break;
/ A6 z, {, o0 N$ u# C$ S; i                        case "2":
1 o# e+ O: K1 Y' H9 F( D6 j" A# }                            mHeadingMode = WaypointMissionHeadingMode.CONTROL_BY_REMOTE_CONTROLLER;7 _% y  [- o1 e5 z4 n
                            break;
8 g, @1 z5 {8 M6 f% Y, |, X                        case "3":
+ ~7 o" s% K; A: ~8 t0 R9 @' g                            mHeadingMode = WaypointMissionHeadingMode.USING_WAYPOINT_HEADING;! U" r' R3 t8 j
                            break;
  G9 J7 u( R5 `  E  m                        case "4":
/ h6 Z5 e& Q# Z' L, J0 U                            mHeadingMode = WaypointMissionHeadingMode.TOWARD_POINT_OF_INTEREST;
3 p# X2 r4 j0 n3 e  p- Y1 J                            break;! t4 C9 ^/ Z- f
                    }
/ \) U% g7 Y, w1 j9 z- R                    switch (c.getString(5)) {
$ ?  V: j6 f/ E  _( N: ]8 \                        case "0":
+ z# A; u) c% \2 q                            mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;
# V  X& L$ s$ d- Q% @                            break;
9 ^! ^. ^7 X7 d$ b                        case "1":
- C$ \) {, o# Q; D                            mFinishedAction = WaypointMissionFinishedAction.GO_HOME;
9 ~7 y' ?& J( u* ^                            break;* {! V8 M9 ~/ i! }$ H, b
                        case "2":. c6 [! Y+ H* D0 O, R1 B0 f
                            mFinishedAction = WaypointMissionFinishedAction.AUTO_LAND;$ l8 ^$ A8 |7 P1 O
                            break;" X8 y+ x5 s* z( t# I4 l; I
                        case "3":
9 a- A: T3 A( T1 e. o                            mFinishedAction = WaypointMissionFinishedAction.GO_FIRST_WAYPOINT;0 q6 h) q3 b! O, {
                            break;
8 C( i, W' _3 j  e# Y                        case "4":& n; K* \+ [' H. K  R3 r
                            mFinishedAction = WaypointMissionFinishedAction.CONTINUE_UNTIL_END;' P0 ?; k* K! d
                            break;* C+ u! y4 z2 L/ I9 ?
                    }
# U2 Q5 h8 t) x7 q! U8 j" E                }
. a# j# i  B8 v0 X" u. n3 E            }
  x+ ]6 w: ^+ ?8 j% p            for (int i = 0; i new LatLng(mPointInfo.get(i).getLatitude(), mPointInfo.get(i).getLongitude()));8 ]6 |; x' K! G8 M* R1 `5 T4 O
                Waypoint mWaypoint = new Waypoint(mPointInfo.get(i).getLatitude(), mPointInfo.get(i).getLongitude(), altitude);+ b7 }* O; c0 J( w% B8 j
                if (waypointMissionBuilder != null) {
& x* p8 @) K+ _5 Y) ^& a: h2 k                    waypointList.add(mWaypoint);
$ n& ~; I, E$ }+ y3 E" Y                    waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());4 ?( k; ?7 p6 |4 e* [# B
                } else {
" V0 ~2 j! i" _' X) I                    waypointMissionBuilder = new WaypointMission.Builder();9 }! Z1 w/ Y6 {7 s% n7 K" B3 K
                    waypointList.add(mWaypoint);
2 g# Z' D% |$ B) B- c                    waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
, T" {! \, k% g( `' y, b: W                }
- \7 W, D! c( r            }$ E" I& j: T% j( T2 e* @
            aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(mPointInfo.get(0).getLatitude(), mPointInfo.get(0).getLongitude()), 18, 0, 0)));
5 q0 L7 j& m' ~9 s" K+ @            ResultconfigWayPointMission();
& a: A5 R9 J% C7 M            getWaypointMissionOperator().uploadMission(new CommonCallbacks.CompletionCallback() {$ x+ U, ^/ d5 b8 [5 h5 |7 v
                @Override2 k% S. Q& p+ R: l
                public void onResult(DJIError djiError) {
8 S( T6 J4 q8 H! h0 w0 K% b                    if (djiError == null) {1 _# _) F. Z1 ^% G
                        showToasts("获取任务成功!");
5 Z+ D% n5 Y3 S8 Q7 {7 q                    }
( A" Y$ T% ]8 s" N8 @4 j! k                }6 }' n! h7 i: z
            });
: U" K8 _9 r3 u! K7 O2 D  H        }+ R; P, ?9 g$ ]* T( m9 ]
        private void showWaypoint(LatLng point) {
0 T* }6 Q& y; P3 m9 E! t4 h            MarkerOptions markerOptions = new MarkerOptions();; M' l7 c: F- c* @; B
            markerOptions.position(point);( H) G% D. i4 V7 T
            markerOptions.title("航点" + (mMarkers.size() + 1));& e! }+ T6 E4 E# }( Q5 M; i, T
            markerOptions.snippet("事件:");
- n, l' `6 X2 g            markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));3 d0 _5 v, r5 K- [0 V
            markerOptions.infoWindowEnable(true);5 ~) @& A0 W* s  e# h0 s1 w
            Marker marker = aMap.addMarker(markerOptions);
8 K) I5 ~+ k9 l! }& Q: n            mMarkers.put(mMarkers.size(), marker);
) I& A( ]: g- S: _            marker.showInfoWindow();0 |0 n4 S8 Y6 A6 ]
            if (mMarkers.size() > 0) {( C  O' r, |& \& s. a
                mLatLng.clear();
0 [( r, ?' |. y                PolylineOptions PolylineOptions = new PolylineOptions();( l3 h3 d: r" X; i3 P
                for (int i = 0; i 10);
% A- I; s- n/ s3 ^9 ^                PolylineOptions.color(Color.argb(255, 1, 1, 1));& |0 j! C2 e( n+ y- }
                aMap.addPolyline(PolylineOptions);
+ b$ n8 k) ^1 D* d1 X( C/ C* ]            }
+ ?; u, d$ D+ p5 y3 A        }, G8 f( v7 V& R  A; p, i
        private void ResultconfigWayPointMission() {' u' n9 H" M% g' D6 \
            if (waypointMissionBuilder == null) {4 ~; ~; D2 Z" s5 l5 A5 k9 J. O
                waypointMissionBuilder = new WaypointMission.Builder().finishedAction(mFinishedAction)
8 C1 Q7 D9 g  i" m, X. V                        .headingMode(mHeadingMode)1 |9 V5 ]1 T) q
                        .autoFlightSpeed(mSpeed)
7 {- S+ T, i7 \# E4 R: s                        .maxFlightSpeed(mSpeed)2 I7 J- N4 v7 O8 q
                        .flightPathMode(WaypointMissionFlightPathMode.NORMAL);; D" ]* Y6 ^# G" k, s5 j# M) |+ U( w9 S
            } else {+ r% T# @* [. r" {& a- Z( q. h
                waypointMissionBuilder.finishedAction(mFinishedAction)
# J* _- G3 R- l; n: J: w                        .headingMode(mHeadingMode)9 h  ~9 \8 g' k' M0 z  T0 W& F, o: j
                        .autoFlightSpeed(mSpeed)8 m2 T4 ?- o% {1 m- S
                        .maxFlightSpeed(mSpeed)
8 `/ F: I% J% w, ]5 h8 [5 k* w( [4 h                        .flightPathMode(WaypointMissionFlightPathMode.NORMAL);+ X! V% A2 o, R* I7 M1 i
            }  }! R" N2 P" E
            if (waypointMissionBuilder.getWaypointList().size() > 0) {, y) X+ z( V7 k  O8 V5 `/ r
                for (int i = 0; i if (error == null) {7 e1 C1 f/ T, S6 f/ K
                if (mLinearLayoutInformation.getVisibility() == View.GONE) {% y: H; Z. `0 |& q" F
                    mLinearLayoutInformation.setVisibility(View.VISIBLE);* }7 s. I2 Q8 @  D2 b, E) C
                }  V4 S5 q+ m- q( M, n
                mButtonStart.setVisibility(View.VISIBLE);. f  Q# ]2 |3 _; f
                mButtonStop.setVisibility(View.VISIBLE);' P$ |* c, b( Q  {% t2 [. x' r
                mTextViewHeight.setText("高度:" + altitude + "m");
/ t# J" |) w1 r. H0 Y                mTextViewSpeed.setText("速度:" + mSpeed + "m/s");
* ~( ~: q  w" _* _# M& t5 Q1 P( i                mTextViewCount.setText("航点数:" + waypointMissionBuilder.getWaypointCount());
1 h/ M2 T; D* p: }: `" e                mTextViewDistance.setText("总距离:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");
& F& k* M# L" o                mTextViewTime.setText("总时间:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");+ U% C* K+ [" ?
            }. U0 B% E# X" A. E) q6 m; F1 P
        }
7 V) E7 c, S! [' b: `. T        private void addSampleMarker() {
$ L3 [. Q" D7 x8 y9 ?8 }9 `# C# w            if (ReadKml.addSampleSuccess) {
4 u! c- S9 k8 @2 h4 d; U' i4 `( U; ~                aMap.clear();
" P2 z# T9 Z$ d; s: m                mMarkers.clear();
6 y$ m& |" ~, b! V6 |) {+ s: h1 V                mPointInfo.clear();
& K/ w4 L" k) ~8 o: R! r) ~. I                waypointList.clear();
" T: J3 W; T, U/ a% E                if (mLinearLayoutInformation.getVisibility() == View.VISIBLE) {
; [" I& P. N9 C                    mLinearLayoutInformation.setVisibility(View.GONE);8 N5 |9 r) A% i. ^" v
                }+ }  d# }. N: N
                mButtonFinish.setVisibility(View.GONE);8 U6 z' g" G4 K- K( h4 w3 |# ^2 J
                mButtonSetting.setVisibility(View.GONE);- P; R% b; m- G6 u8 [
                mButtonUpload.setVisibility(View.GONE);/ ]/ ]+ q# ~! d! H) g$ e0 ?
                mButtonStart.setVisibility(View.GONE);
# m7 L* l! [' P                mButtonStop.setVisibility(View.GONE);
& C8 o7 g( n" F+ _) h0 _5 x2 Q                for (int i = 0; i new LatLng(sampleList.get(i).getX(), sampleList.get(i).getY()));; Q9 r) K" Y/ |* q  V( T
                    Waypoint mWaypoint = new Waypoint(sampleList.get(i).getX(), sampleList.get(i).getY(), altitude);
0 B& _, X7 l/ i& l                    //Add Waypoints to Waypoint arraylist;
7 n* ?7 s- g$ C$ U9 o  s                    if (waypointMissionBuilder != null) {  }# g3 ~. K8 L
                        waypointList.add(mWaypoint);
- |' F( w( i( c# h& \! l3 ?; f* O                        waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
: y) W% c! p; @                    } else {& g- C% j1 @* D4 h9 I2 ^* j1 ^
                        waypointMissionBuilder = new WaypointMission.Builder();( N$ A! S* F! v0 C- w/ b6 k; v" d
                        waypointList.add(mWaypoint);+ N! Q; X' `- G$ h& u/ Q4 U! S5 W
                        waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());9 \( H4 \5 Q5 X. C3 a
                    }4 h  d) e9 j8 q& t% D
                }) H7 H1 i0 i7 b; g1 f
                aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(sampleList.get(0).getX(), sampleList.get(0).getY()), 18, 0, 0)));
1 H/ h6 R* f8 O0 `& @: c                showSettingDialog();
& ?8 D3 B6 |# h                mButtonSetting.setVisibility(View.VISIBLE);( c  a/ |: h2 v9 ^8 c
                mButtonUpload.setVisibility(View.VISIBLE);/ {2 ~8 J" c$ x  m
            } else {
8 k0 V! I' _# y0 s$ r& f                Log.d("MainActivity", "addSampleSuccess is false or aMap is null");9 ~3 J7 E1 B. s/ J; F! g5 k
            }3 M0 K; \0 B& [/ X) S
        }% \. y/ _) n9 Y7 _- ]# h2 H1 G2 f. D5 y

: W& s- T) H& D30 `$ \4 P' _( Q- l& t9 g' A8 z
航线管理4 ]" X8 x5 r8 E' S! c
创建activity_waypoint.xml和WaypointActivity文件。% ]* U7 N, v, H9 Q# t( t2 j& W' k

/ F( ?7 l6 ?; w! i) j. E( J+ lactivity_waypoint.xml' z! `( A5 `! E  X8 S0 d( x
, j6 N$ Z; [, _" f
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4 V9 g9 @4 |% r- X    xmlns:app="http://schemas.android.com/apk/res-auto"
  `% u8 F) }, D    xmlns:tools="http://schemas.android.com/tools"; r# x+ x# a4 D7 Z6 J& i
    android:layout_width="match_parent"1 l0 u& y3 n! d  v& K/ P# s
    android:layout_height="match_parent"
, `) b0 d9 @8 {7 C0 T; b; ]    tools:context=".ui.WaypointActivity"- B: t. r. U( L. G
    android:orientation="vertical"
/ m1 @0 u$ `' P5 d9 ^7 k    android:background="@drawable/shape_corner_eight">7 d' {- Z  J) N1 ^' f
    include
5 N0 Z% N3 G* `  E: g- i$ ]        android:id="@+id/layout_waypoint"
1 t$ y: h+ l9 s" t! J8 P" E6 g        layout="@layout/activity_toolbar">include>4 m8 h) [4 @" B0 i+ M+ L( l
    View" |- p- r  V" |' Z
        android:layout_width="match_parent"* g" W5 Z6 U3 q2 [5 O* Y+ v
        android:layout_height="1dp"
5 K: i) t: i1 N, f( j- v" P# c        android:background="#5B6782"3 L+ Q* h- A' h- G& d0 s9 C
        android:layout_marginTop="1dp"
, H6 A5 ^  O* _1 p; K3 s* i        android:layout_marginRight="20dp"; F3 n' F2 Y& E: b& v1 e! z/ y/ b
        android:layout_marginLeft="20dp"1 L6 G* v, x/ z4 T) q$ O  V
        >View>$ ]8 K+ O2 m% L
    androidx.recyclerview.widget.RecyclerView
$ [' M" J* F4 D9 @3 L% N9 z+ A3 p        android:id="@+id/rv_waypoint": w0 o/ ]7 Y0 }5 I' }
        android:layout_width="match_parent"+ L: o6 ^3 H+ w. A0 x4 V1 ~
        android:layout_height="match_parent"
# e& C) u( M2 G0 _- Q        android:layout_marginRight="20dp"
2 O+ ~/ d/ I& C3 U+ U        android:layout_marginLeft="20dp">androidx.recyclerview.widget.RecyclerView>/ a* ?6 Z& f- j
LinearLayout>/ i, D( ~9 E5 d9 D: {# e) U- g
WaypointActivity
3 U; e1 X$ x5 f3 h/ |% ~. Y3 q0 t, f( R* X
@Layout(R.layout.activity_waypoint)
6 C: z7 j1 ^* T1 J3 m9 |7 V* Npublic class WaypointActivity extends BaseActivity implements View.OnClickListener {
' Y" E- ~, Y& t, h    @BindView(R.id.layout_waypoint)
5 q( E4 C8 b6 x* K5 o& x" S5 }* ]    View mViewLayoutToolbar;, S% C! M+ S6 d4 b0 ^  k1 W
    @BindView(R.id.ll_waypoint)/ }0 L, x) U. J* h+ j, t; x
    LinearLayout mLinearLayout;# d/ V' A5 i5 ~; }* c2 E
    @BindView(R.id.tv_toolbar_title)& j! ?6 x0 S7 ~: e5 I
    TextView mTextViewToolbarTitle;1 M! e/ L. ?+ r" S# K" x, O
    @BindView(R.id.rv_waypoint)
1 {2 x9 _! w1 e# U8 t    RecyclerView mRecyclerView;1 j: w) H- n. w6 @, D* d# c* e
    private SQLiteHelper mSQLiteHelper;
5 m* j( ]( m' u0 w. i# F6 _7 D/ @9 J    private List mWaypointInfo = new ArrayList();. Y1 W/ I% L3 H6 {" i4 c8 I3 i
    private WaypointAdapter mWaypointAdapter;
3 v. d$ U+ r3 C& E  q& _; d    private List[I] mWaypointId = new ArrayList();6 k/ X1 u. ^) `: U8 ^: y
    private String StrId = "";
- U/ O3 D! ~; o& C2 `0 H    @Override
0 X& \# d( F+ G: G    public void initViews() {
; g/ n4 ]7 [' ?( y9 H        mLinearLayout.setVisibility(View.VISIBLE);
0 G$ l$ f3 ?) {6 n6 _        mTextViewToolbarTitle.setText("航线管理");; d0 \6 o% G. f5 u. q  g
        MyStatic.isChoose = false;3 r5 s4 \/ v" `  a9 v0 f
    }2 w) J/ X- @1 x; ?' @: y4 t
    @Override) e) ^# y$ C. {& g: C! _
    public void initDatas() {
5 l+ I( O& O  n! ]/ j& E3 U        mSQLiteHelper = new SQLiteHelper(WaypointActivity.this);
- U. R8 _8 Y( l6 H8 M0 w: h        Cursor c = mSQLiteHelper.doSelect();2 O  T$ D/ X, k% x) k2 I1 K
        if (c!=null){
4 U" B& W9 e1 J! x$ |* D8 G0 L            while (c.moveToNext()){
/ `+ }( Y7 r! p$ `9 C# W                mWaypointInfo.add(new WaypointInfo(c.getInt(0),c.getString(1),c.getFloat(2),c.getFloat(3),- {9 c, ?9 W: P; L  q7 a: k
                        c.getString(4),c.getString(5),c.getString(6),c.getInt(7),c.getInt(8),
& g. F& }5 H0 {" B0 O7 W/ ~                        c.getInt(9),c.getString(10)));3 C% e# s1 N3 U1 N: o6 N
            }: @! c3 T/ {/ S# {% @
        }: ~1 Z6 I& u" A( |$ V7 K( j
        c.close();2 K2 H4 |+ y* i1 W- y7 A+ @
        mSQLiteHelper.close();
8 }% b$ x- o( |  h  a        mWaypointAdapter = new WaypointAdapter(R.layout.item_waypoint);! f# Y1 K! V" m
        mWaypointAdapter.setNewData(mWaypointInfo);
" I* \% ?/ F( s* O        initRv(mRecyclerView,mWaypointAdapter);
; n. b# b3 Z; i# ?3 g        mWaypointAdapter.setOnItemchildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {$ M4 X) j3 a- h: d& m0 f0 C; u  n# }
            @Override
& n2 o5 Y% n2 p+ Q$ I$ f# b            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
4 d. M" |1 Q3 {6 E1 ^* O                Intent intent = new Intent();
. v% j1 A5 F' T4 h8 ~                intent.putExtra("id", mWaypointInfo.get(position).getId());0 K+ l3 R) d# |2 }( M# F
                setResult(RESULT_OK, intent);$ b3 ?4 G) _! X7 K9 U5 D# b
                finish();# Y( J. X! u# j. n0 z
            }
7 [% a3 [/ [8 _9 K        });
4 D) v) H- n, u        mWaypointAdapter.setOnCheckboxCheckedListener(new WaypointAdapter.OnCheckboxCheckedListener() {( ~6 V% J( ], j3 j" G1 m% K& M
            @Override$ J7 C8 ?- W# e" N9 L5 q
            public void OnCheckboxChecked(boolean isCheck, int position) {
9 i, x& [. i0 H' h4 J& D) X                if (isCheck){
% D# N. V+ B3 ?6 A' o7 k8 H) `                    mWaypointId.add(position);
" P, g+ C1 U; ?# B                }else {3 N: U2 Y1 n. \5 x9 P/ ?
                    if (mWaypointId.contains(position)){2 T2 f+ A9 ~$ H5 U" r
                        mWaypointId.remove(position);
% c9 B7 H+ f; E# x2 o                    }9 R8 `: _* A3 _; }( `
                }& R9 N8 Q6 I8 O' m) w0 N
            }
# K/ ~) P" `9 m6 [        });& l- [$ {& ^4 ^' Y" w; H8 Q. I
    }
" P. S" }- w1 \9 a0 w" u; J    @Override
3 s  z& }' {. K; |8 s    protected void requestData() {
$ ^% ~9 |/ v* C/ Q0 C    }
' {6 ~6 w: i( U- a0 L5 |; J    @OnClick({R.id.img_way_choose,R.id.img_way_delete,R.id.img_back})
' [# ]8 G+ o& H5 {5 @    @Override* r9 j/ T( X* |( M
    public void onClick(View v) {4 N: c, G& d3 Z  Z3 }
        switch (v.getId()){& J2 @* J6 o/ y
            case R.id.img_way_choose:, d3 x' B$ t* n2 x
                if (MyStatic.isChoose){' A1 _, t- _/ q8 k5 Y
                    MyStatic.isChoose = false;. e3 ]3 m4 Z' E  d
                }else {
6 @( v- Z) g' P& R; o4 i: ]                    MyStatic.isChoose = true;
9 @0 P7 d& m4 `( q' N0 I                }
! s8 X) G* _9 s( I" q9 A; F                if (mWaypointAdapter!=null){
: @: ~- w  R. `3 H( R                    mWaypointAdapter.notifyDataSetChanged();6 |% a" k7 d) ^: s0 A/ r
                }
  a+ V" u% i+ F5 R; x2 `. R                break;
; A- a( \  D9 I- @            case R.id.img_way_delete:$ i. k3 R$ k4 s8 F
                if (mWaypointId.size() > 0){3 d: J( _; G" \) @
                    for (int i = 0; i ",";
% [5 ?1 d' e: n3 c+ n                    }3 ?3 Z3 l6 a2 X: ?
                    if (!TextUtils.isEmpty(StrId)){* y) \( g( L5 g  `
                        StrId = StrId.substring(0,StrId.length()-1);
7 |/ ~9 H- e# \& @4 w                        mSQLiteHelper = new SQLiteHelper(WaypointActivity.this);
; d7 d% ~( N/ i                        mSQLiteHelper.doDelete(StrId);
8 Z9 |: Y& P, [8 f                        mSQLiteHelper.close();
% _/ l" ?4 k, e- x1 z                        for (int j = 0; j if (mWaypointAdapter!=null){+ t% L4 \/ n' X+ Z0 ?+ i
                            mWaypointId.clear();
% W' i# n; N; W9 E1 Q5 H# S                            MyStatic.isChoose = false;
( g3 u& N& q8 f5 t                            mWaypointAdapter.setNewData(mWaypointInfo);: m" f  [; h" Y9 @
                        }
4 C' L" y( e7 ^% O                    }. n5 S& ?5 @9 h8 f% F- D% |
                }else {# c1 t4 t9 I! I4 i3 `( m
                    showToasts("请先选择删除的航线!");9 }" a, m2 Y' h& A  b3 j
                }# W2 `( M8 c9 b
                break;& E5 L) p7 T# @9 ~* c3 V" I  {
            case R.id.img_back:
3 x6 v2 x# O9 @. h( M9 j                Intent intent = new Intent();5 H* k# i- v6 g% d3 c. ]
                intent.putExtra("id", -1);- N/ c/ k- ?( N5 t( w+ X
                setResult(RESULT_OK, intent);, \8 a  u* e! x
                finish();3 |4 [1 S! c+ `. a
                break;
0 L3 o$ p  |, @; ?8 h) C        }
5 G. W9 D! v9 R8 v    }6 {. u" `$ P, M; r- `3 |
以上代码仅供参考,如果想了解更多的大疆无人机二次开发过程可以私信我,源代码因为涉及到商业使用不能给大家共享,有什么问题我可以帮你解决。1 a  Q! d! D+ W) y7 t0 [

h3i1eui0cv56406114743.png

h3i1eui0cv56406114743.png

* V1 d! `% V+ S: b, M& G4 h1 ~往期推荐毕业设计So Easy:基于C++实现网络扫描器2 \1 |; y( T! K; w
详解CAN总线:CAN节点硬件构成方案# |6 E) A% @4 c" y
LabVIEW串口通信
9 G- u: P: K: SLabVIEW感兴趣区域分析(实战篇—1)9 p  i- L" L( s
Python Qt GUI设计:信号与槽的使用方法(基础篇—7)
$ [* V/ \& j4 R8 f# }和12岁小同志搞创客开发:如何使用继电器?' `: K& p" A$ X7 @. v
PCB天线无线模组如何布局摆放?; l9 B" A+ p9 i3 \& g1 e
芯片内部长啥样?牛人用1500张照片,一层一层放给你看!
# u, V9 }/ R! Y( {$ r; V移柯L620模组使用MQTT协议连接移动OneNet云平台
1 v* a) m; W. ^' U. _& @6 Y

! \. q( e8 {  C( ^8 D: E

ctcsti0dr2r6406114843.jpg

ctcsti0dr2r6406114843.jpg
4 }% A3 Q* J0 L! W7 k

slgjzpot3pc6406114943.gif

slgjzpot3pc6406114943.gif
" B* b! b0 w  M9 Y8 X
点击阅读原文,更精彩~
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


联系客服 关注微信 下载APP 返回顶部 返回列表