I have been following a tutorial on how to select a picture, crop it and upload to my app... it selects, it crops but it uploads the un-cropped picture...I don't see any errors...
There is :
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == REQUEST_WRITE_PERMISSION && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//THIS IS HAPPEN WHEN USER CLICK ALLOW ON PERMISSION
//START PICK IMAGE ACTIVITY
CropImage.startPickImageActivity(addceleb.this);
}
}
this starts the function :
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
Uri imageUri = CropImage.getPickImageResultUri(this, data);
Log.i("RESPONSE getPath", imageUri.getPath());
Log.i("RESPONSE getScheme", imageUri.getScheme());
Log.i("RESPONSE PathSegments", imageUri.getPathSegments().toString());
//GET IMAGEVIEW RESULT URI AND PASS TO IMAGEVIEW
imageView.setImageURI(imageUri);
//NOW CROP IMAGE URI
CropImage.activity(imageUri)
.setGuidelines(CropImageView.Guidelines.ON)
.setMultiTouchEnabled(true)
.setRequestedSize(800, 800)
.setAspectRatio(1,1)
.start(this);
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
Log.i("RESPONSE getUri", result.getUri().toString());
//GET CROPPED IMAGE URI AND PASS TO IMAGEVIEW
imageView.setImageURI(result.getUri());
}
}
}
the following suggestion is displayed:
Condition 'requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE' is always 'false' less... (Ctrl+F1)
Inspection info: This inspection analyzes method control and data flow to report possible conditions that are always true or false, expressions whose value is statically proven to be constant, and situations that can lead to nullability contract violations.
Variables, method parameters and return values marked as @Nullable or @NotNull are treated as nullable (or not-null, respectively) and used during the analysis to check nullability contracts, e.g. report NullPointerException (NPE) errors that might be produced.
More complex contracts can be defined using @Contract annotation, for example:
@Contract("_, null -> null") — method returns null if its second argument is null @Contract("_, null -> null; _, !null -> !null") — method returns null if its second argument is null and not-null otherwise @Contract("true -> fail") — a typical assertFalse method which throws an exception if true is passed to it
The inspection can be configured to use custom @Nullable
@NotNull annotations (by default the ones from annotations.jar will be used)
Aucun commentaire:
Enregistrer un commentaire