当前位置: 首页>>代码示例>>Java>>正文


Java CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE属性代码示例

本文整理汇总了Java中com.theartofdev.edmodo.cropper.CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE属性的典型用法代码示例。如果您正苦于以下问题:Java CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE属性的具体用法?Java CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE怎么用?Java CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.theartofdev.edmodo.cropper.CropImage的用法示例。


在下文中一共展示了CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == AppCompatActivity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage,
        // but we don't know if we need to for the URI so the simplest is to try open the stream and see if we get error.
        boolean requirePermissions = false;
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {

            // request permissions and handle the result in onRequestPermissionsResult()
            requirePermissions = true;
            mCropImageUri = imageUri;
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {

            mCurrentFragment.setImageUri(imageUri);
        }
    }
}
 
开发者ID:chuch0805,项目名称:Android-Demo_ImageCroper,代码行数:23,代码来源:MainActivity.java

示例2: onActivityResult

@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // handle result of pick image chooser
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        if (isImageFileValid(imageUri)) {
            this.imageUri = imageUri;
        }

        // For API >= 23 we need to check specifically that we have permissions to read external storage.
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
            // request permissions and handle the result in onRequestPermissionsResult()
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {
            // no permissions required or already grunted
            onImagePikedAction();
        }
    }
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:21,代码来源:PickImageActivity.java

示例3: onActivityResult

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE: {
            if (resultCode == RESULT_OK) {
                CropImage.activity(data.getData())
                        .setActivityTitle(getString(R.string.crop))
                        .setAspectRatio(1, 1)
                        .setFixAspectRatio(true)
                        .start(this);
            }
            break;
        }
        case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE: {
            if (resultCode == RESULT_OK) {
                CropImage.ActivityResult result = CropImage.getActivityResult(data);
                returnUri(result.getUri());
            }
            break;
        }
    }
}
 
开发者ID:richardchien,项目名称:jigsaw-android,代码行数:23,代码来源:ChooseActivity.java

示例4: onActivityResult

@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage,
        // but we don't know if we need to for the URI so the simplest is to try open the stream and see if we get error.
        boolean requirePermissions = false;
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {

            // request permissions and handle the result in onRequestPermissionsResult()
            requirePermissions = true;
            mCropImageUri = imageUri;
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
        } else {

            mCurrentFragment.setImageUri(imageUri);
        }
    }
}
 
开发者ID:enjoyproduct,项目名称:ImageCroper,代码行数:21,代码来源:MainActivity.java

示例5: onActivityResult

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // handle result of pick image chooser
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            Uri imageUri = CropImage.getPickImageResultUri(this, data);

            if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
                cropImageUri = imageUri;
                ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
            } else {
                startCropImageActivity(imageUri);
            }
        } else {
            Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_fail, ""), Snackbar.LENGTH_SHORT).show();
        }
    } else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            vehiclePicturePath = result.getUri().getPath();
            Picasso.with(getApplicationContext()).load(new File(vehiclePicturePath)).into(imgCarPhoto);
            imgCarPhoto.setAlpha(REMOVE_PHOTO_ALPHA_CHANNEL);
            imgCarPhotoRemove.setVisibility(View.VISIBLE);
            Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_success), Snackbar.LENGTH_SHORT).show();
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_fail, error), Snackbar.LENGTH_SHORT).show();

        }
    }
}
 
开发者ID:piskula,项目名称:FuelUp,代码行数:31,代码来源:VehicleAbstractActivity.java

示例6: onActivityResult

@SuppressLint("NewApi")
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // handle result of pick image chooser
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        this.imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage.
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
            // request permissions and handle the result in onRequestPermissionsResult()
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {
            // no permissions required or already grunted, can start crop image activity
            startCropper(imageUri);
        }
    }

    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        Uri resultUri = result.getUri();

        // Start creator
        new CustomCreator(this, resultUri).setListener(this).execute();
    }

    if (requestCode == PreviewActivity.PREVIEW_ACTIVITY_REQUEST_CODE && resultCode == PreviewActivity.RESULT_OK) {
        if (data != null) {
            CatalogItem catalogItem = data.getParcelableExtra(PreviewActivity.EXTRA_CATALOG_ITEM);
            if (catalogItem != null) {
                downloadBackground(catalogItem);
            }
        }
    }
}
 
开发者ID:lucasax,项目名称:Zero,代码行数:34,代码来源:MainActivity.java

示例7: onActivityResult

@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    // handle result of pick image chooser
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage.
        boolean requirePermissions = false;
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
            // request permissions and handle the result in onRequestPermissionsResult()
            requirePermissions = true;
            mCropImageUri = imageUri;
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
        } else {
            // no permissions required or already grunted, can start crop image activity
            startCropImageActivity(imageUri);
        }
    }

    // handle result of CropImageActivity
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            ((ImageView) findViewById(R.id.quick_start_cropped_image)).setImageURI(result.getUri());
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:enjoyproduct,项目名称:ImageCroper,代码行数:31,代码来源:MainActivity.java

示例8: onActivityResult

@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);

  if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE
      && resultCode == AppCompatActivity.RESULT_OK) {
    Uri imageUri = CropImage.getPickImageResultUri(this, data);

    // For API >= 23 we need to check specifically that we have permissions to read external
    // storage,
    // but we don't know if we need to for the URI so the simplest is to try open the stream and
    // see if we get error.
    boolean requirePermissions = false;
    if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {

      // request permissions and handle the result in onRequestPermissionsResult()
      requirePermissions = true;
      mCropImageUri = imageUri;
      requestPermissions(
          new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
          CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
    } else {

      mCurrentFragment.setImageUri(imageUri);
    }
  }
}
 
开发者ID:ArthurHub,项目名称:Android-Image-Cropper,代码行数:28,代码来源:MainActivity.java

示例9: handleOnActivityResult

public static boolean handleOnActivityResult(int requestCode, int resultCode, Intent data, BaseActivity activity) {

        /*
         * Image chooser result
         */
        if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE) {
            if (resultCode != Activity.RESULT_OK) {
                callOnFailure(Failure.CANCELLED);
                return true;
            }

            Uri imageUri = CropImage.getPickImageResultUri(activity, data);

            Intent intent = CropImage.activity(imageUri)
                    .setAspectRatio(1, 1)
                    .setFixAspectRatio(true)
                    .setCropShape(CropImageView.CropShape.OVAL)
                    .getIntent(activity);

            activity.startActivityForResult(intent, CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE);
            return true;
        }

        /*
         * Image cropper result
         */
        if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
            if (resultCode == Activity.RESULT_CANCELED) {
                callOnFailure(Failure.CANCELLED);
                return true;
            }

            Log.d(TAG, "activity result for crop");

            CropImage.ActivityResult result = CropImage.getActivityResult(data);
            if (result == null) {
                callOnFailure(Failure.CROP_IMAGE_ERROR);
                return true;
            }

            if (result.getError() != null) {
                Log.e(TAG, "Error cropping image", result.getError());
                callOnFailure(Failure.CROP_IMAGE_ERROR);
                return true;
            }

            if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
                callOnFailure(Failure.CROP_IMAGE_ERROR);
                return true;
            }

            Log.d(TAG, "Photo cropped successfully: " + result.getUri());
            callOnSuccess(result.getUri());
            return true;
        }

        return false;
    }
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:58,代码来源:PhotoHelper.java


注:本文中的com.theartofdev.edmodo.cropper.CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。