com.facebook.datasource.DataSource Java Examples

The following examples show how to use com.facebook.datasource.DataSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FrescoVitoImage2Spec.java    From fresco with MIT License 6 votes vote down vote up
@OnBind
static void onBind(
    ComponentContext c,
    final FrescoDrawable2 frescoDrawable,
    @Prop(optional = true) final @Nullable Object callerContext,
    @Prop(optional = true) final @Nullable ImageListener imageListener,
    @CachedValue VitoImageRequest imageRequest,
    @FromPrepare DataSource<Void> prefetchDataSource,
    @FromBoundsDefined Rect viewportDimensions) {
  // We fetch in both mount and bind in case an unbind event triggered a delayed release.
  // We'll only trigger an actual fetch if needed. Most of the time, this will be a no-op.
  FrescoVitoProvider.getController()
      .fetch(frescoDrawable, imageRequest, callerContext, imageListener, viewportDimensions);
  if (prefetchDataSource != null) {
    prefetchDataSource.close();
  }
}
 
Example #2
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testPrefetchToEncodedCacheCustomPriority() {
  Producer<Void> prefetchProducerSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(mImageRequest))
      .thenReturn(prefetchProducerSequence);
  DataSource<Void> dataSource =
      mImagePipeline.prefetchToEncodedCache(mImageRequest, mCallerContext, Priority.MEDIUM);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(prefetchProducerSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.MEDIUM);
}
 
Example #3
Source File: FrescoController2Impl.java    From fresco with MIT License 6 votes vote down vote up
private static Extras obtainExtras(
    @Nullable DataSource<CloseableReference<CloseableImage>> dataSource,
    CloseableReference<CloseableImage> image,
    FrescoDrawable2 drawable) {
  Map<String, Object> imageExtras = null;
  if (image != null && image.get() != null) {
    imageExtras = image.get().getExtras();
  }
  return MiddlewareUtils.obtainExtras(
      COMPONENT_EXTRAS,
      SHORTCUT_EXTRAS,
      dataSource == null ? null : dataSource.getExtras(),
      drawable.getViewportDimensions(),
      String.valueOf(drawable.getActualImageScaleType()),
      drawable.getActualImageFocusPoint(),
      imageExtras,
      drawable.getCallerContext(),
      null);
}
 
Example #4
Source File: FrescoVitoPrefetcherImpl.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Prefetch an image to the given {@link PrefetchTarget}
 *
 * <p>Beware that if your network fetcher doesn't support priorities prefetch requests may slow
 * down images which are immediately required on screen.
 *
 * @param prefetchTarget the target to prefetch to
 * @param uri the image URI to prefetch
 * @param imageOptions the image options used to display the image
 * @param callerContext the caller context for the given image
 * @return a DataSource that can safely be ignored.
 */
public DataSource<Void> prefetch(
    PrefetchTarget prefetchTarget,
    final Uri uri,
    final @Nullable ImageOptions imageOptions,
    final @Nullable Object callerContext) {
  switch (prefetchTarget) {
    case MEMORY_DECODED:
      return prefetchToBitmapCache(uri, imageOptions, callerContext);
    case MEMORY_ENCODED:
      return prefetchToEncodedCache(uri, imageOptions, callerContext);
    case DISK:
      return prefetchToDiskCache(uri, imageOptions, callerContext);
  }
  return DataSources.immediateFailedDataSource(
      new CancellationException("Prefetching is not enabled"));
}
 
Example #5
Source File: ImagePipeline.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
private DataSource<Void> submitPrefetchRequest(
    Producer<Void> producerSequence,
    ImageRequest imageRequest,
    Object callerContext) {
  SettableProducerContext settableProducerContext = new SettableProducerContext(
      imageRequest,
      generateUniqueFutureId(),
      mRequestListener,
      callerContext,
      /* isPrefetch */ true,
      /* isIntermediateResultExpected */ false,
      Priority.LOW);
  return ProducerToDataSourceAdapter.create(
      producerSequence,
      settableProducerContext,
      mRequestListener);
}
 
Example #6
Source File: DraweeSpan.java    From drawee-text-view with Apache License 2.0 6 votes vote down vote up
private void onFailureInternal(String id,
        DataSource<CloseableReference<CloseableImage>> dataSource,
        Throwable throwable, boolean isFinished) {
    if (FLog.isLoggable(Log.WARN)) {
        FLog.w(DraweeSpan.class, id + " load failure", throwable);
    }
    // ignored this result
    if (!getId().equals(id)
            || dataSource != mDataSource
            || !mIsRequestSubmitted) {
        dataSource.close();
        return;
    }
    if (isFinished) {
        mDataSource = null;
        // Set the previously available image if available.
        setDrawableInner(mDrawable);
    }
}
 
Example #7
Source File: ImagePipeline.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Returns a DataSource supplier that will on get submit the request for execution and return a
 * DataSource representing the pending results of the task.
 *
 * @param imageRequest the request to submit (what to execute).
 * @param callerContext the caller context of the caller of data source supplier
 * @param requestLevel which level to look down until for the image
 * @param requestListener additional image request listener independent of ImageRequest listeners
 * @return a DataSource representing pending results and completion of the request
 */
public Supplier<DataSource<CloseableReference<CloseableImage>>> getDataSourceSupplier(
    final ImageRequest imageRequest,
    final Object callerContext,
    final ImageRequest.RequestLevel requestLevel,
    final @Nullable RequestListener requestListener) {
  return new Supplier<DataSource<CloseableReference<CloseableImage>>>() {
    @Override
    public DataSource<CloseableReference<CloseableImage>> get() {
      return fetchDecodedImage(imageRequest, callerContext, requestLevel, requestListener);
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this).add("uri", imageRequest.getSourceUri()).toString();
    }
  };
}
 
Example #8
Source File: AbstractDraweeControllerBuilder.java    From fresco with MIT License 6 votes vote down vote up
/** Creates a data source supplier for the given image request. */
protected Supplier<DataSource<IMAGE>> getDataSourceSupplierForRequest(
    final DraweeController controller,
    final String controllerId,
    final REQUEST imageRequest,
    final CacheLevel cacheLevel) {
  final Object callerContext = getCallerContext();
  return new Supplier<DataSource<IMAGE>>() {
    @Override
    public DataSource<IMAGE> get() {
      return getDataSourceForRequest(
          controller, controllerId, imageRequest, callerContext, cacheLevel);
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this).add("request", imageRequest.toString()).toString();
    }
  };
}
 
Example #9
Source File: VitoImagePipelineImpl.java    From fresco with MIT License 6 votes vote down vote up
@Override
public DataSource<CloseableReference<CloseableImage>> fetchDecodedImage(
    final VitoImageRequest imageRequest,
    final @Nullable Object callerContext,
    final @Nullable RequestListener requestListener,
    final long uiComponentId) {
  if (!(imageRequest.imageSource instanceof VitoImageSource)) {
    return DataSources.immediateFailedDataSource(
        new IllegalArgumentException("Unknown ImageSource " + imageRequest.imageSource));
  }
  VitoImageSource vitoImageSource = (VitoImageSource) imageRequest.imageSource;
  final String stringId = VitoUtils.getStringId(uiComponentId);
  return vitoImageSource
      .createDataSourceSupplier(
          mImagePipeline,
          mImagePipelineUtils,
          imageRequest.imageOptions,
          callerContext,
          requestListener,
          stringId)
      .get();
}
 
Example #10
Source File: BaseBitmapDataSubscriber.java    From fresco with MIT License 6 votes vote down vote up
@Override
public void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
  if (!dataSource.isFinished()) {
    return;
  }

  CloseableReference<CloseableImage> closeableImageRef = dataSource.getResult();
  Bitmap bitmap = null;
  if (closeableImageRef != null && closeableImageRef.get() instanceof CloseableBitmap) {
    bitmap = ((CloseableBitmap) closeableImageRef.get()).getUnderlyingBitmap();
  }

  try {
    onNewResultImpl(bitmap);
  } finally {
    CloseableReference.closeSafely(closeableImageRef);
  }
}
 
Example #11
Source File: AbstractDraweeControllerBuilder.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
/** Creates a data source supplier for the given image request. */
protected Supplier<DataSource<IMAGE>> getDataSourceSupplierForRequest(
    final REQUEST imageRequest,
    final boolean bitmapCacheOnly) {
  final Object callerContext = getCallerContext();
  return new Supplier<DataSource<IMAGE>>() {
    @Override
    public DataSource<IMAGE> get() {
      return getDataSourceForRequest(imageRequest, callerContext, bitmapCacheOnly);
    }
    @Override
    public String toString() {
      return Objects.toStringHelper(this)
          .add("request", imageRequest.toString())
          .toString();
    }
  };
}
 
Example #12
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testPrefetchToEncodedCacheDefaultPriority() {
  Producer<Void> prefetchProducerSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(mImageRequest))
      .thenReturn(prefetchProducerSequence);
  DataSource<Void> dataSource =
      mImagePipeline.prefetchToEncodedCache(mImageRequest, mCallerContext);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(prefetchProducerSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.MEDIUM);
}
 
Example #13
Source File: ImagePipeline.java    From fresco with MIT License 6 votes vote down vote up
private DataSource<Void> prefetchToBitmapCache(
    ImageRequest imageRequest, Object callerContext, Priority priority) {
  if (!mIsPrefetchEnabledSupplier.get()) {
    return DataSources.immediateFailedDataSource(PREFETCH_EXCEPTION);
  }
  try {
    final Boolean shouldDecodePrefetches = imageRequest.shouldDecodePrefetches();
    final boolean skipBitmapCache =
        shouldDecodePrefetches != null
            ? !shouldDecodePrefetches // use imagerequest param if specified
            : mSuppressBitmapPrefetchingSupplier
                .get(); // otherwise fall back to pipeline's default
    Producer<Void> producerSequence =
        skipBitmapCache
            ? mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(imageRequest)
            : mProducerSequenceFactory.getDecodedImagePrefetchProducerSequence(imageRequest);
    return submitPrefetchRequest(
        producerSequence,
        imageRequest,
        ImageRequest.RequestLevel.FULL_FETCH,
        callerContext,
        priority);
  } catch (Exception exception) {
    return DataSources.immediateFailedDataSource(exception);
  }
}
 
Example #14
Source File: ImagePipeline.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Submits a request for prefetching to the disk cache.
 *
 * <p>Beware that if your network fetcher doesn't support priorities prefetch requests may slow
 * down images which are immediately required on screen.
 *
 * @param imageRequest the request to submit
 * @param priority custom priority for the fetch
 * @return a DataSource that can safely be ignored.
 */
public DataSource<Void> prefetchToDiskCache(
    ImageRequest imageRequest, Object callerContext, Priority priority) {
  if (!mIsPrefetchEnabledSupplier.get()) {
    return DataSources.immediateFailedDataSource(PREFETCH_EXCEPTION);
  }
  try {
    Producer<Void> producerSequence =
        mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(imageRequest);
    return submitPrefetchRequest(
        producerSequence,
        imageRequest,
        ImageRequest.RequestLevel.FULL_FETCH,
        callerContext,
        priority);
  } catch (Exception exception) {
    return DataSources.immediateFailedDataSource(exception);
  }
}
 
Example #15
Source File: FrescoImageloadHelper.java    From nono-android with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #16
Source File: PipelineDraweeController.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Initializes this controller with the new data source supplier, id and caller context. This
 * allows for reusing of the existing controller instead of instantiating a new one. This method
 * should be called when the controller is in detached state.
 *
 * @param dataSourceSupplier data source supplier
 * @param id unique id for this controller
 * @param callerContext tag and context for this controller
 */
public void initialize(
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    CacheKey cacheKey,
    Object callerContext,
    @Nullable ImmutableList<DrawableFactory> customDrawableFactories,
    @Nullable ImageOriginListener imageOriginListener) {
  if (FrescoSystrace.isTracing()) {
    FrescoSystrace.beginSection("PipelineDraweeController#initialize");
  }
  super.initialize(id, callerContext);
  init(dataSourceSupplier);
  mCacheKey = cacheKey;
  setCustomDrawableFactories(customDrawableFactories);
  clearImageOriginListeners();
  maybeUpdateDebugOverlay(null);
  addImageOriginListener(imageOriginListener);
  if (FrescoSystrace.isTracing()) {
    FrescoSystrace.endSection();
  }
}
 
Example #17
Source File: VolleyDraweeController.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public VolleyDraweeController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    Executor uiThreadExecutor,
    Supplier<DataSource<Bitmap>> dataSourceSupplier,
    String id,
    Object callerContext) {
  super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mResources = resources;
  init(dataSourceSupplier);
}
 
Example #18
Source File: SingleImageSource.java    From fresco with MIT License 5 votes vote down vote up
@Override
public Supplier<DataSource<CloseableReference<CloseableImage>>> createDataSourceSupplier(
    final ImagePipeline imagePipeline,
    final ImagePipelineUtils imagePipelineUtils,
    final ImageOptions imageOptions,
    final @Nullable Object callerContext,
    final @Nullable RequestListener requestListener,
    final String uiComponentId) {
  return new Supplier<DataSource<CloseableReference<CloseableImage>>>() {
    @Override
    public DataSource<CloseableReference<CloseableImage>> get() {
      final ImageRequest imageRequest =
          maybeExtractFinalImageRequest(imagePipelineUtils, imageOptions);
      if (imageRequest != null) {
        return imagePipeline.fetchDecodedImage(
            imageRequest,
            callerContext,
            ImageRequest.RequestLevel.FULL_FETCH,
            requestListener, // TODO: Check if this is correct !!
            uiComponentId);
      } else {
        return DataSources.immediateFailedDataSource(
            new NullPointerException(
                "Could not extract image request from: " + SingleImageSource.this));
      }
    }
  };
}
 
Example #19
Source File: FrescoVitoPrefetcherImpl.java    From fresco with MIT License 5 votes vote down vote up
/**
 * Prefetch an image to the encoded memory cache. In order to cancel the prefetch, close the
 * {@link DataSource} returned by this method.
 *
 * <p>Beware that if your network fetcher doesn't support priorities prefetch requests may slow
 * down images which are immediately required on screen.
 *
 * @param uri the image URI to prefetch
 * @param imageOptions the image options used to display the image
 * @param callerContext the caller context for the given image
 * @return a DataSource that can safely be ignored.
 */
public DataSource<Void> prefetchToEncodedCache(
    final Uri uri,
    final @Nullable EncodedImageOptions imageOptions,
    final @Nullable Object callerContext) {
  mFrescoContext.verifyCallerContext(callerContext);
  ImageRequest imageRequest =
      mFrescoContext
          .getImagePipelineUtils()
          .buildEncodedImageRequest(
              uri, imageOptions != null ? imageOptions : ImageOptions.defaults());
  return mFrescoContext.getImagePipeline().prefetchToEncodedCache(imageRequest, callerContext);
}
 
Example #20
Source File: ListDataSource.java    From fresco with MIT License 5 votes vote down vote up
@Override
@Nullable
public synchronized List<CloseableReference<T>> getResult() {
  if (!hasResult()) {
    return null;
  }
  List<CloseableReference<T>> results = new ArrayList<>(mDataSources.length);
  for (DataSource<CloseableReference<T>> dataSource : mDataSources) {
    results.add(dataSource.getResult());
  }
  return results;
}
 
Example #21
Source File: PipelineDraweeController.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public PipelineDraweeController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    AnimatedDrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    Object callerContext) {
    super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mResources = resources;
  mAnimatedDrawableFactory = animatedDrawableFactory;
  init(dataSourceSupplier);
}
 
Example #22
Source File: ImagePipeline.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Submits a request for prefetching to the disk cache.
 * @param imageRequest the request to submit
 * @return a DataSource that can safely be ignored.
 */
public DataSource<Void> prefetchToDiskCache(
    ImageRequest imageRequest,
    Object callerContext) {
  if (!mIsPrefetchEnabledSupplier.get()) {
    return DataSources.immediateFailedDataSource(PREFETCH_EXCEPTION);
  }

  Producer<Void> producerSequence =
      mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(
          imageRequest);
  return submitPrefetchRequest(producerSequence, imageRequest, callerContext);
}
 
Example #23
Source File: ImagePipelineTest.java    From fresco with MIT License 5 votes vote down vote up
private void verifyPrefetchToDiskCache(
    DataSource<Void> dataSource, Producer<Void> prefetchProducerSequence, Priority priority) {
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(prefetchProducerSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(priority, producerContextArgumentCaptor.getValue().getPriority());
}
 
Example #24
Source File: PipelineDraweeControllerBuilder.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected DataSource<CloseableReference<CloseableImage>> getDataSourceForRequest(
    ImageRequest imageRequest,
    Object callerContext,
    boolean bitmapCacheOnly) {
  if (bitmapCacheOnly) {
    return mImagePipeline.fetchImageFromBitmapCache(imageRequest, callerContext);
  } else {
    return mImagePipeline.fetchDecodedImage(imageRequest, callerContext);
  }
}
 
Example #25
Source File: AbstractDraweeController.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
private void onFailureInternal(
    String id,
    DataSource<T> dataSource,
    Throwable throwable,
    boolean isFinished) {
  // ignore late callbacks (data source that failed is not the one we expected)
  if (!isExpectedDataSource(id, dataSource)) {
    logMessageAndFailure("ignore_old_datasource @ onFailure", throwable);
    dataSource.close();
    return;
  }
  mEventTracker.recordEvent(
      isFinished ? Event.ON_DATASOURCE_FAILURE : Event.ON_DATASOURCE_FAILURE_INT);
  // fail only if the data source is finished
  if (isFinished) {
    logMessageAndFailure("final_failed @ onFailure", throwable);
    mDataSource = null;
    mHasFetchFailed = true;
    if (shouldRetryOnTap()) {
      mSettableDraweeHierarchy.setRetry(throwable);
    } else {
      mSettableDraweeHierarchy.setFailure(throwable);
    }
    getControllerListener().onFailure(mId, throwable);
    // IMPORTANT: do not execute any instance-specific code after this point
  } else {
    logMessageAndFailure("intermediate_failed @ onFailure", throwable);
    getControllerListener().onIntermediateImageFailed(mId, throwable);
    // IMPORTANT: do not execute any instance-specific code after this point
  }
}
 
Example #26
Source File: ImagePipeline.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Submits a request for prefetching to the bitmap cache.
 * @param imageRequest the request to submit
 * @return a DataSource that can safely be ignored.
 */
public DataSource<Void> prefetchToBitmapCache(
    ImageRequest imageRequest,
    Object callerContext) {
  if (!mIsPrefetchEnabledSupplier.get()) {
    return DataSources.immediateFailedDataSource(PREFETCH_EXCEPTION);
  }

  Producer<Void> producerSequence =
      mProducerSequenceFactory.getDecodedImagePrefetchProducerSequence(
          imageRequest);
  return submitPrefetchRequest(producerSequence, imageRequest, callerContext);
}
 
Example #27
Source File: ImagePipeline.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Submits a request for execution and returns a DataSource representing the pending encoded
 * image(s).
 *
 * <p>The returned DataSource must be closed once the client has finished with it.
 * @param imageRequest the request to submit
 * @return a DataSource representing the pending encoded image(s)
 */
public DataSource<CloseableReference<PooledByteBuffer>> fetchEncodedImage(
    ImageRequest imageRequest,
    Object callerContext) {
  Producer<CloseableReference<PooledByteBuffer>> producerSequence =
      mProducerSequenceFactory.getEncodedImageProducerSequence(
          imageRequest);
    return submitFetchRequest(producerSequence, imageRequest, callerContext);
}
 
Example #28
Source File: VolleyDraweeControllerFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public VolleyDraweeController newController(
    Supplier<DataSource<Bitmap>> dataSourceSupplier,
    String id,
    Object callerContext) {
  return new VolleyDraweeController(
      mResources,
      mDeferredReleaser,
      mUiThreadExecutor,
      dataSourceSupplier,
      id,
      callerContext);
}
 
Example #29
Source File: ImagePipeline.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Submits a request for bitmap cache lookup.
 * @param imageRequest the request to submit
 * @return a DataSource representing the image
 */
public DataSource<CloseableReference<CloseableImage>> fetchImageFromBitmapCache(
    ImageRequest imageRequest,
    Object callerContext) {
  Producer<CloseableReference<CloseableImage>> producerSequence =
      mProducerSequenceFactory.getBitmapCacheGetOnlySequence();
  return submitFetchRequest(producerSequence, imageRequest, callerContext);
}
 
Example #30
Source File: ProducerToDataSourceAdapter.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public static <T> DataSource<T> create(
    Producer<T> producer,
    SettableProducerContext settableProducerContext,
    RequestListener listener) {
  return new ProducerToDataSourceAdapter<T>(
      producer,
      settableProducerContext,
      listener);
}