Skip to content

Commit

Permalink
Fix reading CropImageOptions in CropImageView after Samsung bundle fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHub committed Jul 7, 2017
1 parent f78d486 commit 21cf46b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ public Intent getIntent(@NonNull Context context, @Nullable Class<?> cls) {

Intent intent = new Intent();
intent.setClass(context, cls);
Bundle b = new Bundle();
b.putParcelable(CROP_IMAGE_EXTRA_SOURCE, mSource);
b.putParcelable(CROP_IMAGE_EXTRA_OPTIONS, mOptions);
intent.putExtra("bundle", b);
Bundle bundle = new Bundle();
bundle.putParcelable(CROP_IMAGE_EXTRA_SOURCE, mSource);
bundle.putParcelable(CROP_IMAGE_EXTRA_OPTIONS, mOptions);
intent.putExtra(CropImageOptions.BUNDLE_KEY, bundle);
return intent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onCreate(Bundle savedInstanceState) {

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

Bundle bundle = getIntent().getBundleExtra("bundle");
Bundle bundle = getIntent().getBundleExtra(CropImageOptions.BUNDLE_KEY);
mCropImageUri = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_SOURCE);
mOptions = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/
public class CropImageOptions implements Parcelable {

static final String BUNDLE_KEY = "bundle";

public static final Creator<CropImageOptions> CREATOR = new Creator<CropImageOptions>() {
@Override
public CropImageOptions createFromParcel(Parcel in) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ public CropImageView(Context context, AttributeSet attrs) {
CropImageOptions options = null;
Intent intent = context instanceof Activity ? ((Activity) context).getIntent() : null;
if (intent != null) {
options = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_OPTIONS);
Bundle bundle = intent.getBundleExtra(CropImageOptions.BUNDLE_KEY);
if (bundle != null) {
options = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS);
}
}

if (options == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public void onSelectImageClick(View view) {
CropImage.activity()
.setGuidelines(CropImageView.Guidelines.ON)
.setActivityTitle("My Crop")
.setCropShape(CropImageView.CropShape.OVAL)
.setRequestedSize(400, 400)
.start(this);
}

Expand Down

0 comments on commit 21cf46b

Please sign in to comment.