• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MemoryCacheUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.nostra13.universalimageloader.utils.MemoryCacheUtils的典型用法代码示例。如果您正苦于以下问题:Java MemoryCacheUtils类的具体用法?Java MemoryCacheUtils怎么用?Java MemoryCacheUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MemoryCacheUtils类属于com.nostra13.universalimageloader.utils包,在下文中一共展示了MemoryCacheUtils类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getMemoryCachedAvatarBitmap

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
/**
 * 从ImageLoader内存缓存中取出头像位图
 */
private static Bitmap getMemoryCachedAvatarBitmap(UserInfoProvider.UserInfo userInfo) {
    if(userInfo == null || !isImageUriValid(userInfo.getAvatar())) {
        return null;
    }

    String key = HeadImageView.getAvatarCacheKey(userInfo.getAvatar());

    // DiskCacheUtils.findInCache(uri, ImageLoader.getInstance().getDiskCache() 查询磁盘缓存示例
    List<Bitmap> bitmaps = MemoryCacheUtils.findCachedBitmapsForImageUri(key, ImageLoader.getInstance().getMemoryCache());
    if(bitmaps.size() > 0) {
        return bitmaps.get(0);
    }

    return null;
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:19,代码来源:ImageLoaderKit.java


示例2: cleanUp

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
@SuppressLint("SetTextI18n")
private void cleanUp() {
    progressbar.setProgress(0);
    totalOriginalSize.setText("0 kb");
    totalFileSize.setText("0 kb");
    reductionPercent.setText("0 %");

    DownloadStorageSizes.clearAll();

    for (String image: imageUrls) {
        MemoryCacheUtils.removeFromCache(image, imageLoader.getMemoryCache());
        DiskCacheUtils.removeFromCache(image, imageLoader.getDiskCache());
    }

    for (ImageView imageView : imageViews) {
        if (imageView != null) {
            imageLoader.cancelDisplayTask(imageView);
            imageView.setImageResource(android.R.color.transparent);
        }
    }

    imageUrls.clear();
}
 
开发者ID:Nventify,项目名称:ImagizerAndroidExample,代码行数:24,代码来源:CompareActivity.java


示例3: initEmptyFieldsWithDefaultValues

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
private void initEmptyFieldsWithDefaultValues() {
    if (this.taskExecutor == null) {
        this.taskExecutor = DefaultConfigurationFactory.createExecutor(this.threadPoolSize, this.threadPriority, this.tasksProcessingType);
    } else {
        this.customExecutor = true;
    }
    if (this.taskExecutorForCachedImages == null) {
        this.taskExecutorForCachedImages = DefaultConfigurationFactory.createExecutor(this.threadPoolSize, this.threadPriority, this.tasksProcessingType);
    } else {
        this.customExecutorForCachedImages = true;
    }
    if (this.diskCache == null) {
        if (this.diskCacheFileNameGenerator == null) {
            this.diskCacheFileNameGenerator = DefaultConfigurationFactory.createFileNameGenerator();
        }
        this.diskCache = DefaultConfigurationFactory.createDiskCache(this.context, this.diskCacheFileNameGenerator, this.diskCacheSize, this.diskCacheFileCount);
    }
    if (this.memoryCache == null) {
        this.memoryCache = DefaultConfigurationFactory.createMemoryCache(this.memoryCacheSize);
    }
    if (this.denyCacheImageMultipleSizesInMemory) {
        this.memoryCache = new FuzzyKeyMemoryCache(this.memoryCache, MemoryCacheUtils.createFuzzyKeyComparator());
    }
    if (this.downloader == null) {
        this.downloader = DefaultConfigurationFactory.createImageDownloader(this.context);
    }
    if (this.decoder == null) {
        this.decoder = DefaultConfigurationFactory.createImageDecoder(this.writeLogs);
    }
    if (this.defaultDisplayImageOptions == null) {
        this.defaultDisplayImageOptions = DisplayImageOptions.createSimple();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:34,代码来源:ImageLoaderConfiguration.java


示例4: initEmptyFieldsWithDefaultValues

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
private void initEmptyFieldsWithDefaultValues() {
    if (this.taskExecutor == null) {
        this.taskExecutor = DefaultConfigurationFactory.createExecutor(this
                .threadPoolSize, this.threadPriority, this.tasksProcessingType);
    } else {
        this.customExecutor = true;
    }
    if (this.taskExecutorForCachedImages == null) {
        this.taskExecutorForCachedImages = DefaultConfigurationFactory.createExecutor
                (this.threadPoolSize, this.threadPriority, this.tasksProcessingType);
    } else {
        this.customExecutorForCachedImages = true;
    }
    if (this.diskCache == null) {
        if (this.diskCacheFileNameGenerator == null) {
            this.diskCacheFileNameGenerator = DefaultConfigurationFactory
                    .createFileNameGenerator();
        }
        this.diskCache = DefaultConfigurationFactory.createDiskCache(this.context, this
                .diskCacheFileNameGenerator, this.diskCacheSize, this.diskCacheFileCount);
    }
    if (this.memoryCache == null) {
        this.memoryCache = DefaultConfigurationFactory.createMemoryCache(this.context,
                this.memoryCacheSize);
    }
    if (this.denyCacheImageMultipleSizesInMemory) {
        this.memoryCache = new FuzzyKeyMemoryCache(this.memoryCache, MemoryCacheUtils
                .createFuzzyKeyComparator());
    }
    if (this.downloader == null) {
        this.downloader = DefaultConfigurationFactory.createImageDownloader(this.context);
    }
    if (this.decoder == null) {
        this.decoder = DefaultConfigurationFactory.createImageDecoder(this.writeLogs);
    }
    if (this.defaultDisplayImageOptions == null) {
        this.defaultDisplayImageOptions = DisplayImageOptions.createSimple();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:40,代码来源:ImageLoaderConfiguration.java


示例5: init

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@AfterViews
public void init() {
	if (isProtrait) {
		getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		mProtraitRelativeLayout.setVisibility(View.VISIBLE);
	} else {
		getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
		mLandscapeRelativeLayout.setVisibility(View.VISIBLE);
	}
	MemoryCacheUtils.removeFromCache("file://" + photoPath, ImageLoader.getInstance().getMemoryCache());
	DiscCacheUtils.removeFromCache("file://" + photoPath, ImageLoader.getInstance().getDiscCache());
	mImageLoader.displayImage("file://" + photoPath, imageView, ImageLoaderConfig.options);
	mRelativeLayout.setOnClickListener(this);
}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:16,代码来源:SavePhotoFragment.java


示例6: onCreate

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_thumb_view);

    final DisplayImageOptions thumbOptions = new DisplayImageOptions.Builder().cacheInMemory(true).build();
    final ImageLoader imageLoader = Global.getImageLoader(getApplicationContext());

    final ViewGroup root = (ViewGroup) findViewById(R.id.root);
    int l = root.getChildCount();
    for (int i = 0; i < l; i++) {
        final int fi = i;
        final ImageView thumb = (ImageView) ((ViewGroup) root.getChildAt(i)).getChildAt(0);
        final ImageViewAware thumbAware = new ImageViewAware(thumb);
        final String url = Global.getTestImage(i).getThumb(100, 100).url;
        imageLoader.displayImage(url, thumbAware, thumbOptions);
        thumb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ThumbViewActivity.this, PicViewActivity.class);
                intent.putExtra("image", Global.getTestImage(fi));
                ImageSize targetSize = new ImageSize(thumbAware.getWidth(), thumbAware.getHeight());
                String memoryCacheKey = MemoryCacheUtils.generateKey(url, targetSize);
                intent.putExtra("cache_key", memoryCacheKey);
                Rect rect = new Rect();
                thumb.getGlobalVisibleRect(rect);
                intent.putExtra("rect", rect);
                intent.putExtra("scaleType", thumb.getScaleType());
                startActivity(intent);
            }
        });
    }
}
 
开发者ID:boycy815,项目名称:PinchImageView,代码行数:35,代码来源:ThumbViewActivity.java


示例7: onLoadingComplete

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
    if (view == null) return;

    Object tag = view.getTag(R.id.tag_image);
    if (enableDebugLog) FLog.d("tag: %s", tag);

    if (tag != null && tag instanceof String) {
        String actualUri = tag.toString();

        File pngFile = AssistUtil.getCopiedFile(context, actualUri);

        if (pngFile == null) {
            if (enableDebugLog) FLog.w("Can't locate the file!!! %s", actualUri);

        } else if (pngFile.exists()) {
            boolean isApng = AssistUtil.isApng(pngFile);

            if (isApng) {
                if (enableDebugLog) FLog.d("Setup apng drawable");
                ApngDrawable drawable = new ApngDrawable(context, loadedImage, Uri.fromFile(pngFile));
                ((ImageView) view).setImageDrawable(drawable);
            } else {
                ((ImageView) view).setImageBitmap(loadedImage);
            }

        } else {
            if (enableDebugLog) FLog.d("Clear cache and reload");
            MemoryCacheUtils.removeFromCache(actualUri, ApngImageLoader.getInstance().getMemoryCache());
            DiskCacheUtils.removeFromCache(actualUri, ApngImageLoader.getInstance().getDiskCache());

            ApngImageLoader.getInstance().displayImage(actualUri, (ImageView) view, this);
        }
    }

    if (shouldForward()) callback.onLoadFinish(true, imageUri, view);
}
 
开发者ID:sahasbhop,项目名称:apng-view,代码行数:38,代码来源:ApngImageLoadingListener.java


示例8: displayImage

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
    checkConfiguration();
    if (imageAware == null) {
        throw new IllegalArgumentException(ERROR_WRONG_ARGUMENTS);
    }
    if (listener == null) {
        listener = this.emptyListener;
    }
    if (options == null) {
        options = this.configuration.defaultDisplayImageOptions;
    }
    if (TextUtils.isEmpty(uri)) {
        this.engine.cancelDisplayTaskFor(imageAware);
        listener.onLoadingStarted(uri, imageAware.getWrappedView());
        if (options.shouldShowImageForEmptyUri()) {
            imageAware.setImageDrawable(options.getImageForEmptyUri(this.configuration.resources));
        } else {
            imageAware.setImageDrawable(null);
        }
        listener.onLoadingComplete(uri, imageAware.getWrappedView(), null);
        return;
    }
    ImageSize targetSize = ImageSizeUtils.defineTargetSizeForView(imageAware, this.configuration.getMaxImageSize());
    String memoryCacheKey = MemoryCacheUtils.generateKey(uri, targetSize);
    this.engine.prepareDisplayTaskFor(imageAware, memoryCacheKey);
    listener.onLoadingStarted(uri, imageAware.getWrappedView());
    Bitmap bmp = (Bitmap) this.configuration.memoryCache.get(memoryCacheKey);
    if (bmp == null || bmp.isRecycled()) {
        if (options.shouldShowImageOnLoading()) {
            imageAware.setImageDrawable(options.getImageOnLoading(this.configuration.resources));
        } else if (options.isResetViewBeforeLoading()) {
            imageAware.setImageDrawable(null);
        }
        LoadAndDisplayImageTask displayTask = new LoadAndDisplayImageTask(this.engine, new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options, listener, progressListener, this.engine.getLockForUri(uri)), defineHandler(options));
        if (options.isSyncLoading()) {
            displayTask.run();
            return;
        } else {
            this.engine.submit(displayTask);
            return;
        }
    }
    L.d(LOG_LOAD_IMAGE_FROM_MEMORY_CACHE, memoryCacheKey);
    if (options.shouldPostProcess()) {
        ProcessAndDisplayImageTask displayTask2 = new ProcessAndDisplayImageTask(this.engine, bmp, new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options, listener, progressListener, this.engine.getLockForUri(uri)), defineHandler(options));
        if (options.isSyncLoading()) {
            displayTask2.run();
            return;
        } else {
            this.engine.submit(displayTask2);
            return;
        }
    }
    options.getDisplayer().display(bmp, imageAware, LoadedFrom.MEMORY_CACHE);
    listener.onLoadingComplete(uri, imageAware.getWrappedView(), bmp);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:57,代码来源:ImageLoader.java


示例9: displayImage

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options,
                         ImageSize targetSize, ImageLoadingListener listener,
                         ImageLoadingProgressListener progressListener) {
    checkConfiguration();
    if (imageAware == null) {
        throw new IllegalArgumentException(ERROR_WRONG_ARGUMENTS);
    }
    if (listener == null) {
        listener = this.defaultListener;
    }
    if (options == null) {
        options = this.configuration.defaultDisplayImageOptions;
    }
    if (TextUtils.isEmpty(uri)) {
        this.engine.cancelDisplayTaskFor(imageAware);
        listener.onLoadingStarted(uri, imageAware.getWrappedView());
        if (options.shouldShowImageForEmptyUri()) {
            imageAware.setImageDrawable(options.getImageForEmptyUri(this.configuration
                    .resources));
        } else {
            imageAware.setImageDrawable(null);
        }
        listener.onLoadingComplete(uri, imageAware.getWrappedView(), null);
        return;
    }
    if (targetSize == null) {
        targetSize = ImageSizeUtils.defineTargetSizeForView(imageAware, this.configuration
                .getMaxImageSize());
    }
    String memoryCacheKey = MemoryCacheUtils.generateKey(uri, targetSize);
    this.engine.prepareDisplayTaskFor(imageAware, memoryCacheKey);
    listener.onLoadingStarted(uri, imageAware.getWrappedView());
    Bitmap bmp = this.configuration.memoryCache.get(memoryCacheKey);
    if (bmp == null || bmp.isRecycled()) {
        if (options.shouldShowImageOnLoading()) {
            imageAware.setImageDrawable(options.getImageOnLoading(this.configuration
                    .resources));
        } else if (options.isResetViewBeforeLoading()) {
            imageAware.setImageDrawable(null);
        }
        LoadAndDisplayImageTask displayTask = new LoadAndDisplayImageTask(this.engine, new
                ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options,
                listener, progressListener, this.engine.getLockForUri(uri)), defineHandler
                (options));
        if (options.isSyncLoading()) {
            displayTask.run();
            return;
        } else {
            this.engine.submit(displayTask);
            return;
        }
    }
    L.d(LOG_LOAD_IMAGE_FROM_MEMORY_CACHE, memoryCacheKey);
    if (options.shouldPostProcess()) {
        ProcessAndDisplayImageTask displayTask2 = new ProcessAndDisplayImageTask(this.engine,
                bmp, new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey,
                options, listener, progressListener, this.engine.getLockForUri(uri)),
                defineHandler(options));
        if (options.isSyncLoading()) {
            displayTask2.run();
            return;
        } else {
            this.engine.submit(displayTask2);
            return;
        }
    }
    options.getDisplayer().display(bmp, imageAware, LoadedFrom.MEMORY_CACHE);
    listener.onLoadingComplete(uri, imageAware.getWrappedView(), bmp);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:70,代码来源:ImageLoader.java


示例10: getMemoryCache

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
public List getMemoryCache(String s)
{
    return MemoryCacheUtils.findCachedBitmapsForImageUri(s, b.getMemoryCache());
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:5,代码来源:BraceletImageLoader.java


示例11: removeImageCache

import com.nostra13.universalimageloader.utils.MemoryCacheUtils; //导入依赖的package包/类
public void removeImageCache(String s)
{
    MemoryCacheUtils.removeFromCache(s, b.getMemoryCache());
    DiskCacheUtils.removeFromCache(s, b.getDiscCache());
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:6,代码来源:BraceletImageLoader.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WhileLoopTree类代码示例发布时间:2022-05-21
下一篇:
Java UnitGraph类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap