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


Java DataSubscriber类代码示例

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


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

示例1: setUp

import com.facebook.datasource.DataSubscriber; //导入依赖的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

示例2: setUp

import com.facebook.datasource.DataSubscriber; //导入依赖的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

示例3: instantiateItem

import com.facebook.datasource.DataSubscriber; //导入依赖的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


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