Search in sources :

Example 1 with TIntentWap

use of com.jph.takephoto.model.TIntentWap in project TakePhoto by crazycodeboy.

the class TakePhotoImpl method onPickFromCaptureWithCrop.

@Override
public void onPickFromCaptureWithCrop(Uri outPutUri, CropOptions options) {
    this.fromType = TImage.FromType.CAMERA;
    if (PermissionManager.TPermissionType.WAIT.equals(permissionType))
        return;
    this.cropOptions = options;
    this.outPutUri = outPutUri;
    if (Build.VERSION.SDK_INT >= 23) {
        this.tempUri = TUriParse.getTempUri(contextWrap.getActivity());
    } else {
        this.tempUri = outPutUri;
    }
    try {
        TUtils.captureBySafely(contextWrap, new TIntentWap(IntentUtils.getCaptureIntent(this.tempUri), TConstant.RC_PICK_PICTURE_FROM_CAPTURE_CROP));
    } catch (TException e) {
        takeResult(TResult.of(TImage.of("", fromType)), e.getDetailMessage());
        e.printStackTrace();
    }
}
Also used : TException(com.jph.takephoto.model.TException) TIntentWap(com.jph.takephoto.model.TIntentWap)

Example 2 with TIntentWap

use of com.jph.takephoto.model.TIntentWap in project TakePhoto by crazycodeboy.

the class TakePhotoImpl method selectPicture.

private void selectPicture(int defaultIndex, boolean isCrop) {
    this.fromType = TImage.FromType.OTHER;
    if (takePhotoOptions != null && takePhotoOptions.isWithOwnGallery()) {
        onPickMultiple(1);
        return;
    }
    if (PermissionManager.TPermissionType.WAIT.equals(permissionType))
        return;
    ArrayList<TIntentWap> intentWapList = new ArrayList<>();
    intentWapList.add(new TIntentWap(IntentUtils.getPickIntentWithDocuments(), isCrop ? TConstant.RC_PICK_PICTURE_FROM_DOCUMENTS_CROP : TConstant.RC_PICK_PICTURE_FROM_DOCUMENTS_ORIGINAL));
    intentWapList.add(new TIntentWap(IntentUtils.getPickIntentWithGallery(), isCrop ? TConstant.RC_PICK_PICTURE_FROM_GALLERY_CROP : TConstant.RC_PICK_PICTURE_FROM_GALLERY_ORIGINAL));
    try {
        TUtils.sendIntentBySafely(contextWrap, intentWapList, defaultIndex, isCrop);
    } catch (TException e) {
        takeResult(TResult.of(TImage.of("", fromType)), e.getDetailMessage());
        e.printStackTrace();
    }
}
Also used : TException(com.jph.takephoto.model.TException) ArrayList(java.util.ArrayList) TIntentWap(com.jph.takephoto.model.TIntentWap)

Example 3 with TIntentWap

use of com.jph.takephoto.model.TIntentWap in project TakePhoto by crazycodeboy.

the class TUtils method cropWithOtherAppBySafely.

/**
     * 通过第三方工具裁切照片,当没有第三方裁切工具时,会自动使用自带裁切工具进行裁切
     * @param contextWrap
     * @param imageUri
     * @param outPutUri
     * @param options
     */
public static void cropWithOtherAppBySafely(TContextWrap contextWrap, Uri imageUri, Uri outPutUri, CropOptions options) {
    Intent nativeCropIntent = IntentUtils.getCropIntentWithOtherApp(imageUri, outPutUri, options);
    List result = contextWrap.getActivity().getPackageManager().queryIntentActivities(nativeCropIntent, PackageManager.MATCH_ALL);
    if (result.isEmpty()) {
        cropWithOwnApp(contextWrap, imageUri, outPutUri, options);
    } else {
        //            try {
        //                imageUri=Uri.fromFile(new File(TUriParse.getFilePathWithDocumentsUri(imageUri,contextWrap.getActivity())));
        //            } catch (TException e) {
        //                e.printStackTrace();
        //            }
        startActivityForResult(contextWrap, new TIntentWap(IntentUtils.getCropIntentWithOtherApp(imageUri, outPutUri, options), TConstant.RC_CROP));
    }
}
Also used : TIntentWap(com.jph.takephoto.model.TIntentWap) Intent(android.content.Intent) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with TIntentWap

use of com.jph.takephoto.model.TIntentWap in project TakePhoto by crazycodeboy.

the class TUtils method sendIntentBySafely.

/**
     * 安全地发送Intent
     * @param contextWrap
     * @param intentWapList 要发送的Intent以及候选Intent
     * @param defaultIndex 默认发送的Intent
     * @param isCrop 是否为裁切照片的Intent
     * @throws TException
     */
public static void sendIntentBySafely(TContextWrap contextWrap, List<TIntentWap> intentWapList, int defaultIndex, boolean isCrop) throws TException {
    if (defaultIndex + 1 > intentWapList.size())
        throw new TException(isCrop ? TExceptionType.TYPE_NO_MATCH_PICK_INTENT : TExceptionType.TYPE_NO_MATCH_CROP_INTENT);
    TIntentWap intentWap = intentWapList.get(defaultIndex);
    List result = contextWrap.getActivity().getPackageManager().queryIntentActivities(intentWap.getIntent(), PackageManager.MATCH_ALL);
    if (result.isEmpty()) {
        sendIntentBySafely(contextWrap, intentWapList, ++defaultIndex, isCrop);
    } else {
        startActivityForResult(contextWrap, intentWap);
    }
}
Also used : TException(com.jph.takephoto.model.TException) TIntentWap(com.jph.takephoto.model.TIntentWap) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

TIntentWap (com.jph.takephoto.model.TIntentWap)4 TException (com.jph.takephoto.model.TException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)2 Intent (android.content.Intent)1