【问题标题】:does ParseImageView cache ParseFileParseImageView 是否缓存 ParseFile
【发布时间】:2013-12-08 18:33:49
【问题描述】:

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

【问题讨论】:

  • 毕加索是去这里的唯一途径。

标签: android caching parse-platform


【解决方案1】:

看起来@suresh kumar 是完全正确的,所以这个问题用 "no" 解决,但是遇到了这个麻烦,我想在这里放一些代码来解决它。 p>

我使用Universal Image Loader 来加载URL 图片,它支持很多用于缓存和显示的配置选项。在您的应用程序类中设置它(在撰写本文时):

    //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 中使用它来加载和缓存图像:

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

希望对您有所帮助。

【讨论】:

  • 一个令人难以置信的提示,谢谢.. 只是 FTR,iOS 等价物是 DLImageLoader(例如,stackoverflow.com/a/19115912/294884)......这可能有助于将来任何“Mac 到 Android”开发人员进行谷歌搜索。再次非常感谢。赏金途中!
  • 很高兴为您提供帮助! (有趣的是,iOS 图像加载器之间也存在多少竞争。我习惯使用 SDWebImage。)
  • footnote cacheOnDisc 现在似乎是 cacheOnDisk ("k")。
  • footnote 这个非常有用的答案将对 android studio:stackoverflow.com/a/17521288/294884
  • 但是!从那以后,我开始尝试毕加索。我认为它甚至更好。使用很长的 ListView(大约 100 个全屏图像),我在 UIL 上遇到了很多我无法解决的问题。我换成了毕加索——就完成了。所以,毕加索为我工作!
【解决方案2】:

ParseImageView 不缓存 ParseFile,它仅用于显示存储在 Parse.com 中的图像文件。 See this

this

【讨论】:

    猜你喜欢
    • 2015-08-18
    • 2023-04-02
    • 1970-01-01
    • 2012-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多