2013-11-23 15 views
13

Bộ đệm ParseImageView của ParseFile trong Android chưa. Nếu nó lưu trữ parseFile, Làm thế nào tôi có thể tìm thấy đường dẫn của những tập tin trong thiết bị Android của tôi.Bộ đệm ParseImageView ParseFile

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

Picasso là cách duy nhất để đến đây. – Fattie

Trả lời

2

ParseImageView không cache ParseFile, Nó chỉ được sử dụng để hiển thị tệp hình ảnh được lưu trữ trong Parse.com. See this

this

+0

Không cập nhật từ Parse cho những người trong năm qua. Thật buồn. – LordParsley

14

Hình như @suresh kumar là chết ngay, vì vậy câu hỏi này được giải quyết với "không", nhưng đã chạy vào rắc rối này, tôi muốn thả một số mã tại đây để có được xung quanh nó.

Tôi sử dụng Universal Image Loader để tải hình ảnh URL và hỗ trợ nhiều tùy chọn cấu hình để lưu vào bộ nhớ cache và hiển thị. Thiết lập nó trong lớp ứng dụng của bạn với (tại thời điểm viết bài):

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

Và sau đó sử dụng nó với Parse nơi bạn muốn tải và bộ nhớ cache hình ảnh của bạn:

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

Hy vọng rằng sẽ giúp .

+0

Một mẹo đáng kinh ngạc, cảm ơn .. Chỉ FTR tương đương iOS là DLImageLoader (ví dụ, http://stackoverflow.com/a/19115912/294884) ... có thể giúp bất kỳ "Mac cho Android" devs googling trong tương lai. Cảm ơn một lần nữa rất nhiều. Bounty trên đường! – Fattie

+1

Rất vui được giúp đỡ! (Thú vị là có bao nhiêu sự cạnh tranh trong số các bộ tải hình ảnh của iOS. Tôi đã sử dụng SDWebImage trong thói quen.) – LordParsley

+0

** footnote ** cacheOnDisc dường như bây giờ là cacheOnDisk ("k"). – Fattie