Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does ParseImageView cache ParseFile

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());
   }
 });
like image 503
saravanan Avatar asked Nov 23 '13 23:11

saravanan


1 Answers

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.

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);

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);
        }

Hope that helps.

like image 152
LordParsley Avatar answered Oct 18 '22 11:10

LordParsley