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


Java Supplier.get方法代码示例

本文整理汇总了Java中com.facebook.common.internal.Supplier.get方法的典型用法代码示例。如果您正苦于以下问题:Java Supplier.get方法的具体用法?Java Supplier.get怎么用?Java Supplier.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.common.internal.Supplier的用法示例。


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

示例1: testGetBitmapCacheGetSupplier

import com.facebook.common.internal.Supplier; //导入方法依赖的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

示例2: testGetFullFetchSupplier

import com.facebook.common.internal.Supplier; //导入方法依赖的package包/类
@Test
public void testGetFullFetchSupplier() {
  Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier = mImagePipeline
      .getDataSourceSupplier(mImageRequest, mCallerContext, ImageRequest.RequestLevel.FULL_FETCH);
  Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(decodedSequence);
  DataSource<CloseableReference<CloseableImage>> dataSource = dataSourceSupplier.get();
  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,代码行数:19,代码来源:ImagePipelineTest.java

示例3: setSupplier

import com.facebook.common.internal.Supplier; //导入方法依赖的package包/类
public void setSupplier(@Nullable Supplier<DataSource<T>> supplier) {
    // early return without calling {@code supplier.get()} in case we are closed
    if (isClosed()) {
        return;
    }
    DataSource<T> oldDataSource;
    DataSource<T> newDataSource = (supplier != null) ? supplier.get() : null;
    synchronized (RetainingDataSource.this) {
        if (isClosed()) {
            oldDataSource = newDataSource;
            newDataSource = null;
        } else {
            oldDataSource = mDataSource;
            mDataSource = newDataSource;
        }
    }
    if (newDataSource != null) {
        newDataSource.subscribe(new InternalDataSubscriber(), CallerThreadExecutor.getInstance());
    }
    closeSafely(oldDataSource);
}
 
开发者ID:PureDark,项目名称:H-Viewer,代码行数:22,代码来源:RetainingDataSourceSupplier.java

示例4: setSupplier

import com.facebook.common.internal.Supplier; //导入方法依赖的package包/类
public void setSupplier(@Nullable Supplier<DataSource<T>> supplier) {
  // early return without calling {@code supplier.get()} in case we are closed
  if (isClosed()) {
    return;
  }
  DataSource<T> oldDataSource;
  DataSource<T> newDataSource = (supplier != null) ? supplier.get() : null;
  synchronized (RetainingDataSource.this) {
    if (isClosed()) {
      closeSafely(newDataSource);
      return;
    } else {
      oldDataSource = mDataSource;
      mDataSource = newDataSource;
    }
  }
  if (newDataSource != null) {
    newDataSource.subscribe(new InternalDataSubscriber(), CallerThreadExecutor.getInstance());
  }
  closeSafely(oldDataSource);
}
 
开发者ID:facebook,项目名称:fresco,代码行数:22,代码来源:RetainingDataSourceSupplier.java

示例5: startNextDataSource

import com.facebook.common.internal.Supplier; //导入方法依赖的package包/类
private boolean startNextDataSource() {
  Supplier<DataSource<T>> dataSourceSupplier = getNextSupplier();
  DataSource<T> dataSource = (dataSourceSupplier != null) ? dataSourceSupplier.get() : null;
  if (setCurrentDataSource(dataSource) && dataSource != null) {
    dataSource.subscribe(new InternalDataSubscriber(), CallerThreadExecutor.getInstance());
    return true;
  } else {
    closeSafely(dataSource);
    return false;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:FirstAvailableDataSourceSupplier.java


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