use of com.facebook.imagepipeline.core.ImagePipeline in project BigImageViewer by Piasy.
the class FrescoImageLoader method prefetch.
@Override
public void prefetch(Uri uri) {
ImagePipeline pipeline = Fresco.getImagePipeline();
pipeline.prefetchToDiskCache(ImageRequest.fromUri(uri), // we don't need context, but avoid null
false);
}
use of com.facebook.imagepipeline.core.ImagePipeline in project ride-read-android by Ride-Read.
the class PersonalityMapActivity method addMoment2Map.
private void addMoment2Map(Moment moment) {
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) {
addMarker(latLng, bitmap, moment);
}
@Override
public void onFailureImpl(DataSource dataSource) {
}
}, CallerThreadExecutor.getInstance());
}
use of com.facebook.imagepipeline.core.ImagePipeline in project DevRing by LJYcoder.
the class FrescoManager method getBitmap.
@Override
public void getBitmap(Context context, String url, final ImageListener<Bitmap> imageListener) {
// 参考自https://github.com/hpdx/fresco-helper/blob/master/fresco-helper/src/main/java/com/facebook/fresco/helper/ImageLoader.java
Uri uri = Uri.parse(url);
ImagePipeline imagePipeline = Fresco.getImagePipeline();
ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri);
ImageRequest imageRequest = builder.build();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
dataSource.subscribe(new BaseDataSubscriber<CloseableReference<CloseableImage>>() {
@Override
public void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
if (!dataSource.isFinished()) {
return;
}
CloseableReference<CloseableImage> imageReference = dataSource.getResult();
if (imageReference != null) {
final CloseableReference<CloseableImage> closeableReference = imageReference.clone();
try {
CloseableImage closeableImage = closeableReference.get();
// 动图处理
if (closeableImage instanceof CloseableAnimatedImage) {
AnimatedImageResult animatedImageResult = ((CloseableAnimatedImage) closeableImage).getImageResult();
if (animatedImageResult != null && animatedImageResult.getImage() != null) {
int imageWidth = animatedImageResult.getImage().getWidth();
int imageHeight = animatedImageResult.getImage().getHeight();
Bitmap.Config bitmapConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = Bitmap.createBitmap(imageWidth, imageHeight, bitmapConfig);
animatedImageResult.getImage().getFrame(0).renderFrame(imageWidth, imageHeight, bitmap);
if (imageListener != null) {
imageListener.onSuccess(bitmap);
}
}
} else // 非动图处理
if (closeableImage instanceof CloseableBitmap) {
CloseableBitmap closeableBitmap = (CloseableBitmap) closeableImage;
Bitmap bitmap = closeableBitmap.getUnderlyingBitmap();
if (bitmap != null && !bitmap.isRecycled()) {
// https://github.com/facebook/fresco/issues/648
final Bitmap tempBitmap = bitmap.copy(bitmap.getConfig(), false);
if (imageListener != null) {
imageListener.onSuccess(tempBitmap);
}
}
}
} finally {
imageReference.close();
closeableReference.close();
}
}
}
@Override
public void onFailureImpl(DataSource dataSource) {
Throwable throwable = dataSource.getFailureCause();
if (imageListener != null) {
imageListener.onFail(throwable);
}
}
}, UiThreadImmediateExecutorService.getInstance());
}
use of com.facebook.imagepipeline.core.ImagePipeline in project apps-android-wikipedia by wikimedia.
the class ImagePipelineBitmapGetter method get.
public void get() {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(imageUrl)).build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(request, WikipediaApp.getInstance());
dataSource.subscribe(new BitmapDataSubscriber(), UiThreadImmediateExecutorService.getInstance());
}
use of com.facebook.imagepipeline.core.ImagePipeline in project lzc_app_lib by httplzc.
the class BigImgDataRequestHelper method getHolderData.
// 获取holder 的catch
private void getHolderData(final WrapperUri wrapperUri) {
final Uri holderUri = wrapperUri.getLowUri();
if (holderUri == null)
return;
ImagePipeline imagePipeline = Fresco.getImagePipeline();
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(holderUri).setResizeOptions(new ResizeOptions(ScreenData.widthPX / 3, ScreenData.heightPX / 3)).build();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(request, "");
dataSource.subscribe(new BaseDataSubscriber<CloseableReference<CloseableImage>>() {
@Override
protected void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
if (!dataSource.isFinished()) {
return;
}
CloseableReference<CloseableImage> ref = dataSource.getResult();
if (ref != null && ref.isValid()) {
try {
if (data.get(wrapperUri.getUri()) == null) {
holderData.put(holderUri, ref.clone());
if (imgDataLoadCompleteListener != null)
imgDataLoadCompleteListener.onHolderDataLoadComplete(wrapperUri);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
CloseableReference.closeSafely(ref);
}
}
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
}
}, UiThreadImmediateExecutorService.getInstance());
}
Aggregations