Skip to content

Instantly share code, notes, and snippets.

@meeech
Created May 17, 2012 09:24
Show Gist options
  • Select an option

  • Save meeech/2717699 to your computer and use it in GitHub Desktop.

Select an option

Save meeech/2717699 to your computer and use it in GitHub Desktop.
//Fetch file, save to cache, and attach to the passed in item.
//imageUrl: http link to image
//file: Ti File
//item: a Ti.UI.ImageView
var fetchAndCache = function(imageUrl, file, item) {
var adxhr = Titanium.Network.createHTTPClient();
adxhr.onload = function() {
file.write(this.responseData);
item.image = file.nativePath;
};
adxhr.onerror = function() {
Ti.API.warn("Doh! There's been a problem. We're on it.");
};
adxhr.open('GET',imageUrl);
adxhr.send();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment