Android-Image-Cropper icon indicating copy to clipboard operation
Android-Image-Cropper copied to clipboard

Problem Calling CropImage.getActivityResult from Java

Open NmMedina opened this issue 5 years ago • 8 comments

Hi there I'm coming from the old repository due I'm having problems with Android 11 when accepting the Photo but when I'm trying to get the result from the activity I can't get the result due it's not static, reviewing the Java version has the static modifier

@Nullable
public static ActivityResult getActivityResult(@Nullable Intent data) {
    return data != null ? (ActivityResult) data.getParcelableExtra(CROP_IMAGE_EXTRA_RESULT) : null;
}

but the kt file doesn't have the @JvmStatic

/**
 * Get [CropImageActivity] result data object for crop image activity started using [ ][.activity].
 *
 * @param data result data intent as received in onActivityResult(int, int, Intent).
 * @return Crop Image Activity Result object or null if none exists
 */
// TODO don't return null
fun getActivityResult(data: Intent?): ActivityResult? =
    data?.getParcelableExtra<Parcelable>(CROP_IMAGE_EXTRA_RESULT) as? ActivityResult?

Is the intended behavior? I cant figure out how to use that method, any advice will be welcome

image

NmMedina avatar Apr 13 '21 15:04 NmMedina

Hello @NmMedina welcome to the lib

Please check this discussion

We add some @JvmStatic but look like we always need more. So, before make n comments and releases for each method is better we do just one!

For this we need to add a Java Sample code, to be sure is working.

Please feel free to add the Java Sample and open a PR for it

Canato avatar Apr 13 '21 15:04 Canato

Hi, @Canato Thanks for the fast response! Perfect I going to work on this example and make a PR

NmMedina avatar Apr 13 '21 16:04 NmMedina

Let this open, so people know you are working on this!

Will link with the discussion

Canato avatar Apr 13 '21 16:04 Canato

Hello

I really need help on this, my codes is full on java so need this library working on java too.

What should I do to help you fix this bug?

I still new in PR that you mentioned, trying to push my sample in separate branch but not working. Attached is my java sample code, hope you can help me to check it. Uploading SExtendActivityJava.java.txt…

Thank you

junaediwidjojo avatar May 05 '21 11:05 junaediwidjojo

Hey @junaediwidjojo thanks for being involved =D.

To add a PR you will need to create a fork form the repository and create the PR from your forkRepo to this repo. On the top right corner of github you can see Screenshot 2021-05-05 at 12 33 46

The latest button is the one you wanna.

Later you will be able to open a PR like this: Screenshot 2021-05-05 at 12 36 41

As well, please take a read in the CONTRIBUTING GUIDE

For this work we need some stuffs:

  1. Java sample code using all methods, like we have in kotlin
  2. Add @JVMStatic where need

Canato avatar May 05 '21 11:05 Canato

meanwhile this is simple workaround: data.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_RESULT)

Nuwisam avatar May 07 '21 11:05 Nuwisam

CropImage.getPickImageChooserIntent, getPickImageResultUri also can`t be called from Java

andre719mv avatar May 12 '21 21:05 andre719mv

CropImage.getPickImageChooserIntent, getPickImageResultUri also can`t be called from Java

please open a PR or issue for this.

Canato avatar May 13 '21 08:05 Canato