How to crop two images in the same Activity?

1

I'm using this repository to crop images. But I am not able to cut two images in the same activity, being that one cut is oval and the other rectangular. Whenever I click on both, the cut is the same.

Here is the code for the oval cut:

private CircleImageView mCircleImageView;
private static final int GALLERY_REQUEST = 1;
private Uri mImageUri;

mCircleImageView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {

        Intent galleryIntent = new Intent();
        galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
        galleryIntent.setType("image/*");
        startActivityForResult(galleryIntent, GALLERY_REQUEST);
    }
});
}

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

    if (requestCode == GALLERY_REQUEST && resultCode == RESULT_OK) {

        Uri imageUri = data.getData();
        CropImage.activity(imageUri)
            .setGuidelines(CropImageView.Guidelines.ON)
            .setAspectRatio(1, 1)
            .setCropShape(CropImageView.CropShape.OVAL)
            .setBackgroundColor(R.color.pretotransparente)
            .setBorderLineColor(R.color.vermelhotransparente)
            .setCropShape(CropImageView.CropShape.OVAL)
            .start(this);

    }

    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);

        if (resultCode == RESULT_OK) {
            mImageUri = result.getUri();



            mCircleImageView.setImageURI(mImageUri);
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
        }
    }
}

Resolved The problem was with onActivityResult

link

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

    if(requestCode == GALLERY_REQUEST && resultCode == RESULT_OK){

        Uri imageUri = data.getData();
        CropImage.activity(imageUri)
                .setGuidelines(CropImageView.Guidelines.ON)
                .setAspectRatio(1, 1)
                .setCropShape(CropImageView.CropShape.OVAL)
                .setBackgroundColor(R.color.pretotransparente)
                .setBorderLineColor(R.color.vermelhotransparente)
                .setCropShape(CropImageView.CropShape.OVAL)
                .start(this);

    }

    if(requestCode == GALLERY_REQUEST2 && resultCode == RESULT_OK){
        Uri imageUri = data.getData();
        CropImage.activity(imageUri)
                .setGuidelines(CropImageView.Guidelines.ON)
                .setBackgroundColor(R.color.pretotransparente)
                .setBorderLineColor(R.color.vermelhotransparente)
                .setMaxCropResultSize(1000,400)
                .setMinCropResultSize(1000,400)
                .start(this);

    }

    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);

        if (resultCode == RESULT_OK) {
            mImageUri = result.getUri();
            mCircleImageView.setImageURI(mImageUri);
            mCapaSelect.setImageURI(mImageUri);


        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
        }
    
asked by anonymous 18.03.2017 / 15:52

0 answers