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


Java CacheableImageView类代码示例

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


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

示例1: renderImageView

import uk.co.senab.bitmapcache.CacheableImageView; //导入依赖的package包/类
private void renderImageView(final View convertView) {
    if (convertView.getTag() instanceof Folder) {
        final Folder folder = (Folder) convertView.getTag();
        final CacheableImageView imageView = (CacheableImageView) convertView.getTag(R.id.image_view);
        ((TextView) convertView.getTag(R.id.title)).setText(folder.getName());
        ((TextView) convertView.getTag(R.id.size)).setText("(" + folder.getSize() + ")");
        String summary;
        TextView subTitle = (TextView) convertView.getTag(R.id.sub_title);
        String photoSetTitle = folder.getFlickrSetTitle();
        if (ToolString.isBlank(photoSetTitle)) {
            summary = "not monitored";
            subTitle.setTextColor(getResources().getColor(R.color.midgray));
        } else {
            summary = "⇒ Flickr (" + photoSetTitle + ")";
            subTitle.setTextColor(Color.WHITE);
        }
        subTitle.setText(summary);

        final Media media = folder.getMedia();
        imageView.setTag(media);
        if (media == null) {
            imageView.setImageDrawable(null);
        } else {
            final CacheableBitmapDrawable wrapper = Utils.getCache().getFromMemoryCache(media.getPath() + "_" + VIEW_SIZE.small);
            if (wrapper != null && !wrapper.getBitmap().isRecycled()) {
                // The cache has it, so just display it
                imageView.setImageDrawable(wrapper);
            } else {
                imageView.setImageDrawable(null);
            }

            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    if (imageView.getTag() == media) {
                        final CacheableBitmapDrawable bitmapDrawable;
                        if (wrapper != null && !wrapper.getBitmap().isRecycled()) {
                            bitmapDrawable = wrapper;
                        } else {
                            Bitmap bitmap = Utils.getBitmap(media, VIEW_SIZE.small);
                            if (bitmap != null) {
                                bitmapDrawable = Utils.getCache().put(media.getPath() + "_" + VIEW_SIZE.small, bitmap);
                            } else {
                                bitmapDrawable = null;
                            }
                        }

                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if (imageView.getTag() == media) {
                                    if (wrapper != bitmapDrawable) {
                                        imageView.setImageDrawable(bitmapDrawable);
                                    }
                                }
                            }
                        });
                    }
                }
            });
        }
    }
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:64,代码来源:AutoUploadFoldersActivity.java


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