本文整理匯總了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();
}