use of com.facebook.imagepipeline.request.ImageRequest in project lzc_app_lib by httplzc.
the class FunUntil method loadImg.
/**
* 加载图片
* @param targetWidth
* @param targetHeight
* @param simpleDraweeView
* @param path
*/
public static void loadImg(int targetWidth, int targetHeight, SimpleDraweeView simpleDraweeView, String path) {
if (StringManagerUtil.CheckNull(path))
return;
Uri uri = null;
try {
uri = Uri.parse(path);
} catch (Exception e) {
e.printStackTrace();
return;
}
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(targetWidth, targetHeight)).setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH).build();
AbstractDraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(simpleDraweeView.getController()).setImageRequest(request).build();
simpleDraweeView.setController(controller);
}
use of com.facebook.imagepipeline.request.ImageRequest 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.request.ImageRequest in project remusic by aa112901.
the class QuickControlsFragment method updateNowplayingCard.
public void updateNowplayingCard() {
mTitle.setText(MusicPlayer.getTrackName());
mArtist.setText(MusicPlayer.getArtistName());
ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
if (imageInfo == null) {
return;
}
QualityInfo qualityInfo = imageInfo.getQualityInfo();
FLog.d("Final image received! " + "Size %d x %d", "Quality level %d, good enough: %s, full quality: %s", imageInfo.getWidth(), imageInfo.getHeight(), qualityInfo.getQuality(), qualityInfo.isOfGoodEnoughQuality(), qualityInfo.isOfFullQuality());
}
@Override
public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
// FLog.d("Intermediate image received");
}
@Override
public void onFailure(String id, Throwable throwable) {
mAlbumArt.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_210));
}
};
Uri uri = null;
try {
uri = Uri.parse(MusicPlayer.getAlbumPath());
} catch (Exception e) {
e.printStackTrace();
}
if (uri != null) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mAlbumArt.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
mAlbumArt.setController(controller);
} else {
mAlbumArt.setImageURI(Uri.parse("content://" + MusicPlayer.getAlbumPath()));
}
}
use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.
the class ImagePipelineConfigTest method testImageRequestWhenChanged.
@Test
public void testImageRequestWhenChanged() {
ImagePipelineConfig.resetDefaultRequestConfig();
ImagePipelineConfig.getDefaultImageRequestConfig().setProgressiveRenderingEnabled(true);
final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri).build();
assertTrue(imageRequest.getProgressiveRenderingEnabled());
}
use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.
the class LocalVideoThumbnailProducer method produceResults.
@Override
public void produceResults(final Consumer<CloseableReference<CloseableImage>> consumer, final ProducerContext producerContext) {
final ProducerListener2 listener = producerContext.getProducerListener();
final ImageRequest imageRequest = producerContext.getImageRequest();
producerContext.putOriginExtra("local", "video");
final StatefulProducerRunnable cancellableProducerRunnable = new StatefulProducerRunnable<CloseableReference<CloseableImage>>(consumer, listener, producerContext, PRODUCER_NAME) {
@Override
protected void onSuccess(@Nullable CloseableReference<CloseableImage> result) {
super.onSuccess(result);
listener.onUltimateProducerReached(producerContext, PRODUCER_NAME, result != null);
producerContext.putOriginExtra("local");
}
@Override
protected void onFailure(Exception e) {
super.onFailure(e);
listener.onUltimateProducerReached(producerContext, PRODUCER_NAME, false);
producerContext.putOriginExtra("local");
}
@Override
@Nullable
protected CloseableReference<CloseableImage> getResult() throws Exception {
Bitmap thumbnailBitmap;
String path;
try {
path = getLocalFilePath(imageRequest);
} catch (IllegalArgumentException e) {
path = null;
}
thumbnailBitmap = path != null ? ThumbnailUtils.createVideoThumbnail(path, calculateKind(imageRequest)) : createThumbnailFromContentProvider(mContentResolver, imageRequest.getSourceUri());
if (thumbnailBitmap == null) {
return null;
}
CloseableStaticBitmap closeableStaticBitmap = new CloseableStaticBitmap(thumbnailBitmap, SimpleBitmapReleaser.getInstance(), ImmutableQualityInfo.FULL_QUALITY, 0);
producerContext.setExtra(ProducerContext.ExtraKeys.IMAGE_FORMAT, "thumbnail");
closeableStaticBitmap.setImageExtras(producerContext.getExtras());
return CloseableReference.<CloseableImage>of(closeableStaticBitmap);
}
@Override
protected Map<String, String> getExtraMapOnSuccess(@Nullable final CloseableReference<CloseableImage> result) {
return ImmutableMap.of(CREATED_THUMBNAIL, String.valueOf(result != null));
}
@Override
protected void disposeResult(CloseableReference<CloseableImage> result) {
CloseableReference.closeSafely(result);
}
};
producerContext.addCallbacks(new BaseProducerContextCallbacks() {
@Override
public void onCancellationRequested() {
cancellableProducerRunnable.cancel();
}
});
mExecutor.execute(cancellableProducerRunnable);
}
Aggregations