iostitaniumtitanium-alloyappcelerator-alloyalloy-ui

Titanium Alloy ImageView from applicationDataDirectory


I am developing an app that needs to function in an offline mode. The app has a shop for which I have to download and store product images. In the 'shop view' I have a collection of products in a ListView. How can I bind the downloaded images to the alloy ImageView? The downloaded images are in the applicationDataDirectory. So somehow I need to be able to access applicationDataDirectory in the Alloy xml.


Solution

  • You can use the transform function of the Collection (https://docs.axway.com/bundle/Alloy_allOS_en/page/alloy_collection_and_model_objects.html). There I would check if you are in offline/online mode and change the image path (e.g. online images with URL vs. local images with Ti.Filesystem.applicationDataDirectory + "image-name.jpg")