Search in sources :

Example 1 with DJIError

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);
            }
        }
    });
}
Also used : CommonCallbacks(dji.common.util.CommonCallbacks) DJIError(dji.common.error.DJIError) Waypoint(dji.common.mission.waypoint.Waypoint)

Example 2 with DJIError

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");
                }
            }
        });
    }
}
Also used : MediaFile(dji.sdk.media.MediaFile) CommonCallbacks(dji.common.util.CommonCallbacks) DJIError(dji.common.error.DJIError)

Example 3 with DJIError

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");
            }
        });
    }
}
Also used : MediaFile(dji.sdk.media.MediaFile) CommonCallbacks(dji.common.util.CommonCallbacks) DJIError(dji.common.error.DJIError) ArrayList(java.util.ArrayList) DJICameraError(dji.common.error.DJICameraError) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with DJIError

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();
    }
}
Also used : BaseComponent(dji.sdk.base.BaseComponent) DJISDKManager(dji.sdk.sdkmanager.DJISDKManager) Handler(android.os.Handler) DJIError(dji.common.error.DJIError) DJISDKInitEvent(dji.sdk.sdkmanager.DJISDKInitEvent) BaseProduct(dji.sdk.base.BaseProduct)

Example 5 with DJIError

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());
    }
}
Also used : DJIError(dji.common.error.DJIError) ProtoWaypointMission(com.jskj.mobile.request.ProtoWaypointMission) WaypointMission(dji.common.mission.waypoint.WaypointMission) ProtoWaypointMission(com.jskj.mobile.request.ProtoWaypointMission)

Aggregations

DJIError (dji.common.error.DJIError)17 CommonCallbacks (dji.common.util.CommonCallbacks)9 MediaFile (dji.sdk.media.MediaFile)4 Handler (android.os.Handler)3 WaypointMission (dji.common.mission.waypoint.WaypointMission)3 BaseComponent (dji.sdk.base.BaseComponent)3 BaseProduct (dji.sdk.base.BaseProduct)3 DJISDKInitEvent (dji.sdk.sdkmanager.DJISDKInitEvent)3 DJISDKManager (dji.sdk.sdkmanager.DJISDKManager)3 SuppressLint (android.annotation.SuppressLint)2 ProtoWaypointMission (com.jskj.mobile.request.ProtoWaypointMission)2 Waypoint (dji.common.mission.waypoint.Waypoint)2 ArrayList (java.util.ArrayList)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 Bitmap (android.graphics.Bitmap)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1