Cropping_SampleCode
public class MainActivity extends AppCompatActivity {
@Bind(R.id.imgSelCrop)
ImageView ivSelectImage;
@Bind(R.id.btnSelectimg)
Button btnSelectImage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
btnSelectImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CropImage.activity(null)
.setGuidelines(CropImageView.Guidelines.ON)
.start(MainActivity.this);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// handle result of CropImageActivity
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
ivSelectImage.setImageURI(result.getUri());
Log.e("uri-", "-" + result.getUri());
Toast.makeText(this, "Cropping done, Thumbnail: " + result.getSampleSize(), Toast.LENGTH_LONG).show();
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show();
}
}
}
}
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
No comments :
Post a Comment