use of com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber in project gl-react-native by ProjectSeptemberInc.
the class GLImage method reloadImage.
private void reloadImage() {
if (pending != null && !pending.isFinished())
pending.close();
final Uri uri = src;
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setAutoRotateEnabled(// I don't really understand why need to disable this. but it actually fixes the image is properly rotated according to EXIF data
false).build();
pending = Fresco.getImagePipeline().fetchDecodedImage(imageRequest, null);
pending.subscribe(new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(@Nullable Bitmap bitmap) {
onLoad(bitmap);
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
Log.e("GLImage", "Failed to load '" + uri.getPath() + "'", dataSource.getFailureCause());
}
}, decodeExecutor);
}
use of com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber in project remusic by aa112901.
the class RadioDetailActivity method setAlbumart.
private void setAlbumart() {
albumTitle.setText(albumName);
albumArtSmall.setImageURI(Uri.parse(albumPath));
try {
ImageRequest imageRequest = ImageRequest.fromUri(albumPath);
CacheKey cacheKey = DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(imageRequest);
BinaryResource resource = ImagePipelineFactory.getInstance().getMainDiskStorageCache().getResource(cacheKey);
File file = ((FileBinaryResource) resource).getFile();
if (file != null) {
new setBlurredAlbumArt().execute(ImageUtils.getArtworkQuick(file, 300, 300));
return;
}
imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(albumPath)).setProgressiveRenderingEnabled(true).build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, RadioDetailActivity.this);
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
public void onNewResultImpl(@Nullable Bitmap bitmap) {
// No need to do any cleanup.
if (bitmap != null) {
new setBlurredAlbumArt().execute(bitmap);
}
;
}
@Override
public void onFailureImpl(DataSource dataSource) {
// No cleanup required here.
}
}, CallerThreadExecutor.getInstance());
//drawable = Drawable.createFromStream( new URL(albumPath).openStream(),"src");
} catch (Exception e) {
}
}
use of com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber in project ride-read-android by Ride-Read.
the class MapFragment method addMoment2Map.
private void addMoment2Map(final MapMoment moment) {
final LatLng latLng = new LatLng(moment.getLatitude(), moment.getLongitude());
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(moment.getPictures().get(0) + QiNiuUtils.CROP_SMALL_100)).setProgressiveRenderingEnabled(true).build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, Utils.getAppContext());
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
public void onNewResultImpl(@Nullable Bitmap bitmap) {
addMomentMarker(latLng, bitmap, moment);
}
@Override
public void onFailureImpl(DataSource dataSource) {
}
}, CallerThreadExecutor.getInstance());
}
Aggregations