ArthurHub / ArthurHub/Android-Image-Cropper
StackoverFlow error
- Dominant language
- Java
- Stars
- 6.4k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
i am unable to use cropimage inside fragment.
mImageButtonn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent galleryIntent = new Intent();
galleryIntent.setType("image/*");
galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(galleryIntent, "SELECT IMAGE"), GALLERY_PICK);
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_PICK && resultCode == RESULT_OK){
Uri imageUri = data.getData();
CropImage.activity(imageUri)
.setAspectRatio(1, 1)
.setMinCropWindowSize(500, 500)
.start(getActivity());
Toast.makeText(getActivity(), (CharSequence) imageUri, Toast.LENGTH_LONG).show();
}
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
mProgressDialog = new ProgressDialog(getContext());
mProgressDialog.setTitle("Uploading Image...");
mProgressDialog.setMessage("Please wait while we upload and process the image.");
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
Uri resultUri = result.getUri();
File thumb_filePath = new File(resultUri.getPath());
String current_user_id = mCurrentUser.getUid();
Bitmap thumb_bitmap = new Compressor(getContext())
.setMaxWidth(200)
.setMaxHeight(200)
.setQuality(75)
.compressToBitmap(thumb_filePath);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
thumb_bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
final byte[] thumb_byte = baos.toByteArray();
StorageReference filepath = mImageStorage.child("profile_images").child(current_user_id +
".jpg");
final StorageReference thumb_filepath =
mImageStorage.child("profile_images").child("thumbs").child(current_user_id + ".jpg");
filepath.putFile(resultUri).addOnCompleteListener(new
OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if(task.isSuccessful()){
final String download_url = task.getResult().getDownloadUrl().toString();
UploadTask uploadTask = thumb_filepath.putBytes(thumb_byte);
uploadTask.addOnCompleteListener(new
OnCompleteListener() {
@Override
public void onComplete(@NonNull Task thumb_task) {
String thumb_downloadUrl = thumb_task.getResult().getDownloadUrl().toString();
if(thumb_task.isSuccessful()){
Map update_hashMap = new HashMap();
update_hashMap.put("image", download_url);
update_hashMap.put("thumb_image", thumb_downloadUrl);
mUserDatabase.updateChildren(update_hashMap).addOnCompleteListener(new
OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if(task.isSuccessful()){
mProgressDialog.dismiss();
Toast.makeText(getContext(), "Success Uploading.",
Toast.LENGTH_LONG).show();
}
}
});
} else {
Toast.makeText(getContext(), "Error in uploading thumbnail.",
Toast.LENGTH_LONG).show();
mProgressDialog.dismiss();
}
}
});
} else {
Toast.makeText(getContext(), "Error in uploading.", Toast.LENGTH_LONG).show();
mProgressDialog.dismiss();
}
}
});
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
}
}
}
My gallery intent is opening but when i crop the image its getting closed and i am back to the change Image Fragment.
also in my logcat it is showing E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.jimmy.chatapplication, PID: 4315 java.lang.StackOverflowError error
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the gallery-to-crop flow in the fragment and inspect the complete Logcat stack trace for the StackOverflowError. Trace the onActivityResult callbacks around CropImage.activity and CropImage.getActivityResult, then verify the crop screen returns to the fragment without crashing and that the image upload path still completes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100