Search in sources :

Example 1 with WrapperUri

use of com.yioks.lzclib.Data.WrapperUri 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());
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CloseableReference(com.facebook.common.references.CloseableReference) ImagePipeline(com.facebook.imagepipeline.core.ImagePipeline) Uri(android.net.Uri) WrapperUri(com.yioks.lzclib.Data.WrapperUri)

Aggregations

Uri (android.net.Uri)1 CloseableReference (com.facebook.common.references.CloseableReference)1 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)1 ImagePipeline (com.facebook.imagepipeline.core.ImagePipeline)1 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)1 WrapperUri (com.yioks.lzclib.Data.WrapperUri)1