use of dji.common.error.DJIError in project uav_mobile_app by jiushuokj.
the class MainActivity method uploadWayPointMission.
private void uploadWayPointMission() {
// Log.d(TAG, "uploadWayPointMission: " + waypointList.toString());
for (Waypoint waypoint : waypointList) {
Log.d(TAG, "uploadWayPointMission: " + waypoint);
}
getWaypointMissionOperator().uploadMission(new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError error) {
if (error == null) {
setResultToToast("航点任务上传成功");
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
start.setEnabled(true);
pause.setEnabled(false);
resume.setEnabled(false);
stop.setEnabled(false);
}
});
} else {
setResultToToast("Mission upload failed, error: " + error.getDescription() + " retrying...");
getWaypointMissionOperator().retryUploadMission(null);
}
}
});
}
use of dji.common.error.DJIError in project uav_mobile_app by jiushuokj.
the class PlaybackActivity method playVideo.
private void playVideo() {
mDisplayImageView.setVisibility(View.INVISIBLE);
MediaFile selectedMediaFile = mediaFileList.get(lastClickViewIndex);
if ((selectedMediaFile.getMediaType() == MediaFile.MediaType.MOV) || (selectedMediaFile.getMediaType() == MediaFile.MediaType.MP4)) {
mMediaManager.playVideoMediaFile(selectedMediaFile, new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError error) {
if (null != error) {
setResultToToast("Play Video Failed " + error.getDescription());
} else {
DJILog.e(TAG, "Play Video Success");
}
}
});
}
}
use of dji.common.error.DJIError in project uav_mobile_app by jiushuokj.
the class PlaybackActivity method deleteFileByIndex.
private void deleteFileByIndex(final int index) {
ArrayList<MediaFile> fileToDelete = new ArrayList<MediaFile>();
if (mediaFileList.size() > index) {
fileToDelete.add(mediaFileList.get(index));
mMediaManager.deleteFiles(fileToDelete, new CommonCallbacks.CompletionCallbackWithTwoParam<List<MediaFile>, DJICameraError>() {
@Override
public void onSuccess(List<MediaFile> x, DJICameraError y) {
DJILog.e(TAG, "Delete file success");
runOnUiThread(new Runnable() {
public void run() {
MediaFile file = mediaFileList.remove(index);
// Reset select view
lastClickViewIndex = -1;
lastClickView = null;
// Update recyclerView
mListAdapter.notifyItemRemoved(index);
}
});
}
@Override
public void onFailure(DJIError error) {
setResultToToast("Delete file failed");
}
});
}
}
use of dji.common.error.DJIError in project uav_mobile_app by jiushuokj.
the class DemoApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
mHandler = new Handler(Looper.getMainLooper());
/**
* When starting SDK services, an instance of interface DJISDKManager.DJISDKManagerCallback will be used to listen to
* the SDK Registration result and the product changing.
*/
mDJISDKManagerCallback = new DJISDKManager.SDKManagerCallback() {
// Listens to the SDK registration result
@Override
public void onRegister(DJIError error) {
if (error == DJISDKError.REGISTRATION_SUCCESS) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "注册成功", Toast.LENGTH_LONG).show();
}
});
DJISDKManager.getInstance().startConnectionToProduct();
} else {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "注册SDK失败, 请检查网络是否可用", Toast.LENGTH_LONG).show();
}
});
}
Log.e("TAG", error.toString());
}
@Override
public void onProductDisconnect() {
Log.d("TAG", "onProductDisconnect");
notifyStatusChange();
}
@Override
public void onProductConnect(BaseProduct baseProduct) {
Log.d("TAG", String.format("onProductConnect newProduct:%s", baseProduct));
notifyStatusChange();
}
@Override
public void onComponentChange(BaseProduct.ComponentKey componentKey, BaseComponent oldComponent, BaseComponent newComponent) {
if (newComponent != null) {
newComponent.setComponentListener(new BaseComponent.ComponentListener() {
@Override
public void onConnectivityChange(boolean isConnected) {
Log.d("TAG", "onComponentConnectivityChanged: " + isConnected);
notifyStatusChange();
}
});
}
Log.d("TAG", String.format("onComponentChange key:%s, oldComponent:%s, newComponent:%s", componentKey, oldComponent, newComponent));
}
@Override
public void onInitProcess(DJISDKInitEvent djisdkInitEvent, int i) {
}
@Override
public void onDatabaseDownloadProgress(long l, long l1) {
}
};
// Check the permissions before registering the application for android system 6.0 above.
int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
int permissionCheck2 = ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.READ_PHONE_STATE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || (permissionCheck == 0 && permissionCheck2 == 0)) {
// This is used to start SDK services and initiate SDK.
DJISDKManager.getInstance().registerApp(getApplicationContext(), mDJISDKManagerCallback);
Toast.makeText(getApplicationContext(), "正在注册SDK,请稍等...", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "请检查App的权限是否足够", Toast.LENGTH_LONG).show();
}
}
use of dji.common.error.DJIError in project uav_mobile_app by jiushuokj.
the class MyMqttService method loadWaypointMissionUsingProtoBuf.
private void loadWaypointMissionUsingProtoBuf(String topic, MqttMessage message) throws com.google.protobuf.InvalidProtocolBufferException {
ProtoWaypointMission.WaypointMission protoMission = ProtoWaypointMission.WaypointMission.parseFrom(message.getPayload());
Log.i(TAG, "收到消息: " + protoMission);
// 收到消息,这里弹出Toast表示。如果需要更新UI,可以使用广播或者EventBus进行发送
Toast.makeText(getApplicationContext(), "messageArrived: " + protoMission, Toast.LENGTH_LONG).show();
// 处理收到的WaypointMission
WaypointMission waypointMission = handleWaypointMission(protoMission);
Log.i(TAG, "转换后的消息: " + waypointMission);
if (waypointMissionOperator == null) {
waypointMissionOperator = DJISDKManager.getInstance().getMissionControl().getWaypointMissionOperator();
}
// 装载任务
DJIError error = waypointMissionOperator.loadMission(waypointMission);
if (error == null) {
Log.i(TAG, "messageArrived: " + "loadWaypointMission succeeded");
response(topic, "loadWaypointMission succeeded");
} else {
Log.i(TAG, "messageArrived: " + "loadWaypointMission failed " + error.getDescription());
response(topic, "loadWaypointMission failed " + error.getDescription());
}
}
Aggregations