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


Java ImagePipeline.fetchDecodedImage方法代碼示例

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


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

示例1: attach

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
void attach(BitmapUpdateListener listener) {
  mBitmapUpdateListener = listener;

  mAttachCounter++;
  if (mAttachCounter != 1) {
    // this is a secondary attach, ignore it, only updating Bitmap boundaries if needed.
    Bitmap bitmap = getBitmap();
    if (bitmap != null) {
      listener.onSecondaryAttach(bitmap);
    }
    return;
  }

  listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD_START);

  Assertions.assertCondition(mDataSource == null);
  Assertions.assertCondition(mImageRef == null);

  // Submit the request
  ImagePipeline imagePipeline = ImagePipelineFactory.getInstance().getImagePipeline();
  mDataSource = imagePipeline.fetchDecodedImage(mImageRequest, RCTImageView.getCallerContext());
  mDataSource.subscribe(this, UiThreadImmediateExecutorService.getInstance());
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:24,代碼來源:PipelineRequestHelper.java

示例2: setImage

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public void setImage(String uri) {
    if (uri == null) {
        iconBitmapDescriptor = null;
        update();
    } else if (uri.startsWith("http://") || uri.startsWith("https://") ||
            uri.startsWith("file://")) {
        ImageRequest imageRequest = ImageRequestBuilder
                .newBuilderWithSource(Uri.parse(uri))
                .build();

        ImagePipeline imagePipeline = Fresco.getImagePipeline();
        dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setControllerListener(mLogoControllerListener)
                .setOldController(logoHolder.getController())
                .build();
        logoHolder.setController(controller);
    } else {
        iconBitmapDescriptor = getBitmapDescriptorByName(uri);
        update();
    }
}
 
開發者ID:laoqiu,項目名稱:react-native-amap,代碼行數:24,代碼來源:AMapMarker.java

示例3: loadBitmapFromUrl

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public static void loadBitmapFromUrl(Context context, String url, String cookie, String referer, BaseBitmapDataSubscriber dataSubscriber) {
    if (TextUtils.isEmpty(url))
        return;
    Uri uri = Uri.parse(url);
    JsonObject header = new JsonObject();
    header.addProperty("Cookie", cookie);
    header.addProperty("Referer", referer);
    if (HProxy.isEnabled() && HProxy.isAllowPicture()) {
        HProxy proxy = new HProxy(url);
        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<CloseableImage>>
            dataSource = imagePipeline.fetchDecodedImage(request, context);
    dataSource.subscribe(dataSubscriber, CallerThreadExecutor.getInstance());
}
 
開發者ID:PureDark,項目名稱:H-Viewer,代碼行數:20,代碼來源:ImageLoader.java

示例4: LoadImageFromURLAndCallBack

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public static void LoadImageFromURLAndCallBack(SimpleDraweeView destImageView , String URL,Context context,BaseBitmapDataSubscriber bbds)
{
    int w = destImageView.getWidth();
    int h  =destImageView.getHeight();
    if(w<1){
        w = destImageView.getLayoutParams().width;
    }
    if(h<1){
        h  =destImageView.getLayoutParams().height;
    }
    ImageRequest imageRequest =
            ImageRequestBuilder.newBuilderWithSource(Uri.parse(URL))
                    .setResizeOptions(new ResizeOptions(w,h))
                    .setProgressiveRenderingEnabled(true)
                    .build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
    dataSource.subscribe(bbds, CallerThreadExecutor.getInstance());
    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setImageRequest(imageRequest)
            .setOldController(destImageView.getController())
            .setAutoPlayAnimations(true)
            .build();
    destImageView.setController(draweeController);
}
 
開發者ID:tianyuan168326,項目名稱:nono-android,代碼行數:26,代碼來源:FrescoImageloadHelper.java

示例5: LoadImageFromURIAndCallBack

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public static void LoadImageFromURIAndCallBack(SimpleDraweeView destImageView , Uri uri,Context context,BaseBitmapDataSubscriber bbds)
{
    int w = destImageView.getWidth();
    int h  =destImageView.getHeight();
    if(w<1){
        w = destImageView.getLayoutParams().width;
    }
    if(h<1){
        h  =destImageView.getLayoutParams().height;
    }
    ImageRequest imageRequest =
            ImageRequestBuilder.newBuilderWithSource(uri)
                    .setResizeOptions(new ResizeOptions(w,h))
                    .setProgressiveRenderingEnabled(true)
                    .build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
    dataSource.subscribe(bbds, CallerThreadExecutor.getInstance());
    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setImageRequest(imageRequest)
            .setOldController(destImageView.getController())
            .setAutoPlayAnimations(true)
            .build();
    destImageView.setController(draweeController);
}
 
開發者ID:tianyuan168326,項目名稱:nono-android,代碼行數:26,代碼來源:FrescoImageloadHelper.java

示例6: displayImage

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
/**
 * 加載遠程圖片
 *
 * @param url
 * @param imageSize
 */
private void displayImage(Uri url, ResizeOptions imageSize, final ImageView imageView, final DraweeHolder<GenericDraweeHierarchy> draweeHolder) {
    ImageRequest imageRequest = ImageRequestBuilder
            .newBuilderWithSource(url)
            .setResizeOptions(imageSize)//圖片目標大小
            .build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();

    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeHolder.getController())
            .setImageRequest(imageRequest)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String s, ImageInfo imageInfo, Animatable animatable) {
                    CloseableReference<CloseableImage> imageReference = null;
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null && imageView != null) {
                                    imageView.setImageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    draweeHolder.setController(controller);
}
 
開發者ID:YuanPengandy,項目名稱:GalleryFinal-master,代碼行數:44,代碼來源:FrescoImageLoader.java

示例7: setImageUri

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public void setImageUri(String url) {
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)).build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(mDraweeHolder.getController())
            .setImageRequest(imageRequest)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String s, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            // do something with the image
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null) {
                                    setImageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    mDraweeHolder.setController(controller);
}
 
開發者ID:lizubing1992,項目名稱:Li-MVPArms,代碼行數:34,代碼來源:PhotoView.java

示例8: getBitmapWithFresco

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public static void getBitmapWithFresco(Context context, String url, BaseBitmapDataSubscriber baseBitmapDataSubscriber) {
    ImageRequest imageRequest = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>>
            dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
    dataSource.subscribe(baseBitmapDataSubscriber,
            CallerThreadExecutor.getInstance());
}
 
開發者ID:luania,項目名稱:witchpot,代碼行數:13,代碼來源:MediaUtil.java

示例9: instantiateItem

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
@Override
public View instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(ImageViewActivity.this).inflate(R.layout.item_imagepage, container, false);
    final PhotoView photoView = (PhotoView) view.findViewById(R.id.photoview);
    final View wheel = view.findViewById(R.id.wheel);
    photoView.setOnPhotoTapListener((view1, v, v1) -> finish());

    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(urls.get(position))
            .setResizeOptions(new ResizeOptions(768, 768))
            .build();
    DataSource<CloseableReference<CloseableImage>>
            dataSource = imagePipeline.fetchDecodedImage(request,this);
    DataSubscriber dataSubscriber = new BaseBitmapDataSubscriber() {
        @Override
        protected void onNewResultImpl(Bitmap bitmap) {
              photoView.setImageBitmap(bitmap);
              wheel.setVisibility(View.GONE);
        }

        @Override
        protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> closeableReferenceDataSource) {

        }
    };
    dataSource.subscribe(dataSubscriber, new Executor() {
        @Override
        public void execute(Runnable command) {
            handler.post(command);
        }
    });
    container.addView(view);
    return view;
}
 
開發者ID:Jude95,項目名稱:Fishing,代碼行數:35,代碼來源:ImageViewActivity.java

示例10: get

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
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());
}
 
開發者ID:wikimedia,項目名稱:apps-android-wikipedia,代碼行數:9,代碼來源:ImagePipelineBitmapGetter.java

示例11: setSubscribe

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
private static final void setSubscribe(Context context, ImageRequest request, BaseDataSubscriber subscriber) {
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> dataSource =
            imagePipeline.fetchDecodedImage(request, context);
    dataSource.subscribe(subscriber, CallerThreadExecutor.getInstance());
}
 
開發者ID:goodev,項目名稱:materialup,代碼行數:7,代碼來源:FrescoUtils.java

示例12: setImageUri

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public void setImageUri(String uri, ResizeOptions options) {

		final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri))
				.setResizeOptions(options)
				.setAutoRotateEnabled(true)
				.build();
		final ImagePipeline imagePipeline = Fresco.getImagePipeline();
		final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
		final AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
				.setOldController(mDraweeHolder.getController())
				.setImageRequest(imageRequest)
				.setControllerListener(new BaseControllerListener<ImageInfo>() {
					@Override
					public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
						super.onFinalImageSet(id, imageInfo, animatable);

						CloseableReference<CloseableImage> imageCloseableReference = null;
						try {
							imageCloseableReference = dataSource.getResult();
							if (imageCloseableReference != null) {
								final CloseableImage image = imageCloseableReference.get();
								if (image != null && image instanceof CloseableStaticBitmap) {
									CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
									final Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
									if (bitmap != null) {
										setImageBitmap(bitmap);
										// 如果是長圖,讓其寬度放大至與屏幕等寬
										setScaleType(ScaleType.CENTER_CROP);
									}
								}
							}
						} finally {
							dataSource.close();
							CloseableReference.closeSafely(imageCloseableReference);
						}
					}
				})
				.build();
		mDraweeHolder.setController(controller);
		setImageDrawable(mDraweeHolder.getTopLevelDrawable());
	}
 
開發者ID:iflove,項目名稱:gank-examples,代碼行數:42,代碼來源:MyPhotoView.java

示例13: loadImageInternal

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
/**
 * Internal helper method for load Bitmap.
 *
 * @param maxSize 0 or less than 0 if want original bitmap.
 */
@Override
public void loadImageInternal(
        final Uri uri,
        final int maxSize,
        final ImageLoaderUtils.ImageLoadListener listener) {

    if (uri == null) {
        listener.onFailed(-1);
        return;
    }

    ImageRequestBuilder builder = ImageRequestBuilder
            .newBuilderWithSource(uri)
            .setAutoRotateEnabled(true);
    if (maxSize > 0) {
        builder.setResizeOptions(new ResizeOptions(maxSize, maxSize));
    }

    ImagePipeline pipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> data =
            pipeline.fetchDecodedImage(builder.build(), null);

    Executor executor = new Executor() {
        @Override
        public void execute(@NonNull Runnable command) {
            ThreadManager.getInstance().postOnUIHandler(command);
        }
    };

    data.subscribe(new BaseBitmapDataSubscriber() {
        @Override
        protected void onNewResultImpl(Bitmap bitmap) {
            if (bitmap == null) {
                listener.onFailed(ImageLoaderUtils.ERROR_LOAD_EMPTY_IMAGE);
                return;
            }

            final int width = bitmap.getWidth();
            final int height = bitmap.getHeight();
            try {
                if (maxSize <= 0 || (width <= maxSize && height <= maxSize)) {
                    listener.onSuccess(uri, Bitmap.createBitmap(bitmap));
                } else {
                    JungleSize size = ImageUtils.getMaxScaleSize(
                            bitmap.getWidth(), bitmap.getHeight(), maxSize);
                    listener.onSuccess(uri, Bitmap.createScaledBitmap(
                            bitmap, size.getWidth(), size.getHeight(), true));
                }
            } catch (Throwable e) {
                e.printStackTrace();
                listener.onSuccess(uri, bitmap);
            }
        }

        @Override
        protected void onFailureImpl(
                DataSource<CloseableReference<CloseableImage>> dataSource) {
            listener.onFailed(ImageLoaderUtils.ERROR_LOAD_FAILED);
        }
    }, executor);
}
 
開發者ID:Android-Jungle,項目名稱:android-jungle-framework,代碼行數:67,代碼來源:FrescoImageLoaderEngine.java

示例14: setImageUri

import com.facebook.imagepipeline.core.ImagePipeline; //導入方法依賴的package包/類
public void setImageUri(String uri) {

    final ImageRequest imageRequest =
        ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).setResizeOptions(null).setAutoRotateEnabled(true).build();
    final ImagePipeline imagePipeline = Fresco.getImagePipeline();
    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
    final AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
        .setOldController(mDraweeHolder.getController())
        .setAutoPlayAnimations(true)
        .setImageRequest(imageRequest)
        .setControllerListener(new BaseControllerListener<ImageInfo>() {
          @Override public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);

            // set flag if this is an animated image
            if (animatable != null) {
              isAnimation = true;
            }

            CloseableReference<CloseableImage> imageCloseableReference = null;
            try {
              imageCloseableReference = dataSource.getResult();
              if (imageCloseableReference != null) {
                final CloseableImage image = imageCloseableReference.get();
                if (image != null && image instanceof CloseableStaticBitmap) {
                  CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                  final Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                  if (bitmap != null) {
                    setImageBitmap(bitmap);
                  }
                }
              }
            } finally {
              dataSource.close();
              CloseableReference.closeSafely(imageCloseableReference);
            }
          }
        })
        .build();
    mDraweeHolder.setController(controller);
    setImageDrawable(mDraweeHolder.getTopLevelDrawable());
  }
 
開發者ID:zfdang,項目名稱:zSMTH-Android,代碼行數:43,代碼來源:MyPhotoView.java


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