问题描述
ParseImageView 是否在 Android 中缓存 ParseFile.如果它缓存了 parseFile,我如何在我的 android 设备中找到这些文件的路径.
Does ParseImageView cache ParseFile's in Android. If it caches parseFile, How can i find the path of those files in my android device.
ParseImageView imageView = (ParseImageView) findViewById(android.R.id.icon);
// The placeholder will be used before and during the fetch, to be replaced by the fetched image
// data.
imageView.setPlaceholder(getResources().getDrawable(R.drawable.placeholder));
imageView.setParseFile(file);
imageView.loadInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
Log.i("ParseImageView",
"Fetched! Data length: " + data.length + ", or exception: " + e.getMessage());
}
});
推荐答案
看起来 @suresh kumar 已经死了是的,所以这个问题用否"解决了,但是遇到这个麻烦我想在这里放一些代码来解决它.
Looks like @suresh kumar is dead right, so this question is settled with "no", but having run into this trouble I wanted to drop some code in here to get around it.
我使用 Universal Image Loader 来加载 URL 图片,它支持许多用于缓存和显示的配置选项.在您的应用程序类中设置它(在撰写本文时):
I use Universal Image Loader for URL image loading, and it supports a lot of configuration options for caching and display. Set it up in your Application class with (at time of writing):
//Create image options.
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.button_default)
.cacheInMemory(true)
.cacheOnDisc(true)
.build();
//Create a config with those options.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.defaultDisplayImageOptions(options)
.build();
ImageLoader.getInstance().init(config);
然后将其与 Parse 一起使用,您可以在其中加载和缓存图像:
And then use it with Parse where you'd like to load and cache your image:
ParseImageView itemImage = (ParseImageView) v.findViewById(R.id.iv_item);
ParseFile photoFile = item.getParseFile("picture");
if (photoFile != null) {
//Get singleton instance of ImageLoader
ImageLoader imageLoader = ImageLoader.getInstance();
//Load the image from the url into the ImageView.
imageLoader.displayImage(photoFile.getUrl(), itemImage);
}
希望有所帮助.
这篇关于ParseImageView 是否缓存 ParseFile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!