com.theartofdev.edmodo.cropper.CropImage Java Examples

The following examples show how to use com.theartofdev.edmodo.cropper.CropImage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CropperImageActivity.java    From WanAndroid with Apache License 2.0 7 votes vote down vote up
protected Intent getResultIntent(Uri uri, Exception error, int sampleSize) {
    CropImage.ActivityResult result =
            new CropImage.ActivityResult(
                    cropImageView.getImageUri(),
                    uri,
                    error,
                    cropImageView.getCropPoints(),
                    cropImageView.getCropRect(),
                    cropImageView.getRotatedDegrees(),
                    cropImageView.getWholeImageRect(),
                    sampleSize);
    Intent intent = new Intent();
    intent.putExtras(getIntent());
    intent.putExtra(CropImage.CROP_IMAGE_EXTRA_RESULT, result);
    return intent;
}
 
Example #2
Source File: PublishGroupChatProfilePictureActivity.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        final CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            this.uri = result.getUri();
            if (xmppConnectionServiceBound) {
                reloadAvatar();
            }
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            if (error != null) {
                Toast.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    } else if (requestCode == REQUEST_CHOOSE_PICTURE) {
        if (resultCode == RESULT_OK) {
            PublishProfilePictureActivity.cropUri(this, data.getData());
        }
    }
}
 
Example #3
Source File: MainActivity.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void onClick(DialogInterface dialog, int which) {
    ListView lv = ((AlertDialog) dialog).getListView();

    switch (which) {
        // Galery
        case 1:
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            startActivityForResult(photoPickerIntent, ImageUtil.REQUEST_PICK_GALERY_PHOTO);
            break;
        // Camera with Cropping
        case 0:
            //dispatchTakePictureIntent(mF);
            // start picker to get image for cropping and then use the image in cropping activity
            CropImage.activity()
                .setGuidelines(CropImageView.Guidelines.ON)
                .start(getActivity());
            break;
        case 2: // Delete picture

            break;
        // Camera
        default:
    }
}
 
Example #4
Source File: PublishProfilePictureActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            this.avatarUri = result.getUri();
            if (xmppConnectionServiceBound) {
                loadImageIntoPreview(this.avatarUri);
            }
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            if (error != null) {
                ToastCompat.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    } else if (requestCode == REQUEST_CHOOSE_PICTURE) {
        if (resultCode == RESULT_OK) {
            cropUri(this, data.getData());
        }
    }
}
 
Example #5
Source File: SetupActivity.java    From Simple-Blog-App with MIT License 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == GALLARY_REQUEST && resultCode == RESULT_OK) {
        Uri imageUri = data.getData();
        CropImage.activity(imageUri)
                .setGuidelines(CropImageView.Guidelines.ON)
                .setAspectRatio(1, 1)
                .start(this);

    }
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            mImageUri = result.getUri();
            mSetupImage.setImageURI(mImageUri);
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            Log.d("setupError", error + "");
        }
    }
}
 
Example #6
Source File: PublishProfilePictureActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
public static void chooseAvatar(final Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");
        activity.startActivityForResult(
                Intent.createChooser(intent, activity.getString(R.string.attach_choose_picture)),
                REQUEST_CHOOSE_PICTURE
        );
    } else {
        CropImage.activity()
                .setOutputCompressFormat(Bitmap.CompressFormat.PNG)
                .setAspectRatio(1, 1)
                .setMinCropResultSize(Config.AVATAR_SIZE, Config.AVATAR_SIZE)
                .start(activity);
    }
}
 
Example #7
Source File: PublishGroupChatProfilePictureActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        final CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            this.uri = result.getUri();
            if (xmppConnectionServiceBound) {
                reloadAvatar();
            }
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            if (error != null) {
                ToastCompat.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    } else if (requestCode == REQUEST_CHOOSE_PICTURE) {
        if (resultCode == RESULT_OK) {
            PublishProfilePictureActivity.cropUri(this, data.getData());
        }
    }
}
 
Example #8
Source File: MainActivity.java    From Android-Image-Cropper with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

  // 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());
      Toast.makeText(
              this, "Cropping successful, Sample: " + result.getSampleSize(), Toast.LENGTH_LONG)
          .show();
    } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
      Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show();
    }
  }
}
 
Example #9
Source File: PickImageActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    if (requestCode == CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            LogUtil.logDebug(TAG, "CAMERA_CAPTURE_PERMISSIONS granted");
            CropImage.startPickImageActivity(this);
        } else {
            showSnackBar(R.string.permissions_not_granted);
            LogUtil.logDebug(TAG, "CAMERA_CAPTURE_PERMISSIONS not granted");
        }
    }
    if (requestCode == CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) {
        if (imageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            LogUtil.logDebug(TAG, "PICK_IMAGE_PERMISSIONS granted");
            onImagePikedAction();
        } else {
            showSnackBar(R.string.permissions_not_granted);
            LogUtil.logDebug(TAG, "PICK_IMAGE_PERMISSIONS not granted");
        }
    }
}
 
Example #10
Source File: PickImageActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@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 (presenter.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();
        }
    }
}
 
Example #11
Source File: PickImagePresenter.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
protected void handleCropImageResult(int requestCode, int resultCode, Intent data) {
    ifViewAttached(view -> {
        if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
            CropImage.ActivityResult result = CropImage.getActivityResult(data);
            if (resultCode == RESULT_OK) {
                if (ValidationUtil.checkImageMinSize(result.getCropRect())) {
                    Uri imageUri = result.getUri();
                    view.loadImageToImageView(imageUri);
                } else {
                    view.showSnackBar(R.string.error_smaller_image);
                }
            } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
                LogUtil.logError(TAG, "crop image error", result.getError());
                view.showSnackBar(R.string.error_fail_crop_image);
            }
        }
    });

}
 
Example #12
Source File: MainFragment.java    From Android-Image-Cropper with Apache License 2.0 6 votes vote down vote up
private void handleCropResult(CropImageView.CropResult result) {
  if (result.getError() == null) {
    Intent intent = new Intent(getActivity(), CropResultActivity.class);
    intent.putExtra("SAMPLE_SIZE", result.getSampleSize());
    if (result.getUri() != null) {
      intent.putExtra("URI", result.getUri());
    } else {
      CropResultActivity.mImage =
          mCropImageView.getCropShape() == CropImageView.CropShape.OVAL
              ? CropImage.toOvalBitmap(result.getBitmap())
              : result.getBitmap();
    }
    startActivity(intent);
  } else {
    Log.e("AIC", "Failed to crop image", result.getError());
    Toast.makeText(
            getActivity(),
            "Image crop failed: " + result.getError().getMessage(),
            Toast.LENGTH_LONG)
        .show();
  }
}
 
Example #13
Source File: PickImageActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    if (requestCode == CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            LogUtil.logDebug(TAG, "CAMERA_CAPTURE_PERMISSIONS granted");
            CropImage.startPickImageActivity(this);
        } else {
            showSnackBar(R.string.permissions_not_granted);
            LogUtil.logDebug(TAG, "CAMERA_CAPTURE_PERMISSIONS not granted");
        }
    }
    if (requestCode == CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) {
        if (imageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            LogUtil.logDebug(TAG, "PICK_IMAGE_PERMISSIONS granted");
            onImagePikedAction();
        } else {
            showSnackBar(R.string.permissions_not_granted);
            LogUtil.logDebug(TAG, "PICK_IMAGE_PERMISSIONS not granted");
        }
    }
}
 
Example #14
Source File: PickImageActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@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 (presenter.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();
        }
    }
}
 
Example #15
Source File: MainActivity.java    From Android-Image-Cropper with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(
    int requestCode, String permissions[], int[] grantResults) {
  if (requestCode == CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE) {
    if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
      CropImage.startPickImageActivity(this);
    } else {
      Toast.makeText(this, "Cancelling, required permissions are not granted", Toast.LENGTH_LONG)
          .show();
    }
  }
  if (requestCode == CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) {
    if (mCropImageUri != null
        && grantResults.length > 0
        && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
      mCurrentFragment.setImageUri(mCropImageUri);
    } else {
      Toast.makeText(this, "Cancelling, required permissions are not granted", Toast.LENGTH_LONG)
          .show();
    }
  }
}
 
Example #16
Source File: PickImagePresenter.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
protected void handleCropImageResult(int requestCode, int resultCode, Intent data) {
    ifViewAttached(view -> {
        if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
            CropImage.ActivityResult result = CropImage.getActivityResult(data);
            if (resultCode == RESULT_OK) {
                if (ValidationUtil.checkImageMinSize(result.getCropRect())) {
                    Uri imageUri = result.getUri();
                    view.loadImageToImageView(imageUri);
                } else {
                    view.showSnackBar(R.string.error_smaller_image);
                }
            } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
                LogUtil.logError(TAG, "crop image error", result.getError());
                view.showSnackBar(R.string.error_fail_crop_image);
            }
        }
    });

}
 
Example #17
Source File: FlutterImagePickCropPlugin.java    From FlutterImagePickCrop with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {

    if (requestCode == CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) {
        if (mCropImageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            // required permissions granted, start crop image activity
            startCropImageActivity(mCropImageUri);
        } else {
            finishWithError("Failed Permission","Cancelling, required permissions are not granted");
            //Toast.makeText(activity, "Cancelling, required permissions are not granted", Toast.LENGTH_LONG).show();
        }

        return true;
    }

    return false;
}
 
Example #18
Source File: PublishProfilePictureActivity.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            this.avatarUri = result.getUri();
            if (xmppConnectionServiceBound) {
                loadImageIntoPreview(this.avatarUri);
            }
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            if (error != null) {
                Toast.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    } else if (requestCode == REQUEST_CHOOSE_PICTURE) {
        if (resultCode == RESULT_OK) {
            cropUri(this, data.getData());
        }
    }
}
 
Example #19
Source File: PublishProfilePictureActivity.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
public static void chooseAvatar(final Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");
        activity.startActivityForResult(
                Intent.createChooser(intent, activity.getString(R.string.attach_choose_picture)),
                REQUEST_CHOOSE_PICTURE
        );
    } else {
        CropImage.activity()
                .setOutputCompressFormat(Bitmap.CompressFormat.PNG)
                .setAspectRatio(1, 1)
                .setMinCropResultSize(Config.AVATAR_SIZE, Config.AVATAR_SIZE)
                .start(activity);
    }
}
 
Example #20
Source File: MainActivity.java    From Android-Image-Cropper with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

  // 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());
      Toast.makeText(
              this, "Cropping successful, Sample: " + result.getSampleSize(), Toast.LENGTH_LONG)
          .show();
    } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
      Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show();
    }
  }
}
 
Example #21
Source File: MainActivity.java    From Android-Image-Cropper with Apache License 2.0 5 votes vote down vote up
@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);
    }
  }
}
 
Example #22
Source File: MainFragment.java    From Android-Image-Cropper with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
    CropImage.ActivityResult result = CropImage.getActivityResult(data);
    handleCropResult(result);
  }
}
 
Example #23
Source File: ChannelNameActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void beginCrop(Uri imageUri) {
    try {
        CropImage.activity(imageUri)
                .setGuidelines(CropImageView.Guidelines.OFF)
                .setMultiTouchEnabled(true)
                .start(this);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #24
Source File: MainActivity.java    From Android-Image-Cropper with Apache License 2.0 5 votes vote down vote up
/** Start pick image activity with chooser. */
public void onSelectImageClick(View view) {
  CropImage.activity()
      .setGuidelines(CropImageView.Guidelines.ON)
      .setActivityTitle("My Crop")
      .setCropShape(CropImageView.CropShape.OVAL)
      .setCropMenuCropButtonTitle("Done")
      .setRequestedSize(400, 400)
      .setCropMenuCropButtonIcon(R.drawable.ic_launcher)
      .start(this);
}
 
Example #25
Source File: ChannelCreateActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    try {
        if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
            CropImage.ActivityResult result = CropImage.getActivityResult(intent);
            if (resultCode == RESULT_OK) {
                if (intent == null) {
                    return;
                }
                if (imageChangeUri != null) {
                    imageChangeUri = result.getUri();
                    circleImageView.setImageDrawable(null); // <--- added to force redraw of ImageView
                    circleImageView.setImageURI(imageChangeUri);
                    new ProfilePictureUpload(true, profilePhotoFile, imageChangeUri, ChannelCreateActivity.this).execute((Void[]) null);
                } else {
                    imageChangeUri = result.getUri();
                    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
                    String imageFileName = "JPEG_" + timeStamp + "_" + ".jpeg";
                    circleImageView.setImageDrawable(null); // <--- added to force redraw of ImageView
                    circleImageView.setImageURI(imageChangeUri);
                    profilePhotoFile = FileClientService.getFilePath(imageFileName, this, "image/jpeg");
                    new ProfilePictureUpload(true, profilePhotoFile, imageChangeUri, ChannelCreateActivity.this).execute((Void[]) null);
                }
            } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
                Toast.makeText(this, this.getString(R.string.applozic_Cropping_failed) + result.getError(), Toast.LENGTH_LONG).show();
            }
        }
        if (resultCode == Activity.RESULT_OK) {
            handleOnActivityResult(requestCode, intent);
        }
    } catch (Exception e) {
        Utils.printLog(this, TAG, "exception in profile image");
    }
}
 
Example #26
Source File: ChannelNameActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(intent);
        if (resultCode == RESULT_OK) {
            if (intent == null) {
                return;
            }
            if (imageChangeUri != null) {
                imageChangeUri = result.getUri();
                applozicGroupProfileIcon.setImageDrawable(null); // <--- added to force redraw of ImageView
                applozicGroupProfileIcon.setImageURI(imageChangeUri);
            } else {
                imageChangeUri = result.getUri();
                String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
                String imageFileName = "JPEG_" + timeStamp + "_" + ".jpeg";
                applozicGroupProfileIcon.setImageDrawable(null); // <--- added to force redraw of ImageView
                applozicGroupProfileIcon.setImageURI(imageChangeUri);
                profilePhotoFile = FileClientService.getFilePath(imageFileName, this, "image/jpeg");
                fileClientService.writeFile(imageChangeUri, profilePhotoFile);
            }
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Utils.printLog(this,ChannelNameActivity.class.getName(),this.getString(R.string.applozic_Cropping_failed)+result.getError());
        }
    }
    if (resultCode == Activity.RESULT_OK) {
        handleOnActivityResult(requestCode, intent);
    }
}
 
Example #27
Source File: ChannelCreateActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void beginCrop(Uri imageUri) {
    try {
        CropImage.activity(imageUri)
                .setGuidelines(CropImageView.Guidelines.OFF)
                .setMultiTouchEnabled(true)
                .start(this);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #28
Source File: ProfileEditActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
@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)
                .setCropShape(CropImageView.CropShape.OVAL)
                .setAspectRatio(1, 1)
                .start(this);
    }

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

            mImageUri = result.getUri();
            editProfilepic.setImageURI(mImageUri);

        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            Log.e(TAG + "crop_error", error.toString());
        }
    }

}
 
Example #29
Source File: ProfileActivity.java    From Travel-Mate with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == VERIFICATION_REQUEST_CODE) {
        recreate();
    }

    if (data == null)
        return;

    //After user has picked the image
    if (requestCode == RESULT_PICK_IMAGE && data.hasExtra("remove_image")) {
        deleteProfilePicture();
    } else if (requestCode == RESULT_PICK_IMAGE && resultCode == Activity.RESULT_OK) {
        Uri selectedImage = data.getData();
        //startCropIntent(selectedImage);
        CropImage.activity(selectedImage).start(this);
    }
    //After user has cropped the image
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            Uri croppedImage = result.getUri();
            getUrlFromCloudinary(croppedImage);
        }
    }
}
 
Example #30
Source File: FlutterImagePickCropPlugin.java    From FlutterImagePickCrop with Apache License 2.0 5 votes vote down vote up
private void openPickupFromGallery() {
     //Toast.makeText(activity, REQUEST_FOR_GALLERY, Toast.LENGTH_SHORT).show();

     // For Image capture from Gallary
/*     activity.startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI),
             PICK_FROM_GALLARY);*/
     CropImage.startPickImageActivity(activity);

 }