Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_OK) {
- if (requestCode == REQUEST_TAKE_PHOTO || requestCode == REQUEST_PICK_PHOTO) {
- if (data != null) {
- // Get the Image from data
- Uri selectedImage = data.getData();
- String[] filePathColumn = {MediaStore.Images.Media.DATA};
- Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
- assert cursor != null;
- cursor.moveToFirst();
- int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
- mediaPath = cursor.getString(columnIndex);
- // REDUZIR O TAMANHO DO ARQUIVO
- Bitmap bmp = BitmapFactory.decodeFile(mediaPath);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bmp.compress(Bitmap.CompressFormat.JPEG, 50, bos);
- if(imageView == null) {
- imageView.setImageBitmap(BitmapFactory.decodeFile(mediaPath));
- }
- else if(imageView != null){
- imageView2.setImageBitmap(BitmapFactory.decodeFile(mediaPath));
- } else if(imageView2 != null) {
- imageView3.setImageBitmap(BitmapFactory.decodeFile(mediaPath));
- }
- cursor.close();
- postPath = mediaPath;
- }
- }else if (requestCode == CAMERA_PIC_REQUEST){
- if (Build.VERSION.SDK_INT > 21) {
- Glide.with(this).load(mImageFileLocation).into(imageView);
- postPath = mImageFileLocation;
- }else{
- Glide.with(this).load(fileUri).into(imageView);
- postPath = fileUri.getPath();
- }
- }
- }
- else if (resultCode != RESULT_CANCELED) {
- Toast.makeText(this, "Ocorreu um erro!", Toast.LENGTH_LONG).show();
- }
- }
Add Comment
Please, Sign In to add comment