本文整理汇总了Java中com.facebook.imagepipeline.core.ImagePipeline类的典型用法代码示例。如果您正苦于以下问题:Java ImagePipeline类的具体用法?Java ImagePipeline怎么用?Java ImagePipeline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImagePipeline类属于com.facebook.imagepipeline.core包,在下文中一共展示了ImagePipeline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearCache
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
/**
* 清除缓存
*/
private void clearCache() {
// 清理新闻json数据 - 不清理json数据
// NewsDALManager.shared.clearCache();
// Fresco清除图片缓存
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.clearCaches();
// 清除缓存目录 - 清除所有缓存目录文件
FileCacheUtils.clearAllCache(mContext);
final KProgressHUD hud = ProgressHUD.show(mContext, "正在清理...");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
hud.dismiss();
ProgressHUD.showInfo(mContext, "清理缓存完成");
}
}, 2000);
}
示例2: attach
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
void attach(BitmapUpdateListener listener) {
mBitmapUpdateListener = listener;
mAttachCounter++;
if (mAttachCounter != 1) {
// this is a secondary attach, ignore it, only updating Bitmap boundaries if needed.
Bitmap bitmap = getBitmap();
if (bitmap != null) {
listener.onSecondaryAttach(bitmap);
}
return;
}
listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD_START);
Assertions.assertCondition(mDataSource == null);
Assertions.assertCondition(mImageRef == null);
// Submit the request
ImagePipeline imagePipeline = ImagePipelineFactory.getInstance().getImagePipeline();
mDataSource = imagePipeline.fetchDecodedImage(mImageRequest, RCTImageView.getCallerContext());
mDataSource.subscribe(this, UiThreadImmediateExecutorService.getInstance());
}
示例3: queryCache
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
@ReactMethod
public void queryCache(final ReadableArray uris, final Promise promise) {
// perform cache interrogation in async task as disk cache checks are expensive
new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
@Override
protected void doInBackgroundGuarded(Void... params) {
WritableMap result = Arguments.createMap();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
for (int i = 0; i < uris.size(); i++) {
String uriString = uris.getString(i);
final Uri uri = Uri.parse(uriString);
if (imagePipeline.isInBitmapMemoryCache(uri)) {
result.putString(uriString, "memory");
} else if (imagePipeline.isInDiskCacheSync(uri)) {
result.putString(uriString, "disk");
}
}
promise.resolve(result);
}
}.executeOnExecutor(GuardedAsyncTask.THREAD_POOL_EXECUTOR);
}
示例4: clearCache
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
/**
* 清除缓存
*/
private void clearCache() {
// 清理新闻json数据 - 不清理json数据
// NewsDALManager.shared.clearCache();
// Fresco清除图片缓存
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.clearCaches();
// 清除缓存目录 - 清除所有缓存目录文件
FileCacheUtils.clearAllCache(mContext);
final KProgressHUD hud = ProgressHUD.show(mContext, "正在清理...");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
hud.dismiss();
ProgressHUD.showInfo(mContext, "清理缓存完成");
cacheTextView.setText(FileCacheUtils.getTotalCacheSize(mContext));
}
}, 2000);
}
示例5: setImage
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
public void setImage(String uri) {
if (uri == null) {
iconBitmapDescriptor = null;
update();
} else if (uri.startsWith("http://") || uri.startsWith("https://") ||
uri.startsWith("file://")) {
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithSource(Uri.parse(uri))
.build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(imageRequest)
.setControllerListener(mLogoControllerListener)
.setOldController(logoHolder.getController())
.build();
logoHolder.setController(controller);
} else {
iconBitmapDescriptor = getBitmapDescriptorByName(uri);
update();
}
}
示例6: loadBitmapFromUrl
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的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());
}
示例7: loadResourceFromUrl
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的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());
}
示例8: setViewListener
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
@Override
public void setViewListener() {
settingsListAdapter.setOnRecyclerViewItemClickListener(new BaseQuickAdapter.OnRecyclerViewItemClickListener() {
@Override
public void onItemClick(View view, int i) {
if (i == 1) {
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.clearMemoryCaches();
imagePipeline.clearDiskCaches();
// combines above two lines
imagePipeline.clearCaches();
processExtraData();
}
}
});
}
示例9: LoadImageFromURLAndCallBack
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的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);
}
示例10: LoadImageFromURIAndCallBack
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的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);
}
示例11: PipelineDraweeControllerBuilder
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
public PipelineDraweeControllerBuilder(
Context context,
PipelineDraweeControllerFactory pipelineDraweeControllerFactory,
ImagePipeline imagePipeline,
Set<ControllerListener> boundControllerListeners) {
super(context, boundControllerListeners);
mImagePipeline = imagePipeline;
mPipelineDraweeControllerFactory = pipelineDraweeControllerFactory;
}
示例12: clear
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
@Override
public void clear(Context ctx, FrescoImageConfig config) {
Fresco.getImagePipeline().clearMemoryCaches();
Fresco.getImagePipeline().clearCaches();
Fresco.getImagePipeline().clearDiskCaches();
String url = appendUrl(config.getUrl());
ImagePipeline imagePipeline = Fresco.getImagePipeline();
Uri uri = Uri.parse(url);
imagePipeline.evictFromMemoryCache(uri);
}
示例13: onLowMemory
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
@Override
public void onLowMemory() {
super.onLowMemory();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.clearMemoryCaches();
}
示例14: evictUri
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
/**
* 清除缓存中的一条url
*
* @param uri 需要被清除的url
*/
public void evictUri(Uri uri) {
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.evictFromMemoryCache(uri);
imagePipeline.evictFromDiskCache(uri);
imagePipeline.evictFromCache(uri);
}
示例15: clear
import com.facebook.imagepipeline.core.ImagePipeline; //导入依赖的package包/类
/**
* 清除所有缓存
*/
public void clear() {
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.clearMemoryCaches();
imagePipeline.clearDiskCaches();
imagePipeline.clearCaches();
}