13

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());
   }
 });
saravanan
  • 5,339
  • 7
  • 45
  • 52

2 Answers2

15

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.

Community
  • 1
  • 1
LordParsley
  • 3,808
  • 2
  • 30
  • 41
  • An incredible tip, thanks .. Just FTR the iOS equivalent is DLImageLoader (eg, http://stackoverflow.com/a/19115912/294884 ) ... that may help any "Mac to Android" devs googling in the future. Thanks again so much. Bounty en route! – Fattie May 21 '14 at 06:34
  • 1
    Glad to help! (Interesting how much competition there is amongst iOS images loaders too. I've used SDWebImage out of habit.) – LordParsley May 23 '14 at 12:56
  • **footnote** cacheOnDisc would seem to be now cacheOnDisk ("k"). – Fattie May 30 '14 at 14:19
  • **footnote** this incredibly helpful answer will with android studio: http://stackoverflow.com/a/17521288/294884 – Fattie May 30 '14 at 14:21
  • However! I've since experimented with Picasso. I do think it's even better. With a long ListView (about 100 full-screen images) I was getting a lot of stutter with UIL which I could not resolve. I changed to Picasso -- and it's done. So, Picasso worked for me! – Fattie Jun 03 '14 at 22:26
  • ParseFile is limited in this respect. your solution is brilliant, thanks. – brux Sep 09 '14 at 06:04
2

ParseImageView doesn't cache ParseFile, It is only used to display the image file stored in Parse.com. See this

and this

suresh kumar
  • 193
  • 1
  • 10