当前位置: 首页>>代码示例>>Java>>正文


Java DataSource类代码示例

本文整理汇总了Java中com.facebook.datasource.DataSource的典型用法代码示例。如果您正苦于以下问题:Java DataSource类的具体用法?Java DataSource怎么用?Java DataSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataSource类属于com.facebook.datasource包,在下文中一共展示了DataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newController

import com.facebook.datasource.DataSource; //导入依赖的package包/类
public PipelineDraweeController newController(
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    CacheKey cacheKey,
    Object callerContext,
    @Nullable ImmutableList<DrawableFactory> customDrawableFactories) {
  Preconditions.checkState(mResources != null, "init() not called");
  // Field values passed as arguments so that any subclass of PipelineDraweeControllerFactory
  // can simply override internalCreateController() and return a custom Drawee controller
  PipelineDraweeController controller = internalCreateController(
      mResources,
      mDeferredReleaser,
      mAnimatedDrawableFactory,
      mUiThreadExecutor,
      mMemoryCache,
      mDrawableFactories,
      customDrawableFactories,
      dataSourceSupplier,
      id,
      cacheKey,
      callerContext);
  if (mDebugOverlayEnabledSupplier != null) {
    controller.setDrawDebugOverlay(mDebugOverlayEnabledSupplier.get());
  }
  return controller;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PipelineDraweeControllerFactory.java

示例2: internalCreateController

import com.facebook.datasource.DataSource; //导入依赖的package包/类
protected PipelineDraweeController internalCreateController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    DrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    MemoryCache<CacheKey, CloseableImage> memoryCache,
    @Nullable ImmutableList<DrawableFactory> globalDrawableFactories,
    @Nullable ImmutableList<DrawableFactory> customDrawableFactories,
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    CacheKey cacheKey,
    Object callerContext) {
  PipelineDraweeController controller = new PipelineDraweeController(
      resources,
      deferredReleaser,
      animatedDrawableFactory,
      uiThreadExecutor,
      memoryCache,
      dataSourceSupplier,
      id,
      cacheKey,
      callerContext,
      globalDrawableFactories);
  controller.setCustomDrawableFactories(customDrawableFactories);
  return controller;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PipelineDraweeControllerFactory.java

示例3: PipelineDraweeController

import com.facebook.datasource.DataSource; //导入依赖的package包/类
public PipelineDraweeController(
        Resources resources,
        DeferredReleaser deferredReleaser,
        DrawableFactory animatedDrawableFactory,
        Executor uiThreadExecutor,
        MemoryCache<CacheKey, CloseableImage> memoryCache,
        Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
        String id,
        CacheKey cacheKey,
        Object callerContext) {
  this(
      resources,
      deferredReleaser,
      animatedDrawableFactory,
      uiThreadExecutor,
      memoryCache,
      dataSourceSupplier,
      id,
      cacheKey,
      callerContext,
      null);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PipelineDraweeController.java

示例4: onNewResultImpl

import com.facebook.datasource.DataSource; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BaseBitmapDataSubscriber.java

示例5: getDataSourceSupplier

import com.facebook.datasource.DataSource; //导入依赖的package包/类
/**
 * 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
 * @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) {
  return new Supplier<DataSource<CloseableReference<CloseableImage>>>() {
    @Override
    public DataSource<CloseableReference<CloseableImage>> get() {
      return fetchDecodedImage(imageRequest, callerContext, requestLevel);
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this)
          .add("uri", imageRequest.getSourceUri())
          .toString();
    }
  };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:ImagePipeline.java

示例6: getEncodedImageDataSourceSupplier

import com.facebook.datasource.DataSource; //导入依赖的package包/类
/**
 * 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).
 * @return a DataSource representing pending results and completion of the request
 */
public Supplier<DataSource<CloseableReference<PooledByteBuffer>>>
getEncodedImageDataSourceSupplier(
    final ImageRequest imageRequest,
    final Object callerContext) {
  return new Supplier<DataSource<CloseableReference<PooledByteBuffer>>>() {
    @Override
    public DataSource<CloseableReference<PooledByteBuffer>> get() {
      return fetchEncodedImage(imageRequest, callerContext);
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this)
          .add("uri", imageRequest.getSourceUri())
          .toString();
    }
  };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ImagePipeline.java

示例7: fetchDecodedImage

import com.facebook.datasource.DataSource; //导入依赖的package包/类
/**
 * Submits a request for execution and returns a DataSource representing the pending decoded
 * image(s).
 * <p>The returned DataSource must be closed once the client has finished with it.
 *
 * @param imageRequest the request to submit
 * @param callerContext the caller context for image request
 * @param lowestPermittedRequestLevelOnSubmit the lowest request level permitted for image request
 * @return a DataSource representing the pending decoded image(s)
 */
public DataSource<CloseableReference<CloseableImage>> fetchDecodedImage(
    ImageRequest imageRequest,
    Object callerContext,
    ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit) {
  try {
    Producer<CloseableReference<CloseableImage>> producerSequence =
        mProducerSequenceFactory.getDecodedImageProducerSequence(imageRequest);
    return submitFetchRequest(
        producerSequence,
        imageRequest,
        lowestPermittedRequestLevelOnSubmit,
        callerContext);
  } catch (Exception exception) {
    return DataSources.immediateFailedDataSource(exception);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:ImagePipeline.java

示例8: prefetchToBitmapCache

import com.facebook.datasource.DataSource; //导入依赖的package包/类
/**
 * Submits a request for prefetching to the bitmap 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
 * @return a DataSource that can safely be ignored.
 */
public DataSource<Void> prefetchToBitmapCache(
    ImageRequest imageRequest,
    Object callerContext) {
  if (!mIsPrefetchEnabledSupplier.get()) {
    return DataSources.immediateFailedDataSource(PREFETCH_EXCEPTION);
  }
  try {
    Producer<Void> producerSequence = mSuppressBitmapPrefetchingSupplier.get()
        ? mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(imageRequest)
        : mProducerSequenceFactory.getDecodedImagePrefetchProducerSequence(imageRequest);
    return submitPrefetchRequest(
        producerSequence,
        imageRequest,
        ImageRequest.RequestLevel.FULL_FETCH,
        callerContext,
        Priority.MEDIUM);
  } catch (Exception exception) {
    return DataSources.immediateFailedDataSource(exception);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:ImagePipeline.java

示例9: prefetchToDiskCache

import com.facebook.datasource.DataSource; //导入依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:ImagePipeline.java

示例10: verifyState

import com.facebook.datasource.DataSource; //导入依赖的package包/类
private void verifyState(
    boolean isFinished,
    boolean hasResult,
    Object result,
    boolean hasFailed,
    Throwable failureCause) {
  DataSource<Object> dataSource = mDataSource;
  assertEquals("isFinished", isFinished, dataSource.isFinished());
  assertEquals("hasResult", hasResult, dataSource.hasResult());
  assertSame("getResult", result, dataSource.getResult());
  assertEquals("hasFailed", hasFailed, dataSource.hasFailed());
  if (failureCause == NPE) {
    assertNotNull("failure", dataSource.getFailureCause());
    assertSame("failure", NullPointerException.class, dataSource.getFailureCause().getClass());
  } else {
    assertSame("failure", failureCause, dataSource.getFailureCause());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ProducerToDataSourceAdapterTest.java

示例11: verifyState

import com.facebook.datasource.DataSource; //导入依赖的package包/类
private void verifyState(
    boolean isFinished,
    boolean hasResult,
    CloseableReference<Object> resultRef,
    boolean hasFailed,
    Throwable failureCause) {
  DataSource<CloseableReference<Object>> dataSource = mDataSource;
  assertEquals("isFinished", isFinished, dataSource.isFinished());
  assertEquals("hasResult", hasResult, dataSource.hasResult());
  CloseableReference<Object> dataSourceRef = dataSource.getResult();
  assertReferencesSame("getResult", resultRef, dataSourceRef);
  CloseableReference.closeSafely(dataSourceRef);
  assertEquals("hasFailed", hasFailed, dataSource.hasFailed());
  if (failureCause == NPE) {
    assertNotNull("failure", dataSource.getFailureCause());
    assertSame("failure", NullPointerException.class, dataSource.getFailureCause().getClass());
  } else {
    assertSame("failure", failureCause, dataSource.getFailureCause());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:CloseableProducerToDataSourceAdapterTest.java

示例12: testPrefetchToBitmapCache

import com.facebook.datasource.DataSource; //导入依赖的package包/类
@Test
public void testPrefetchToBitmapCache() {
  Producer<Void> prefetchProducerSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImagePrefetchProducerSequence(mImageRequest))
      .thenReturn(prefetchProducerSequence);
  DataSource<Void> dataSource =
      mImagePipeline.prefetchToBitmapCache(mImageRequest, mCallerContext);
  assertTrue(!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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ImagePipelineTest.java

示例13: testFetchDecodedImage

import com.facebook.datasource.DataSource; //导入依赖的package包/类
@Test
public void testFetchDecodedImage() {
  Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(decodedSequence);
  DataSource<CloseableReference<CloseableImage>> dataSource =
      mImagePipeline.fetchDecodedImage(mImageRequest, mCallerContext);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(decodedSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ImagePipelineTest.java

示例14: testFetchDecodedImageWithRequestLevel

import com.facebook.datasource.DataSource; //导入依赖的package包/类
@Test
public void testFetchDecodedImageWithRequestLevel() {
  Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(decodedSequence);
  DataSource<CloseableReference<CloseableImage>> dataSource =
      mImagePipeline.fetchDecodedImage(
          mImageRequest,
          mCallerContext,
          ImageRequest.RequestLevel.DISK_CACHE);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(decodedSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
  assertEquals(
      producerContextArgumentCaptor.getValue().getLowestPermittedRequestLevel(),
      ImageRequest.RequestLevel.DISK_CACHE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ImagePipelineTest.java

示例15: testGetBitmapCacheGetSupplier

import com.facebook.datasource.DataSource; //导入依赖的package包/类
@Test
public void testGetBitmapCacheGetSupplier() {
  Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier =
      mImagePipeline.getDataSourceSupplier(
          mImageRequest,
          mCallerContext,
          ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
  Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(bitmapCacheSequence);
  dataSourceSupplier.get();
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0",  false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(bitmapCacheSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:ImagePipelineTest.java


注:本文中的com.facebook.datasource.DataSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。