Skip to content

Commit 21cf46b

Browse files
committed
Fix reading CropImageOptions in CropImageView after Samsung bundle fix
1 parent f78d486 commit 21cf46b

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,10 @@ public Intent getIntent(@NonNull Context context, @Nullable Class<?> cls) {
454454

455455
Intent intent = new Intent();
456456
intent.setClass(context, cls);
457-
Bundle b = new Bundle();
458-
b.putParcelable(CROP_IMAGE_EXTRA_SOURCE, mSource);
459-
b.putParcelable(CROP_IMAGE_EXTRA_OPTIONS, mOptions);
460-
intent.putExtra("bundle", b);
457+
Bundle bundle = new Bundle();
458+
bundle.putParcelable(CROP_IMAGE_EXTRA_SOURCE, mSource);
459+
bundle.putParcelable(CROP_IMAGE_EXTRA_OPTIONS, mOptions);
460+
intent.putExtra(CropImageOptions.BUNDLE_KEY, bundle);
461461
return intent;
462462
}
463463

cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImageActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void onCreate(Bundle savedInstanceState) {
6464

6565
mCropImageView = (CropImageView) findViewById(R.id.cropImageView);
6666

67-
Bundle bundle = getIntent().getBundleExtra("bundle");
67+
Bundle bundle = getIntent().getBundleExtra(CropImageOptions.BUNDLE_KEY);
6868
mCropImageUri = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_SOURCE);
6969
mOptions = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS);
7070

cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImageOptions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
public class CropImageOptions implements Parcelable {
3131

32+
static final String BUNDLE_KEY = "bundle";
33+
3234
public static final Creator<CropImageOptions> CREATOR = new Creator<CropImageOptions>() {
3335
@Override
3436
public CropImageOptions createFromParcel(Parcel in) {

cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImageView.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ public CropImageView(Context context, AttributeSet attrs) {
227227
CropImageOptions options = null;
228228
Intent intent = context instanceof Activity ? ((Activity) context).getIntent() : null;
229229
if (intent != null) {
230-
options = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_OPTIONS);
230+
Bundle bundle = intent.getBundleExtra(CropImageOptions.BUNDLE_KEY);
231+
if (bundle != null) {
232+
options = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS);
233+
}
231234
}
232235

233236
if (options == null) {

quick-start/src/main/java/com/theartofdev/edmodo/cropper/quick/start/MainActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public void onSelectImageClick(View view) {
3737
CropImage.activity()
3838
.setGuidelines(CropImageView.Guidelines.ON)
3939
.setActivityTitle("My Crop")
40+
.setCropShape(CropImageView.CropShape.OVAL)
41+
.setRequestedSize(400, 400)
4042
.start(this);
4143
}
4244

0 commit comments

Comments
 (0)