@@ -6,20 +6,21 @@ import android.view.LayoutInflater
6
6
import android.view.View
7
7
import android.widget.LinearLayout
8
8
import android.widget.TextView
9
- import butterknife.OnClick
10
9
import com.dji.sdk.sample.R
11
10
import com.dji.sdk.sample.internal.utils.ToastUtils
12
11
import com.dji.sdk.sample.internal.view.PresentableView
13
12
import dji.common.error.DJIError
14
13
import dji.common.util.CommonCallbacks.CompletionCallbackWith
15
14
import dji.sdk.sdkmanager.DJISDKManager
16
15
import dji.sdk.sdkmanager.LDMManager.LDMCallback
16
+ import dji.sdk.sdkmanager.LDMModule
17
+ import dji.sdk.sdkmanager.LDMModuleType
17
18
18
19
class LDMView (context : Context ? ) : LinearLayout(context), PresentableView, View.OnClickListener {
19
20
20
21
private lateinit var ldmInfoText: TextView
21
- private var isLDMEnable : Boolean = false
22
- private var isLDMSupport : Boolean = false
22
+ private var isLDMSupported : Boolean = false
23
+ private var isLDMEnabled : Boolean = false
23
24
24
25
init {
25
26
initUI(context)
@@ -36,19 +37,20 @@ class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.
36
37
findViewById<View >(R .id.btn_disable_ldm).setOnClickListener(this )
37
38
findViewById<View >(R .id.btn_enable_rtk_network).setOnClickListener(this )
38
39
findViewById<View >(R .id.btn_disable_rtk_network).setOnClickListener(this )
39
- findViewById<View >(R .id.btn_is_rtk_network_enabled).setOnClickListener(this )
40
+ findViewById<View >(R .id.btn_is_enable_user_account).setOnClickListener(this )
41
+ findViewById<View >(R .id.btn_is_disable_user_account).setOnClickListener(this )
40
42
findViewById<View >(R .id.btn_get_ldm_license).setOnClickListener(this )
41
43
}
42
44
43
45
private fun initListener () {
44
46
DJISDKManager .getInstance().ldmManager.setCallback(object : LDMCallback {
45
47
override fun onLDMEnabledChange (isEnabled : Boolean ) {
46
- isLDMEnable = isEnabled;
48
+ isLDMEnabled = isEnabled;
47
49
handler.post { updateLdmInfo() }
48
50
}
49
51
50
52
override fun onLDMSupportedChange (isSupported : Boolean ) {
51
- isLDMSupport = isSupported;
53
+ isLDMSupported = isSupported;
52
54
handler.post { updateLdmInfo() }
53
55
}
54
56
})
@@ -68,18 +70,40 @@ class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.
68
70
}
69
71
}
70
72
71
- fun enableRTKNetwork () {
72
- val error = DJISDKManager .getInstance().ldmManager.setRTKNetworkServiceEnabled(true )
73
- ToastUtils .setResultToToast(" enableRTKNetwork " + if (error == null ) " success" else " error=" + error.description)
73
+ fun setRTKEnabled () {
74
+ var error = DJISDKManager .getInstance().ldmManager.setModuleNetworkServiceEnabled(LDMModule .Builder ()
75
+ .enabled(true )
76
+ .moduleType(LDMModuleType .RTK )
77
+ .build())
78
+ ToastUtils .setResultToToast(" setRTKEnabled " + if (error == null ) " success" else " error=" + error.description)
79
+ updateLdmInfo()
74
80
}
75
81
76
- fun disableRTKNetwork () {
77
- val error = DJISDKManager .getInstance().ldmManager.setRTKNetworkServiceEnabled(false )
78
- ToastUtils .setResultToToast(" disableRTKNetwork " + if (error == null ) " success" else " error=" + error.description)
82
+ fun setRTKDisabled () {
83
+ var error = DJISDKManager .getInstance().ldmManager.setModuleNetworkServiceEnabled(LDMModule .Builder ()
84
+ .enabled(false )
85
+ .moduleType(LDMModuleType .RTK )
86
+ .build())
87
+ ToastUtils .setResultToToast(" setRTKDisabled " + if (error == null ) " success" else " error=" + error.description)
88
+ updateLdmInfo()
79
89
}
80
90
81
- fun isRTKNetworkEnabled () {
82
- ToastUtils .setResultToToast(" isRTKNetworkServiceEnabled: " + DJISDKManager .getInstance().ldmManager.isRTKNetworkServiceEnabled)
91
+ fun setUserAccountEnabled () {
92
+ var error = DJISDKManager .getInstance().ldmManager.setModuleNetworkServiceEnabled(LDMModule .Builder ()
93
+ .enabled(true )
94
+ .moduleType(LDMModuleType .USER_ACCOUNT )
95
+ .build())
96
+ ToastUtils .setResultToToast(" setUserAccountEnabled " + if (error == null ) " success" else " error=" + error.description)
97
+ updateLdmInfo()
98
+ }
99
+
100
+ fun setUserAccountDisabled () {
101
+ var error = DJISDKManager .getInstance().ldmManager.setModuleNetworkServiceEnabled(LDMModule .Builder ()
102
+ .enabled(false )
103
+ .moduleType(LDMModuleType .USER_ACCOUNT )
104
+ .build())
105
+ ToastUtils .setResultToToast(" setUserAccountDisabled " + if (error == null ) " success" else " error=" + error.description)
106
+ updateLdmInfo()
83
107
}
84
108
85
109
fun getLdmLicense () {
@@ -92,10 +116,18 @@ class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.
92
116
ToastUtils .setResultToToast(" getLdmLicense error=" + error.description)
93
117
}
94
118
})
119
+ updateLdmInfo()
95
120
}
96
121
97
122
private fun updateLdmInfo () {
98
- ldmInfoText.text = " LDM enabled:$isLDMEnable ,LDM supported:$isLDMSupport "
123
+ isLDMEnabled = DJISDKManager .getInstance().ldmManager.isLDMEnabled
124
+ var isRTKEnabled = DJISDKManager .getInstance().ldmManager.isModuleNetworkServiceEnabled(LDMModuleType .RTK )
125
+ var isUserAccountEnabled = DJISDKManager .getInstance().ldmManager.isModuleNetworkServiceEnabled(LDMModuleType .USER_ACCOUNT )
126
+
127
+ ldmInfoText.text = " LDM enabled: $isLDMEnabled \n " +
128
+ " LDM supported: $isLDMSupported \n " +
129
+ " isRTKEnabled: $isRTKEnabled \n " +
130
+ " isUserAccountEnabled: $isUserAccountEnabled \n "
99
131
}
100
132
101
133
override fun getDescription (): Int = R .string.component_listview_ldm
@@ -106,9 +138,10 @@ class LDMView(context: Context?) : LinearLayout(context), PresentableView, View.
106
138
when (v?.id) {
107
139
R .id.btn_enable_ldm -> enableLDM()
108
140
R .id.btn_disable_ldm -> disableLDM()
109
- R .id.btn_enable_rtk_network -> enableRTKNetwork()
110
- R .id.btn_disable_rtk_network -> disableRTKNetwork()
111
- R .id.btn_is_rtk_network_enabled -> isRTKNetworkEnabled()
141
+ R .id.btn_enable_rtk_network -> setRTKEnabled()
142
+ R .id.btn_disable_rtk_network -> setRTKDisabled()
143
+ R .id.btn_is_enable_user_account -> setUserAccountEnabled()
144
+ R .id.btn_is_disable_user_account -> setUserAccountDisabled()
112
145
R .id.btn_get_ldm_license -> getLdmLicense()
113
146
}
114
147
}
0 commit comments