當前位置: 首頁>>代碼示例>>Java>>正文


Java ImagePipeline.fetchEncodedImage方法代碼示例

本文整理匯總了Java中com.facebook.imagepipeline.core.ImagePipeline.fetchEncodedImage方法的典型用法代碼示例。如果您正苦於以下問題:Java ImagePipeline.fetchEncodedImage方法的具體用法?Java ImagePipeline.fetchEncodedImage怎麽用?Java ImagePipeline.fetchEncodedImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.facebook.imagepipeline.core.ImagePipeline的用法示例。


在下文中一共展示了ImagePipeline.fetchEncodedImage方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadResourceFromUrl

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public static void loadResourceFromUrl(Context context, Uri uri, String cookie, String referer, BaseDataSubscriber dataSubscriber) {
    if (uri.getScheme().startsWith("http")) {
        JsonObject header = new JsonObject();
        header.addProperty("Cookie", cookie);
        header.addProperty("Referer", referer);
        if (HProxy.isEnabled() && HProxy.isAllowPicture()) {
            HProxy proxy = new HProxy(uri.toString());
            header.addProperty(proxy.getHeaderKey(), proxy.getHeaderValue());
        }
        MyOkHttpNetworkFetcher.headers.put(uri, getGson().toJson(header));
    }
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri);
    ImageRequest request = builder.build();
    DataSource<CloseableReference<PooledByteBuffer>>
            dataSource = imagePipeline.fetchEncodedImage(request, context);
    dataSource.subscribe(dataSubscriber, CallerThreadExecutor.getInstance());
}
 
開發者ID:PureDark,項目名稱:H-Viewer,代碼行數:19,代碼來源:ImageLoader.java

示例2: save

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public static void save(Uri uri, String action) {
    ImageRequest request = ImageRequest.fromUri(uri);
    ImagePipeline pipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<PooledByteBuffer>> dataSource =
            pipeline.fetchEncodedImage(request, null);

    ImageSubscriber dataSubscriber = new ImageSubscriber(uri, action);

    dataSource.subscribe(dataSubscriber,
            ExpressApplication.getApplication().getImagePipelineConfig()
                    .getExecutorSupplier().forLocalStorageWrite());
}
 
開發者ID:mingdroid,項目名稱:tumbviewer,代碼行數:13,代碼來源:FrescoUtils.java

示例3: loadImage

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
@Override
public void loadImage(int requestId, Uri uri, final Callback callback) {
    ImageRequest request = ImageRequest.fromUri(uri);

    File localCache = getCacheFile(request);
    if (localCache.exists()) {
        callback.onCacheHit(localCache);
        callback.onSuccess(localCache);
    } else {
        callback.onStart(); // ensure `onStart` is called before `onProgress` and `onFinish`
        callback.onProgress(0); // show 0 progress immediately

        ImagePipeline pipeline = Fresco.getImagePipeline();
        DataSource<CloseableReference<PooledByteBuffer>> source
                = pipeline.fetchEncodedImage(request, true);
        source.subscribe(new ImageDownloadSubscriber(mAppContext) {
            @Override
            protected void onProgress(int progress) {
                callback.onProgress(progress);
            }

            @Override
            protected void onSuccess(final File image) {
                callback.onFinish();
                callback.onCacheMiss(image);
                callback.onSuccess(image);
            }

            @Override
            protected void onFail(final Throwable t) {
                t.printStackTrace();
                callback.onFail((Exception) t);
            }
        }, mExecutorSupplier.forBackgroundTasks());

        closeSource(requestId);
        saveSource(requestId, source);
    }
}
 
開發者ID:Piasy,項目名稱:BigImageViewer,代碼行數:40,代碼來源:FrescoImageLoader.java

示例4: loadImage

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
@Override
public void loadImage(Uri uri, final Callback callback) {
    ImageRequest request = ImageRequest.fromUri(uri);

    File localCache = getCacheFile(request);
    if (localCache.exists()) {
        callback.onCacheHit(localCache);
    } else {
        callback.onStart(); // ensure `onStart` is called before `onProgress` and `onFinish`
        callback.onProgress(0); // show 0 progress immediately

        ImagePipeline pipeline = Fresco.getImagePipeline();
        DataSource<CloseableReference<PooledByteBuffer>> source
                = pipeline.fetchEncodedImage(request, true);
        source.subscribe(new ImageDownloadSubscriber(mAppContext) {
            @Override
            protected void onProgress(int progress) {
                callback.onProgress(progress);
            }

            @Override
            protected void onSuccess(File image) {
                callback.onFinish();
                callback.onCacheMiss(image);
            }

            @Override
            protected void onFail(Throwable t) {
                // TODO: 12/11/2016 fail
                t.printStackTrace();
            }
        }, mExecutorSupplier.forBackgroundTasks());
    }
}
 
開發者ID:love-311,項目名稱:BigImageViewer-master,代碼行數:35,代碼來源:FrescoImageLoader.java

示例5: intercept

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
@Override
public BitmapRegionDecoder intercept(Chain chain) throws IOException {
    final Uri uri = chain.uri();
    BitmapRegionDecoder decoder = chain.chain(uri);
    if (decoder != null){
        return decoder;
    }

    if (UriUtil.isNetworkUri(uri)){
        ImagePipeline imagePipeline = ImagePipelineFactory.getInstance().getImagePipeline();

        ImageRequest request = ImageRequest.fromUri(uri);
        DataSource<CloseableReference<PooledByteBuffer>> dataSource = imagePipeline.fetchEncodedImage(request,null);
        try {
            CloseableReference<PooledByteBuffer> ref = DataSources.waitForFinalResult(dataSource);
            if (ref == null){
                return null;
            }
            PooledByteBuffer result = ref.get();
            if (BuildConfig.DEBUG) {
                Log.d("FrescoInterceptor", "從我這加載");
            }
            try {
                InputStream inputStream = new PooledByteBufferInputStream(result);
                Closeables.closeQuietly(inputStream);
                return BitmapRegionDecoder.newInstance(inputStream,false);
            } catch (IOException e) {
                ImageRequest imageRequest=ImageRequest.fromUri(uri);
                CacheKey cacheKey= DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(imageRequest,null);
                BinaryResource resource = ImagePipelineFactory.getInstance().getMainFileCache().getResource(cacheKey);
                File file=((FileBinaryResource)resource).getFile();
                if (BuildConfig.DEBUG) {
                    Log.d("FrescoInterceptor", file.getName());
                }
                return Interceptors.fixJPEGDecoder(file,e);
            }
        } catch (Throwable throwable) {
            if (BuildConfig.DEBUG) {
                Log.d("FrescoInterceptor", "intercept: 加載失敗了");
            }
            throwable.printStackTrace();
            return null;
        }
    }

    return null;
}
 
開發者ID:EvilBT,項目名稱:HDImageView,代碼行數:48,代碼來源:FrescoInterceptor.java


注:本文中的com.facebook.imagepipeline.core.ImagePipeline.fetchEncodedImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。