ParseImageView缓存ParseFile

sar*_*nan 13 android caching parse-platform

ParseImageView是否在Android中缓存ParseFile.如果它缓存parseFile,我如何在我的Android设备中找到这些文件的路径.

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());
   }
 });
Run Code Online (Sandbox Code Playgroud)

Lor*_*ley 15

看起来像@suresh kumar是死的,所以这个问题用"不"来解决,但是遇到这个麻烦我想在这里删掉一些代码来解决它.

我使用Universal Image Loader进行URL图像加载,它支持许多用于缓存和显示的配置选项.使用(在撰写本文时)在Application类中进行设置:

    //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);
Run Code Online (Sandbox Code Playgroud)

然后将它与Parse一起使用,您可以在其中加载和缓存图像:

        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);
        }
Run Code Online (Sandbox Code Playgroud)

希望有所帮助.


小智 2

ParseImageView不缓存ParseFile,它仅用于显示Parse.com中存储的图像文件。看到这个

这个