Created
May 17, 2012 09:24
-
-
Save meeech/2717699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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