/**
   * Before the playback commands are sent to the aircraft, the camera work mode should be set to
   * playback mode.
   */
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    if (DJIModuleVerificationUtil.isCameraModuleValid()) {
      mCamera = DJISampleApplication.getAircraftInstance().getCamera();

      mCamera.setCameraMode(
          DJICameraSettingsDef.CameraMode.Playback,
          new DJIBaseComponent.DJICompletionCallback() {
            @Override
            public void onResult(DJIError djiError) {}
          });
      if (DJIModuleVerificationUtil.isPlaybackValid()) {
        mPlaybackManager = mCamera.getPlayback();

        mPlaybackManager.setDJICameraPlayBackStateCallBack(
            new DJIPlaybackManager.DJICameraPlayBackStateCallBack() {
              @Override
              public void onResult(
                  DJIPlaybackManager.DJICameraPlaybackState djiCameraPlaybackState) {
                if (djiCameraPlaybackState.playbackMode.equals(
                    DJICameraSettingsDef.CameraPlaybackMode.SinglePhotoPlayback))
                  mPlaybackManager.enterMultiplePreviewMode();

                if (djiCameraPlaybackState.playbackMode.equals(
                    DJICameraSettingsDef.CameraPlaybackMode.MultipleMediaFilesDisplay))
                  mPlaybackManager.enterMultipleEditMode();
              }
            });
      }
    }
  }
  @Override
  protected void getBtn1Method() {
    if (DJIModuleVerificationUtil.isPlaybackValid()) {
      mPlaybackManager = DJISampleApplication.getProductInstance().getCamera().getPlayback();

      mPlaybackManager.toggleFileSelectionAtIndex(0);
    }
  }
 @Override
 protected int getInfoResourceId() {
   if (!DJIModuleVerificationUtil.isPlaybackValid()) {
     return R.string.not_support_playback;
   } else {
     return R.string.support_playback;
   }
 }
  @Override
  protected void getBtn3Method() {
    // Download Button
    if (DJIModuleVerificationUtil.isPlaybackValid()) {
      mPlaybackManager = DJISampleApplication.getProductInstance().getCamera().getPlayback();

      File destDir =
          new File(Environment.getExternalStorageDirectory().getPath() + "/Dji_Sdk_Test/");
      mPlaybackManager.downloadSelectedFiles(
          destDir,
          new DJIPlaybackManager.CameraFileDownloadCallback() {

            @Override
            public void onStart() {
              Message message = Message.obtain();
              message.obj = "Start";
              messageHandler.sendMessage(message);
            }

            @Override
            public void onEnd() {}

            @Override
            public void onError(Exception e) {

              Message message = Message.obtain();
              message.obj = e.toString();
              messageHandler.sendMessage(message);
            }

            @Override
            public void onProgressUpdate(int i) {

              Message message = Message.obtain();
              message.obj = "Progress: " + i;
              messageHandler.sendMessage(message);
            }
          });
    }
  }
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    if (DJIModuleVerificationUtil.isFlightControllerAvailable()) {

      flightController =
          ((DJIAircraft) DJISampleApplication.getProductInstance()).getFlightController();

      intelligentFlightAssistant = flightController.getIntelligentFlightAssistant();

      if (intelligentFlightAssistant != null) {

        intelligentFlightAssistant.setVisionDetectionStateUpdatedCallback(
            new DJIIntelligentFlightAssistant.VisionDetectionStateUpdatedCallback() {
              @Override
              public void onStateUpdated(
                  DJIIntelligentFlightAssistant.DJIVisionDetectionState djiVisionDetectionState) {
                if (null != djiVisionDetectionState) {
                  mStringBuffer.delete(0, mStringBuffer.length());

                  List<DJIIntelligentFlightAssistant.DJIVisionDetectionSector>
                      visionDetectionSectorList = djiVisionDetectionState.getDetectionSectors();

                  for (DJIIntelligentFlightAssistant.DJIVisionDetectionSector
                      visionDetectionSector : visionDetectionSectorList) {

                    visionDetectionSector.getObstacleDistanceInMeters();
                    visionDetectionSector.getWarningLevel();

                    mStringBuffer
                        .append("Obstacle distance: ")
                        .append(visionDetectionSector.getObstacleDistanceInMeters())
                        .append("\n");
                    mStringBuffer
                        .append("Distance warning: ")
                        .append(visionDetectionSector.getWarningLevel())
                        .append("\n");
                  }

                  mStringBuffer
                      .append("WarningLevel: ")
                      .append(djiVisionDetectionState.getWarningLevel().toString())
                      .append("\n");
                  mStringBuffer
                      .append("Braking state: ")
                      .append(djiVisionDetectionState.isBraking())
                      .append("\n");
                  mStringBuffer
                      .append("Sensor state: ")
                      .append(djiVisionDetectionState.isSensorWorking())
                      .append("\n");

                  mHandler.sendEmptyMessage(SET_CHANGE_STATUS);
                }
              }
            });
      }

    } else {
      Log.i("$$$$$$$$$$$$$$$$$$$", "onAttachedToWindow FC NOT Available");
    }
  }