use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class ImageRequestTest method testCreatingRequestFromExistingRequest.
@Test
public void testCreatingRequestFromExistingRequest() {
ImageRequest original = ImageRequestBuilder.newBuilderWithSource(Uri.parse("http://frescolib.org/image.jpg")).setCacheChoice(ImageRequest.CacheChoice.SMALL).setImageDecodeOptions(new ImageDecodeOptionsBuilder().build()).setLocalThumbnailPreviewsEnabled(true).setLowestPermittedRequestLevel(ImageRequest.RequestLevel.DISK_CACHE).setPostprocessor(new BasePostprocessor() {
@Override
public String getName() {
return super.getName();
}
}).setProgressiveRenderingEnabled(true).setRequestListener(new RequestLoggingListener()).setResizeOptions(new ResizeOptions(20, 20)).setRotationOptions(RotationOptions.forceRotation(RotationOptions.ROTATE_90)).setRequestPriority(Priority.HIGH).build();
ImageRequest copy = ImageRequestBuilder.fromRequest(original).build();
assertThat(copy).isEqualTo(original);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class VitoViewRecyclerFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
final RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
final int imageSize = (right - left) / SPAN_COUNT;
mResizeOptions = new ResizeOptions(imageSize, imageSize);
mOptionsBuilder = mOptionsBuilder.resize(mResizeOptions);
}
});
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), SPAN_COUNT);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
final SimpleAdapter adapter = new SimpleAdapter(new ArrayList<Uri>());
recyclerView.setAdapter(adapter);
final Spinner imageSource = view.findViewById(R.id.spinner_image_source);
ImageSourceSpinner.INSTANCE.setup(imageSource, sampleUris(), new Function1<List<Uri>, Unit>() {
@Override
public Unit invoke(List<Uri> uris) {
adapter.setData(uris);
return null;
}
});
}
use of com.facebook.imagepipeline.common.ResizeOptions in project teaTime by ancfdy.
the class FrescoUtils method loadImage.
/**
* 请求图片
* @param uri - 唯一的必选的成员. 参考 支持的URIs
* @param width
* @param height
* autoRotateEnabled - 是否支持自动旋转.
* progressiveEnabled - 是否支持渐进式加载.
* postprocessor - 后处理器(postprocess).
* resizeOptions - 图片缩放选项,用前请先阅读缩放和旋转
*/
public static void loadImage(SimpleDraweeView draweeView, String uri, int width, int height) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).setAutoRotateEnabled(// 是否支持自动旋转.
true).setImageDecodeOptions(// 图片解码库
getImageDecodeOptions()).setLowestPermittedRequestLevel(// 请求经过缓存级别 BITMAP_MEMORY_CACHE,ENCODED_MEMORY_CACHE,DISK_CACHE,FULL_FETCH
RequestLevel.FULL_FETCH).setProgressiveRenderingEnabled(// 渐进加载,主要用于渐进式的JPEG图,影响图片显示速度(普通)
false).setResizeOptions(new ResizeOptions(width, height)).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(draweeView.getController()).build();
draweeView.setController(controller);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project MyDiary by erttyy8821.
the class DiaryPhotoLayout method setPhotoUri.
public void setPhotoUri(Uri photoUri) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(photoUri).setResizeOptions(new ResizeOptions(DiaryItemHelper.getVisibleWidth(getContext()), DiaryItemHelper.getVisibleHeight(getContext()))).setRotationOptions(RotationOptions.autoRotate()).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).build();
SDV_diary_new_photo.setController(controller);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project MyDiary by erttyy8821.
the class PhotoOverviewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final SimpleViewHolder holder, final int position) {
final Uri photoUri = diaryPhotoFileList.get(position);
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(diaryPhotoFileList.get(position)).setResizeOptions(new ResizeOptions(resizePhotoWidth, resizePhotoHeight)).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setTapToRetryEnabled(false).build();
holder.SDV_CV_diary_photo_overview.setController(controller);
}
Aggregations