/**
  * 直接根据uri 获取图片
  *
  * @param context context
  * @param uri uri
  * @param cut 是否裁剪
  * @param callBack 回调
  */
 public static void getImagePathFromURI(
     Context context, Uri uri, boolean cut, PhotoCallBack callBack) {
   Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
   cursor.moveToFirst();
   String document_id = cursor.getString(0);
   document_id = document_id.substring(document_id.lastIndexOf(":") + 1);
   cursor.close();
   cursor =
       context
           .getContentResolver()
           .query(
               MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
               null,
               MediaStore.Images.Media._ID + " = ? ",
               new String[] {document_id},
               null);
   cursor.moveToFirst();
   String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
   cursor.close();
   if (callBack != null) {
     callBack.Success(path);
   }
   if (cut) {
     doCropPhoto(context, uri, new File(path));
   }
 }
  /**
   * @param context context
   * @param requestCode 如果是相册调用 cameraFile传null即可
   * @param cut 是否调用系统剪辑
   */
  public static void GetPhoto(
      Activity context, int requestCode, Intent data, boolean cut, PhotoCallBack callBack) {
    // ***********图库*****************//
    if (requestCode == CameraUtil.PHOTO_PICKED_WITH_DATA) {
      try {
        String imagePath;
        Uri uri = data.getData();
        if (uri != null) { // 直接根据uri处理照片
          getImagePathFromURI(context, uri, cut, callBack);
        } else {
          Bundle extras = data.getExtras();
          if (extras != null) {
            // 这里是有些拍照后的图片是直接存放到Bundle中的所以我们可以从这里面获取Bitmap图片
            Bitmap image = extras.getParcelable("data");
            if (image != null) {
              imagePath = CameraUtil.savePhotoBitmap(image);
              if (callBack != null) {
                if (cut) {
                  doCropPhoto(context, uri, new File(imagePath));
                } else {
                  callBack.Success(imagePath);
                }
              }
            }
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    // ***********照相*****************//
    if (requestCode == CameraUtil.CAMERA_WITH_DATA) {
      if (callBack != null) {
        if (cut) {
          doCropPhoto(context, null, mCurrentPhotoFile);
        } else {
          callBack.Success(mCurrentPhotoFile.getAbsolutePath());
        }
      }
    }

    // ***********裁剪*****************//
    if (requestCode == CameraUtil.CAMERA_COMPLETE) {
      callBack.Success(cropfile.getAbsolutePath());
    }
  }