本文整理汇总了Java中com.facebook.datasource.BaseDataSubscriber类的典型用法代码示例。如果您正苦于以下问题:Java BaseDataSubscriber类的具体用法?Java BaseDataSubscriber怎么用?Java BaseDataSubscriber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseDataSubscriber类属于com.facebook.datasource包,在下文中一共展示了BaseDataSubscriber类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadResourceFromUrl
import com.facebook.datasource.BaseDataSubscriber; //导入依赖的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());
}
示例2: setSubscribe
import com.facebook.datasource.BaseDataSubscriber; //导入依赖的package包/类
private static final void setSubscribe(Context context, ImageRequest request, BaseDataSubscriber subscriber) {
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>> dataSource =
imagePipeline.fetchDecodedImage(request, context);
dataSource.subscribe(subscriber, CallerThreadExecutor.getInstance());
}
示例3: setShotUrl
import com.facebook.datasource.BaseDataSubscriber; //导入依赖的package包/类
public static final void setShotUrl(DraweeView view, String url, String thumbnail, BaseDataSubscriber subscriber, boolean full) {
if (TextUtils.isEmpty(thumbnail) && TextUtils.isEmpty(url)) {
return;
}
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
// .setResizeOptions(
// new ResizeOptions(300, 400))
.setProgressiveRenderingEnabled(true)
.build();
ImageRequest lowRequest = null;
if (!TextUtils.isEmpty(thumbnail)) {
lowRequest = ImageRequest.fromUri(thumbnail);
}
if (subscriber != null) {
if (lowRequest != null && !full) {
setSubscribe(view.getContext(), lowRequest, subscriber);
} else if (imageRequest != null) {
setSubscribe(view.getContext(), imageRequest, subscriber);
}
}
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setImageRequest(imageRequest)
.setLowResImageRequest(lowRequest)
.setOldController(view.getController())
.setAutoPlayAnimations(true)
// .setControllerListener(listener)
.build();
// ImagePipeline imagePipeline = Fresco.getImagePipeline();
// ImageRequest request = lowRequest == null ? imageRequest : lowRequest;
// DataSource<CloseableReference<CloseableImage>> dataSource =
// imagePipeline.fetchDecodedImage(request, view.getContext());
// dataSource.subscribe(new BaseBitmapDataSubscriber() {
// @Override
// protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
//
// }
//
// @Override protected void onNewResultImpl(@Nullable Bitmap bitmap) {
// Palette.from(bitmap).maximumColorCount(3).generate(new Palette.PaletteAsyncListener() {
// @Override public void onGenerated(Palette palette) {
// }
// });
// }
// }, CallerThreadExecutor.getInstance());
view.setController(draweeController);
}