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


Java DataSource.subscribe方法代码示例

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


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

示例1: loadBitmapFromUrl

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

示例2: loadResourceFromUrl

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

示例3: setSupplier

import com.facebook.datasource.DataSource; //导入方法依赖的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: LoadImageFromURLAndCallBack

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

示例5: LoadImageFromURIAndCallBack

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

示例6: create

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

示例7: save

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
public static void save(Uri uri, String action) {
    ImageRequest request = ImageRequest.fromUri(uri);
    ImagePipeline pipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<PooledByteBuffer>> dataSource =
            pipeline.fetchEncodedImage(request, null);

    ImageSubscriber dataSubscriber = new ImageSubscriber(uri, action);

    dataSource.subscribe(dataSubscriber,
            ExpressApplication.getApplication().getImagePipelineConfig()
                    .getExecutorSupplier().forLocalStorageWrite());
}
 
开发者ID:mingdroid,项目名称:tumbviewer,代码行数:13,代码来源:FrescoUtils.java

示例8: loadImage

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void loadImage(int requestId, Uri uri, final Callback callback) {
    ImageRequest request = ImageRequest.fromUri(uri);

    File localCache = getCacheFile(request);
    if (localCache.exists()) {
        callback.onCacheHit(localCache);
        callback.onSuccess(localCache);
    } else {
        callback.onStart(); // ensure `onStart` is called before `onProgress` and `onFinish`
        callback.onProgress(0); // show 0 progress immediately

        ImagePipeline pipeline = Fresco.getImagePipeline();
        DataSource<CloseableReference<PooledByteBuffer>> source
                = pipeline.fetchEncodedImage(request, true);
        source.subscribe(new ImageDownloadSubscriber(mAppContext) {
            @Override
            protected void onProgress(int progress) {
                callback.onProgress(progress);
            }

            @Override
            protected void onSuccess(final File image) {
                callback.onFinish();
                callback.onCacheMiss(image);
                callback.onSuccess(image);
            }

            @Override
            protected void onFail(final Throwable t) {
                t.printStackTrace();
                callback.onFail((Exception) t);
            }
        }, mExecutorSupplier.forBackgroundTasks());

        closeSource(requestId);
        saveSource(requestId, source);
    }
}
 
开发者ID:Piasy,项目名称:BigImageViewer,代码行数:40,代码来源:FrescoImageLoader.java

示例9: getBitmapWithFresco

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
public static void getBitmapWithFresco(Context context, String url, BaseBitmapDataSubscriber baseBitmapDataSubscriber) {
    ImageRequest imageRequest = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>>
            dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
    dataSource.subscribe(baseBitmapDataSubscriber,
            CallerThreadExecutor.getInstance());
}
 
开发者ID:luania,项目名称:witchpot,代码行数:13,代码来源:MediaUtil.java

示例10: loadImage

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void loadImage(Uri uri, final Callback callback) {
    ImageRequest request = ImageRequest.fromUri(uri);

    File localCache = getCacheFile(request);
    if (localCache.exists()) {
        callback.onCacheHit(localCache);
    } else {
        callback.onStart(); // ensure `onStart` is called before `onProgress` and `onFinish`
        callback.onProgress(0); // show 0 progress immediately

        ImagePipeline pipeline = Fresco.getImagePipeline();
        DataSource<CloseableReference<PooledByteBuffer>> source
                = pipeline.fetchEncodedImage(request, true);
        source.subscribe(new ImageDownloadSubscriber(mAppContext) {
            @Override
            protected void onProgress(int progress) {
                callback.onProgress(progress);
            }

            @Override
            protected void onSuccess(File image) {
                callback.onFinish();
                callback.onCacheMiss(image);
            }

            @Override
            protected void onFail(Throwable t) {
                // TODO: 12/11/2016 fail
                t.printStackTrace();
            }
        }, mExecutorSupplier.forBackgroundTasks());
    }
}
 
开发者ID:love-311,项目名称:BigImageViewer-master,代码行数:35,代码来源:FrescoImageLoader.java

示例11: instantiateItem

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

示例12: get

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
public void get() {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(imageUrl))
            .build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> dataSource
            = imagePipeline.fetchDecodedImage(request, WikipediaApp.getInstance());
    dataSource.subscribe(new BitmapDataSubscriber(), UiThreadImmediateExecutorService.getInstance());
}
 
开发者ID:wikimedia,项目名称:apps-android-wikipedia,代码行数:9,代码来源:ImagePipelineBitmapGetter.java

示例13: setSubscribe

import com.facebook.datasource.DataSource; //导入方法依赖的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());
}
 
开发者ID:goodev,项目名称:materialup,代码行数:7,代码来源:FrescoUtils.java

示例14: loadImageInternal

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
/**
 * Internal helper method for load Bitmap.
 *
 * @param maxSize 0 or less than 0 if want original bitmap.
 */
@Override
public void loadImageInternal(
        final Uri uri,
        final int maxSize,
        final ImageLoaderUtils.ImageLoadListener listener) {

    if (uri == null) {
        listener.onFailed(-1);
        return;
    }

    ImageRequestBuilder builder = ImageRequestBuilder
            .newBuilderWithSource(uri)
            .setAutoRotateEnabled(true);
    if (maxSize > 0) {
        builder.setResizeOptions(new ResizeOptions(maxSize, maxSize));
    }

    ImagePipeline pipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> data =
            pipeline.fetchDecodedImage(builder.build(), null);

    Executor executor = new Executor() {
        @Override
        public void execute(@NonNull Runnable command) {
            ThreadManager.getInstance().postOnUIHandler(command);
        }
    };

    data.subscribe(new BaseBitmapDataSubscriber() {
        @Override
        protected void onNewResultImpl(Bitmap bitmap) {
            if (bitmap == null) {
                listener.onFailed(ImageLoaderUtils.ERROR_LOAD_EMPTY_IMAGE);
                return;
            }

            final int width = bitmap.getWidth();
            final int height = bitmap.getHeight();
            try {
                if (maxSize <= 0 || (width <= maxSize && height <= maxSize)) {
                    listener.onSuccess(uri, Bitmap.createBitmap(bitmap));
                } else {
                    JungleSize size = ImageUtils.getMaxScaleSize(
                            bitmap.getWidth(), bitmap.getHeight(), maxSize);
                    listener.onSuccess(uri, Bitmap.createScaledBitmap(
                            bitmap, size.getWidth(), size.getHeight(), true));
                }
            } catch (Throwable e) {
                e.printStackTrace();
                listener.onSuccess(uri, bitmap);
            }
        }

        @Override
        protected void onFailureImpl(
                DataSource<CloseableReference<CloseableImage>> dataSource) {
            listener.onFailed(ImageLoaderUtils.ERROR_LOAD_FAILED);
        }
    }, executor);
}
 
开发者ID:Android-Jungle,项目名称:android-jungle-framework,代码行数:67,代码来源:FrescoImageLoaderEngine.java


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