Non capisco il comportamento mentre sto recuperando Bitmap
utilizzando Fresco
utilizzando ImagePipeline
. Quando eseguo il debug del mio codice è in esecuzione onNewResultImpl
o onFailureImpl
e quando eseguo l'applicazione non funziona significa che non viene chiamato onFailureImpl
o onNewResultImpl
(lo sto verificando utilizzando Toast
e Log
durante l'esecuzione dell'app). Ho visto questo SO Question and take ref from it e anche from Fresco's
doc.Prova a recuperare la bitmap da uri utilizzando Fresco
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
case ACTION_OPEN_GALLERY:
mImageCaptureUri = data.getData();
if (mImageCaptureUri != null) {
commentImgView.setImageURI(mImageCaptureUri);//mImageCaptureUri is working fine
try {
imageRequest = ImageRequestBuilder
.newBuilderWithSource(mImageCaptureUri)
.setRequestPriority(Priority.HIGH)
.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
.build();
dataSource = imagePipeline.fetchDecodedImage(imageRequest, CommentActivity.this);
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(@Nullable Bitmap bitmap) {
if (bitmap != null) {
bmp = Bitmap.createBitmap(bitmap);
Log.d("Bitmap ","after callback");
Toast.makeText(CommentActivity.this,"has bitmap",Toast.LENGTH_SHORT).show();
} else {
Log.d("Bitmap is null ","after callback");
Toast.makeText(CommentActivity.this,"bitmap is null",Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
Log.d("Bitmap ","after callback failure");
Toast.makeText(CommentActivity.this,"Failure",Toast.LENGTH_SHORT).show();
}
}, CallerThreadExecutor.getInstance());
} catch (Exception e){
e.printStackTrace();
} finally {
if (dataSource != null) {
dataSource.close();
}
}
}
}
}
}
Nota: Sto cercando di ottenere bitmap immagine jpg non da da un'immagine qualsiasi gif animate
provare dichiarando 'imageRequest, imagePipeline e dataSource' a livello di classe –
@KaranMer alcun effetto – kId
assicurarsi che si sta utilizzando le ultime file di libreria e file jar –