I have a snippet where the image is first set to imageView using Glide (the URL of the image obtained from the Internet). Then, by clicking on the image, you can select a new image from the gallery or camera target. The problem is that I am trying to set the bitmap that I get from OnActivityResult (). In fact, the image is superimposed, but superimposed by sliding. I need to show the image taken from the camera / gallery. Any help is appreciated, also if it can be done using Picasso or any other library, please suggest it. Below I am trying to do this.
onActivityResult ()
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK)
{
if (requestCode == SELECT_FILE)
onSelectFromGalleryResult(data);
else if (requestCode == REQUEST_CAMERA)
// onCaptureImageResult((Bitmap) data.getExtras().get("data"));
onCaptureImageResult(data);
}
}
private void onCaptureImageResult(Intent data)
{
if (data != null)
{
mImageUri = Uri.parse("file://" + data.getStringExtra(CameraConfiguration.Arguments.FILE_PATH));
}
try
{
bitmap_image = MediaStore.Images.Media.getBitmap(mContext.getContentResolver(), mImageUri);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap_image.compress(Bitmap.CompressFormat.JPEG, 60, bytes);
bitmap_image = Bitmap.createScaledBitmap(bitmap_image, (int) (bitmap_image.getWidth() * 0.5), (int) (bitmap_image.getHeight() * 0.5), true);
ExifInterface ei = new ExifInterface(data.getStringExtra(CameraConfiguration.Arguments.FILE_PATH));
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
switch (orientation)
{
case ExifInterface.ORIENTATION_ROTATE_90:
bitmap_image = (SnappyUtils.rotateImage(bitmap_image, 90));
break;
case ExifInterface.ORIENTATION_ROTATE_180:
bitmap_image = (SnappyUtils.rotateImage(bitmap_image, 180));
break;
case ExifInterface.ORIENTATION_ROTATE_270:
bitmap_image = (SnappyUtils.rotateImage(bitmap_image, 270));
break;
case ExifInterface.ORIENTATION_NORMAL:
default:
break;
}
}
catch (IOException e)
{
e.printStackTrace();
Log.d("exception", e.toString());
}
////////////////////// it is showing on iv_logo2 as expected as it does not has anything set by glide//////////////////////////////////////////////////////////////////
iv_logo.setBackground(null);
iv_logo.setImageBitmap(bitmap_image);
iv_logo2.setImageBitmap(bitmap_image);
///////////////////////////tried added this by seeing other SO posts //////////////////////////////////////////////////////////////////
Glide.with(mContext)
.load(mImageUri)
.signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(iv_logo);
}
Also note that this is not the same problem as removing the Glide cache