电子产业一站式赋能平台

PCB联盟网

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

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

[复制链接]

1001

主题

1001

帖子

8803

积分

高级会员

Rank: 5Rank: 5

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

twi14romqoi64018801549.gif

twi14romqoi64018801549.gif
' E  f: p5 L- q; `" l
点击上方蓝色字体,关注我们  ~8 y# Z% x& C* f$ L
, j  c% G1 U* L- a5 y( K" Y0 m& P

0 q3 v9 ?8 C% h( `3 W  L& E) n第三篇文章准备单独拿出来写,因为在大疆为人机的所有功能中,航线规划的功能最为复杂,也相当的繁琐,这里需要说仔细一点,可能会将代码进行多步分解。
: _, P. [: g( ?1; Z+ j* I" |2 \3 [6 ]
航线规划- k  Z; {, u7 k
航线打点 ( z4 x; c& a' `& f

$ Z. h% e0 H' @* h* M  |在地图中手动选择点位选择完成航线打点;若打点位置错了可进行点位删除。
2 R* ?" B$ @# \3 q* {6 {/ l) x1 d, W

msnicmq2xie64018801649.png

msnicmq2xie64018801649.png
) r9 f+ O$ d" G' k& e5 f

' S( G8 b# k: g& Z; W5 D航点设置 & {5 I6 N+ R# ]; s& Y& K

" Z5 {  _) v! C/ `$ j, `1 X' E- N' T可对航线点位进行设置,如飞行高度,速度(慢速:3m/s;中速: 7m/s;高速:10 m/s)、任务结束后操作及航向,点击[设置]按钮完成设置。
( p- O! w2 b( T# [

xbv0irdmaaw64018801749.png

xbv0irdmaaw64018801749.png

* ]# E/ M" m# P设置完成后会显示总距离及飞行总时间。
" z" ^' u; ~# A) b/ G

t2ntapgqvb164018801849.png

t2ntapgqvb164018801849.png
$ V7 _: W8 c/ z: ^: G* p6 M

+ f+ ]# e5 g, z8 N航线上传# x: t' l& K3 k, I8 ?. L  P! R& z

5 L7 |0 u0 K4 d+ u. y6 O8 z点击[上传]按钮,进行航线上传。可以进入本地存储中选择航线文件进行上传,航线文件为 .kml结尾。
3 Y  P. f, T4 V; ^( Q/ E

g54axfrfywk64018801950.png

g54axfrfywk64018801950.png

5 Z$ v  b3 R% \& f% s+ }* M  J* |% O" @( X( }
航线执行
9 z4 h! O. ~1 v! C4 `, @* g9 `4 o% g! M) ]( r* y! l
点击 [开始]按钮,则可对航线进行执行。若中途需要暂停也可点击[暂停]安装进行暂停操作。9 F" W  Y% a8 b( z6 R3 G

br0ug2zuowp64018802050.png

br0ug2zuowp64018802050.png
7 W5 r- p0 Q) y! a

9 ]- M& ]: ?6 P0 t2 V1 {; Q航线管理
' x. {  f6 U5 ~, m
6 M  O* f- Q7 a, B0 l: \按钮即可进入航线管理界面。; U0 n! m" S* I8 P  r
2 g. C( I+ ^8 P* U% V& q7 s% |

3exslznao0p64018802150.png

3exslznao0p64018802150.png

% }. M7 l- Y. d- `% _4 v8 }7 i
9 C" _2 t* ^9 P& ]8 |获取航线
: J9 N( o' e6 ^; S
9 s( w. F" s0 O* W点击[获取]按钮,即可将航线信息展示到地图界面中。! Q+ d1 n7 T- z; N: [: {

8 g/ Y% T4 ?4 h) T1 j( [1 {% @, h2 S8 h
2
8 `" ]4 G. ]1 G, D9 X9 w* |主要功能代码9 Y$ t+ ]4 Q& r
创建activity_setting_route.xml及SettingRouteActivity文件。) ?: j9 o/ G+ s/ k' o

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

9 @1 |- d! x2 q4 \) B$ V3" |& I6 f; g& q: s2 `4 i: W
航线管理8 D' c3 r4 t, ~. u; t9 v, ]
创建activity_waypoint.xml和WaypointActivity文件。/ j5 {. X3 O- d1 x8 C, @1 s$ @! a
8 |, r' f5 Z$ i, S+ \
activity_waypoint.xml2 e$ G) D1 ^1 n8 |' O, J" g+ `
' h, g6 x8 X/ B5 h# X2 S
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"0 Y: x8 J- C4 l/ r7 |; K- J5 n% g
    xmlns:app="http://schemas.android.com/apk/res-auto"& i6 U! `0 t; T# y' C+ f  m- c
    xmlns:tools="http://schemas.android.com/tools"" B/ v2 K7 S6 V- Y7 M' P4 J
    android:layout_width="match_parent"
2 `, A" B0 t, o0 e9 `' P    android:layout_height="match_parent"$ ~& I1 \  K" e9 f4 H& u/ j4 k
    tools:context=".ui.WaypointActivity"
2 H% ?9 j( A( L+ ^3 }+ e5 }. n    android:orientation="vertical"
& _6 t+ \; F: F: i* x1 Z; O    android:background="@drawable/shape_corner_eight">' m1 ^; G9 s" o1 |% J( J
    include8 ~% t0 L4 g! n4 O
        android:id="@+id/layout_waypoint"
$ z# d+ Y7 ^( @2 b5 `! c        layout="@layout/activity_toolbar">include>0 R) s* u  @4 o" t6 ]- W- D
    View
) e7 X4 |- D, N/ ~: e5 s- ~        android:layout_width="match_parent"8 E. t' e/ Q" w4 O0 S
        android:layout_height="1dp"; e- |  q5 T5 R+ T; P+ y3 i! S
        android:background="#5B6782"5 `" Y) @( K: X
        android:layout_marginTop="1dp"5 n5 Q* o. v2 F7 H5 h4 ]
        android:layout_marginRight="20dp"
# N& Y# f9 ?1 R* D# b        android:layout_marginLeft="20dp"" _  R/ C% W0 }, b6 M: p9 O
        >View>
5 c& n, d8 f! `1 v' o# Z3 Y3 R    androidx.recyclerview.widget.RecyclerView
5 H4 ~2 x7 S, E. M        android:id="@+id/rv_waypoint"$ L" k& d& T4 `% `; S0 d4 ?$ K2 B
        android:layout_width="match_parent", ?6 B, \/ h- ^9 q: Q0 d1 D& ^& E
        android:layout_height="match_parent"
: ]6 Q2 r) n2 j" [) g        android:layout_marginRight="20dp"
) A- s$ S) b. M, q4 h- ~. x8 c; l        android:layout_marginLeft="20dp">androidx.recyclerview.widget.RecyclerView>% |) N! r3 r/ W, e6 ]! p4 f4 l/ G
LinearLayout>
9 K. l2 E. g1 d# p8 J# I7 kWaypointActivity
$ b3 w' c# P# n$ |/ v0 {) i+ E4 V% ]8 v3 O& d! ]  }% e! Q
@Layout(R.layout.activity_waypoint)
7 i, ~0 u+ ?1 j# Cpublic class WaypointActivity extends BaseActivity implements View.OnClickListener {2 l* r9 d9 {9 M3 Q7 X! K- N: ?7 m
    @BindView(R.id.layout_waypoint)
) p1 P+ n6 y( a: T7 R' ]: v    View mViewLayoutToolbar;/ o0 j# f( s0 X1 r! |  d
    @BindView(R.id.ll_waypoint)
; v7 @+ n! x; x4 p    LinearLayout mLinearLayout;6 \2 C5 l' l) p2 m3 N+ T
    @BindView(R.id.tv_toolbar_title)
/ U+ c7 w1 f! N5 d; O    TextView mTextViewToolbarTitle;- y  S$ j5 C# L
    @BindView(R.id.rv_waypoint)7 Y& F2 c" H4 }  e6 a7 A% r
    RecyclerView mRecyclerView;! q5 m/ T( Q$ U
    private SQLiteHelper mSQLiteHelper;
. R( P# L/ w! R8 X    private List mWaypointInfo = new ArrayList();
- C9 V  h3 F1 R0 b6 G; Z1 O3 |9 j    private WaypointAdapter mWaypointAdapter;$ G1 b" k3 R: [: J
    private List[I] mWaypointId = new ArrayList();
/ g$ }' [  Y; c1 e: \7 ?5 m1 k: _6 `    private String StrId = "";; u" g& |, N/ Y# P* s
    @Override
4 ^, X: \- k8 F    public void initViews() {
- o3 H8 n% J' v! w* M        mLinearLayout.setVisibility(View.VISIBLE);
) s: U$ |5 c4 l$ S7 c        mTextViewToolbarTitle.setText("航线管理");
; a  I, ?2 U7 e( V) m+ N        MyStatic.isChoose = false;; s9 t. u7 O5 ~4 X
    }# N1 q; G% O& }: x
    @Override
; t- z# h6 g  Z# v    public void initDatas() {/ J1 w4 a: \% Z, E
        mSQLiteHelper = new SQLiteHelper(WaypointActivity.this);! k4 e/ }; T3 k: G2 H& L
        Cursor c = mSQLiteHelper.doSelect();
2 L% T+ |6 |: n, \+ C# \6 l        if (c!=null){, ^3 S  b* W' y. U& @1 |
            while (c.moveToNext()){
* n& c2 [, s1 J% Y6 k- b; N                mWaypointInfo.add(new WaypointInfo(c.getInt(0),c.getString(1),c.getFloat(2),c.getFloat(3),
" E& ?* M; V* Q- s# h                        c.getString(4),c.getString(5),c.getString(6),c.getInt(7),c.getInt(8),( v  E6 e4 E" O5 ]' b& l
                        c.getInt(9),c.getString(10)));8 m5 A+ w! Y; H8 v. @
            }, i$ b$ W( B+ _/ W( \. D& e/ h( N7 E
        }
8 c" {  b% E  c        c.close();
# V* d6 E3 c# ]8 o' ^        mSQLiteHelper.close();1 J. `" H3 A8 O  ]  }
        mWaypointAdapter = new WaypointAdapter(R.layout.item_waypoint);! T0 b4 @' T& a  ]" e
        mWaypointAdapter.setNewData(mWaypointInfo);
) g9 t% C" V! e7 i        initRv(mRecyclerView,mWaypointAdapter);
* [8 T0 m& {* W9 E8 K8 z( `        mWaypointAdapter.setOnItemchildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
$ M' U5 E- L; e: z            @Override! r5 P0 b* F) @) X
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {% M. U' E8 [7 V" R& X9 t/ M% |: A
                Intent intent = new Intent();
; c0 j; m4 X! V  U9 D4 N1 X; M                intent.putExtra("id", mWaypointInfo.get(position).getId());6 d1 O7 w4 [% x1 K. t; @
                setResult(RESULT_OK, intent);
. k6 x& q/ M" n/ p+ g0 u                finish();
1 \$ o9 f! o' E3 |. e1 Q1 k            }: p5 r% z$ v" L8 H/ t5 p. Z: S
        });/ x6 _2 V' s7 R: H: p% s
        mWaypointAdapter.setOnCheckboxCheckedListener(new WaypointAdapter.OnCheckboxCheckedListener() {' T5 j  T6 U( A5 o4 [! f# H
            @Override
5 o" ?5 ]/ S) C8 @# d0 A+ J9 A+ L- |            public void OnCheckboxChecked(boolean isCheck, int position) {8 A8 X5 u8 s* R( k8 W; p0 A1 N
                if (isCheck){
2 t+ z: `! e% k8 |* Z8 P- ^                    mWaypointId.add(position);* n# l) m/ ^; k0 _, x$ t- t
                }else {
: t  G, {0 X- q' K4 S4 H                    if (mWaypointId.contains(position)){% p' @' c2 x' |$ ^+ W/ i
                        mWaypointId.remove(position);
7 K* T7 H- [' ^7 k0 y                    }" p5 q; a3 G3 F4 z$ L
                }
  w$ g4 V/ y  t$ {7 d' s  o            }
" O) G& W7 e6 N3 _0 _        });
9 `4 ^0 W; a. b. P# f    }' Y3 m2 j! J" S0 o! _3 h( h
    @Override
: i- i# K) W. r1 F    protected void requestData() {4 J, }/ w# Z6 C1 q
    }
/ n, A$ g/ w  X0 _8 s    @OnClick({R.id.img_way_choose,R.id.img_way_delete,R.id.img_back})
  }4 U' }. g1 n) j- _/ l) [; r! k3 r' [    @Override
5 T* F  n* I5 N$ D* v    public void onClick(View v) {
9 D1 M. \  j: g: p, `8 X. S5 P+ I  u- c        switch (v.getId()){
# W6 j  U5 S# x4 c& f4 `            case R.id.img_way_choose:' _  [. ^/ ?6 k, `* _6 `
                if (MyStatic.isChoose){
) @+ X/ s( w( C4 t                    MyStatic.isChoose = false;2 e3 ^+ q. M' D( m! G+ ]. U
                }else {
1 n1 c+ Z! ~$ J                    MyStatic.isChoose = true;, `. v: p! R  Z/ V1 X
                }& A6 E+ h8 U* ]( P. q7 c0 }
                if (mWaypointAdapter!=null){( B& z: x+ |! M& \9 @9 `* Q
                    mWaypointAdapter.notifyDataSetChanged();
. p2 {0 K* Z, m                }
6 ?) ~1 O; K( ?: w$ W( q                break;
/ k1 [9 m8 {5 C: H/ J3 O$ k0 C: Y            case R.id.img_way_delete:
9 O4 a; B9 v9 Y1 x# |( k! A. d4 |0 n                if (mWaypointId.size() > 0){7 W4 |) R# `$ K6 T5 u
                    for (int i = 0; i ",";
$ Y( C0 i" `7 n. U( u7 q                    }
0 J, V/ \7 t" f6 w& y                    if (!TextUtils.isEmpty(StrId)){; J# f( ?8 z; d1 m7 \7 r
                        StrId = StrId.substring(0,StrId.length()-1);8 f. F0 L* p/ I1 u9 z9 Q3 L& _
                        mSQLiteHelper = new SQLiteHelper(WaypointActivity.this);' N! j. ?" U% @! ~. ]
                        mSQLiteHelper.doDelete(StrId);
0 D2 @% _( w1 A5 K, {" e0 A                        mSQLiteHelper.close();
% I9 ~3 y; W8 z4 @4 x: d                        for (int j = 0; j if (mWaypointAdapter!=null){) L( h8 `' o# r* v+ j$ j
                            mWaypointId.clear();
1 b' y. l% X2 }' C                            MyStatic.isChoose = false;
& q' |4 [; P6 x4 s                            mWaypointAdapter.setNewData(mWaypointInfo);+ j1 ]# D/ H6 H4 C7 ~
                        }8 t7 ^7 S, [# e0 B. I: _' Y
                    }
5 a# }. \6 F/ c" c1 J% j) u                }else {
1 A' [0 A  g, b                    showToasts("请先选择删除的航线!");( R2 k6 W7 l2 X6 K& B4 i: a( S2 i
                }
, h" E2 I* J$ u                break;
4 ]: A& w# w( ]" _5 U: Z            case R.id.img_back:
* y# J, S, v$ S0 n$ N0 V# p7 G                Intent intent = new Intent();( l3 G, U/ O+ c# [
                intent.putExtra("id", -1);* G6 p( Q0 L& `8 F6 h! X- ~
                setResult(RESULT_OK, intent);6 X3 U8 {  w5 l  {4 g
                finish();
1 D2 K: R8 F; h                break;
$ ?: H- ], @' B, `; g        }4 Z3 j4 U, j% w/ e' Z2 C8 J7 `
    }6 a5 H: `8 v  }+ s" X8 o
以上代码仅供参考,如果想了解更多的大疆无人机二次开发过程可以私信我,源代码因为涉及到商业使用不能给大家共享,有什么问题我可以帮你解决。; |% v( d% |  b4 f4 w2 w

zklwwr55t3a64018802250.png

zklwwr55t3a64018802250.png

. z- m; X/ w# f( x' J往期推荐毕业设计So Easy:基于C++实现网络扫描器
, e* d! j8 M8 q$ ~; U0 R详解CAN总线:CAN节点硬件构成方案( f8 E. X6 {' T. d
LabVIEW串口通信
' B( E' \( W! s* Y$ yLabVIEW感兴趣区域分析(实战篇—1)# V# D4 U1 o' h5 H$ ~: w
Python Qt GUI设计:信号与槽的使用方法(基础篇—7)/ z! U9 S9 z4 l- u" [8 a. M( @/ z1 k
和12岁小同志搞创客开发:如何使用继电器?# J; i. `  j6 g. c
PCB天线无线模组如何布局摆放?
5 f4 O6 ^; c; s. J4 C; g/ [芯片内部长啥样?牛人用1500张照片,一层一层放给你看!( x8 k) i4 F: }+ [" ]
移柯L620模组使用MQTT协议连接移动OneNet云平台7 n9 l4 P. B3 ~- l0 |! y% o3 l0 v

0 p3 f. V4 E9 E3 |

1n5zdhx11he64018802350.jpg

1n5zdhx11he64018802350.jpg

% j7 P. z7 x, ]7 i* J

hjp3c1pjfow64018802450.gif

hjp3c1pjfow64018802450.gif
, a# W; F( V: N9 k, S1 D
点击阅读原文,更精彩~
回复

使用道具 举报

发表回复

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

本版积分规则


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