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


Java CallerThreadExecutor类代码示例

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


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

示例1: IncreasingQualityDataSource

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的package包/类
public IncreasingQualityDataSource() {
  mFinishedDataSources = new AtomicInteger(0);
  final int n = mDataSourceSuppliers.size();
  mNumberOfDataSources = n;
  mIndexOfDataSourceWithResult = n;
  mDataSources = new ArrayList<>(n);
  for (int i = 0; i < n; i++) {
    DataSource<T> dataSource = mDataSourceSuppliers.get(i).get();
    mDataSources.add(dataSource);
    dataSource.subscribe(new InternalDataSubscriber(i), CallerThreadExecutor.getInstance());
    // there's no point in creating data sources of lower quality
    // if the data source of a higher quality has some result already
    if (dataSource.hasResult()) {
      break;
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:IncreasingQualityDataSourceSupplier.java

示例2: setUp

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的package包/类
public void setUp() {
  mSrc1 = mock(DataSource.class);
  mSrc2 = mock(DataSource.class);
  mSrc3 = mock(DataSource.class);
  mDataSourceSupplier1 = mock(Supplier.class);
  mDataSourceSupplier2 = mock(Supplier.class);
  mDataSourceSupplier3 = mock(Supplier.class);
  when(mDataSourceSupplier1.get()).thenReturn(mSrc1);
  when(mDataSourceSupplier2.get()).thenReturn(mSrc2);
  when(mDataSourceSupplier3.get()).thenReturn(mSrc3);
  mDataSubscriber = mock(DataSubscriber.class);
  mExecutor = CallerThreadExecutor.getInstance();
  mInOrder = inOrder(
      mSrc1,
      mSrc2,
      mSrc3,
      mDataSourceSupplier1,
      mDataSourceSupplier2,
      mDataSourceSupplier3,
      mDataSubscriber);
  mSuppliers = Arrays.asList(
      mDataSourceSupplier1,
      mDataSourceSupplier2,
      mDataSourceSupplier3);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:DataSourceTestUtils.java

示例3: setUp

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的package包/类
@Before
public void setUp() {
  mDeferredReleaser = mock(DeferredReleaser.class);
  mCallerContext = mock(Object.class);
  mDataSourceSupplier = mock(Supplier.class);
  mDraweeHierarchy = mock(SettableDraweeHierarchy.class);
  mUiThreadExecutor = CallerThreadExecutor.getInstance();
  mController = new FakeDraweeController(
      mDeferredReleaser,
      mUiThreadExecutor,
      mDataSourceSupplier,
      "id",
      mCallerContext);
  doAnswer(
      new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
          ((DeferredReleaser.Releasable) invocation.getArguments()[0]).release();
          return null;
        }
      }).when(mDeferredReleaser).scheduleDeferredRelease(any(DeferredReleaser.Releasable.class));
  when(mDataSourceSupplier.get()).thenReturn(SimpleDataSource.<FakeImage>create());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:AbstractDraweeControllerTest.java

示例4: loadBitmapFromUrl

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的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

示例5: loadResourceFromUrl

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的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

示例6: setSupplier

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的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

示例7: LoadImageFromURLAndCallBack

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的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

示例8: LoadImageFromURIAndCallBack

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的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

示例9: setSupplier

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的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

示例10: startNextDataSource

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的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

示例11: create

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的package包/类
public static <T> ListDataSource<T> create(
    DataSource<CloseableReference<T>>... dataSources) {
  Preconditions.checkNotNull(dataSources);
  Preconditions.checkState(dataSources.length > 0);
  ListDataSource<T> listDataSource = new ListDataSource<T>(dataSources);
  for (DataSource<CloseableReference<T>> dataSource : dataSources) {
    if (dataSource != null) {
      dataSource.subscribe(
          listDataSource.new InternalDataSubscriber(),
          CallerThreadExecutor.getInstance());
    }
  }
  return listDataSource;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ListDataSource.java

示例12: setUp

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mResult1 = new Object();
  mResult2 = new Object();
  mResult3 = new Object();
  mException = mock(Exception.class);

  mDataSubscriber1 = mock(DataSubscriber.class);
  mDataSubscriber2 = mock(DataSubscriber.class);

  mSettableProducerContext = mock(SettableProducerContext.class);
  when(mSettableProducerContext.getId()).thenReturn(mRequestId);
  when(mSettableProducerContext.isPrefetch()).thenReturn(true);
  mProducer = mock(Producer.class);
  mDataSource = ProducerToDataSourceAdapter.create(
      mProducer,
      mSettableProducerContext,
      mRequestListener);
  ArgumentCaptor<Consumer> captor = ArgumentCaptor.forClass(Consumer.class);
  verify(mRequestListener).onRequestStart(
      mSettableProducerContext.getImageRequest(),
      mSettableProducerContext.getCallerContext(),
      mRequestId,
      mSettableProducerContext.isPrefetch());
  verify(mProducer).produceResults(captor.capture(), any(SettableProducerContext.class));
  mInternalConsumer = captor.getValue();

  mDataSource.subscribe(mDataSubscriber1, CallerThreadExecutor.getInstance());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:ProducerToDataSourceAdapterTest.java

示例13: testSubscribe

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的package包/类
private void testSubscribe(int expected) {
  mDataSource.subscribe(mDataSubscriber2, CallerThreadExecutor.getInstance());
  switch (expected) {
    case NO_INTERACTIONS:
      break;
    case ON_NEW_RESULT:
      verify(mDataSubscriber2).onNewResult(mDataSource);
      break;
    case ON_FAILURE:
      verify(mDataSubscriber2).onFailure(mDataSource);
      break;
  }
  verifyNoMoreInteractionsAndReset();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ProducerToDataSourceAdapterTest.java

示例14: setUp

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mResourceReleaser = mock(ResourceReleaser.class);
  mResultRef1 = CloseableReference.of(new Object(), mResourceReleaser);
  mResultRef2 = CloseableReference.of(new Object(), mResourceReleaser);
  mResultRef3 = CloseableReference.of(new Object(), mResourceReleaser);
  mException = mock(Exception.class);

  mDataSubscriber1 = mock(DataSubscriber.class);
  mDataSubscriber2 = mock(DataSubscriber.class);

  mSettableProducerContext = mock(SettableProducerContext.class);
  when(mSettableProducerContext.getId()).thenReturn(mRequestId);
  when(mSettableProducerContext.isPrefetch()).thenReturn(false);
  mProducer = mock(Producer.class);
  mDataSource = CloseableProducerToDataSourceAdapter.create(
      mProducer,
      mSettableProducerContext,
      mRequestListener);
  ArgumentCaptor<Consumer> captor = ArgumentCaptor.forClass(Consumer.class);
  verify(mRequestListener).onRequestStart(
      mSettableProducerContext.getImageRequest(),
      mSettableProducerContext.getCallerContext(),
      mRequestId,
      mSettableProducerContext.isPrefetch());
  verify(mProducer).produceResults(captor.capture(), any(SettableProducerContext.class));
  mInternalConsumer = captor.getValue();

  mDataSource.subscribe(mDataSubscriber1, CallerThreadExecutor.getInstance());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:CloseableProducerToDataSourceAdapterTest.java

示例15: setUp

import com.facebook.common.executors.CallerThreadExecutor; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mSettableDataSource1 = SettableDataSource.create();
  mSettableDataSource2 = SettableDataSource.create();
  mListDataSource = ListDataSource.create(mSettableDataSource1, mSettableDataSource2);
  mRef1 = CloseableReference.of(1, mResourceReleaser);
  mRef2 = CloseableReference.of(2, mResourceReleaser);
  mRuntimeException = new RuntimeException();
  mListDataSource.subscribe(mDataSubscriber, CallerThreadExecutor.getInstance());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:ListDataSourceTest.java


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