本文整理汇总了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);
}
}
}
});
}
}
});
}
}
}