I'm trying to re-size a picture from my gallery to fit an imageview and save its bitmap after the fit so I can upload it to my Parse database on the press of an "add" button. Currently, when "add" is pressed, I check if the bitmap is null, and if it isn't, convert it to a Parsefile to be saved in my Parse database. Adding to the database works (I tested this without using Picasso), but I'm not sure how to get the bitmap if I use Picasso to resize and load. I tried creating a Target and using its callbacks, but I can't use .fit() on a target. I've resorted to using a callback, but I was hoping for a better way to achieve the saving of the bitmap.
Here's what I'm doing right now, trying to get the bitmap from the imageview after it's been loaded:
if(uri != null) {
Picasso.with(mContext).load(uri).skipMemoryCache().fit().centerCrop().into(imgPreview, new Callback() {
@Override
public void onSuccess() {
mBitmap = ((BitmapDrawable)imgPreview.getDrawable()).getBitmap();
}
@Override
public void onError() {
// TODO Auto-generated method stub
}
});
}