本文整理汇总了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());
}
示例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());
}
示例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;
}