2

I'm developping an application for custom menu navigation in restaurants. I have finished my demo app for presentation purpose. My app contains a bunch of images that i added to the resource file. Now i want to create a short installation that gives people the opportunity to add their own images & menuitems to the App at runtime. Here's a screen of my app:

enter image description here

The images would be located on an AzureBlobStorage. A person will be able to give a unique key ( GUID ), the app would then connect to the azure MobileServices where a database is located, containing all the MenuItems ( Name, Category, ImageName,... ) and map it to it's own local SQL lite database. The images are .PNG files with 2 different dimensions. ( 150x150 & 1072x611 )

My question would be, what is the best approach for adding images to the application once the .APK has been created without losing speed?

Chris
  • 3,329
  • 1
  • 30
  • 44
  • Stop and think for a minute. If someone asked you that question exactly as above, how many questions would you need to ask in response before you even *understood* the requirement? – Simon Jul 03 '13 at 13:57
  • Really? All i'm asking is the best way to manage resources once the .APK is created. So imagine you know how to add drawables at runtime, create an efficient assetmanager to manage the images,.... or something else, would it really take that many questions to figure that out? I'm willing to adjust my question if you can point out where i'm not being verry clear. – Chris Jul 03 '13 at 14:10
  • 1
    You say "a short installation". What does that mean? Some UI where the user selects images? Where are those images located? Do you get them from a server? What types of images? What size? If server, internet or LAN? Where will you store them? On SDCard or private storage..etc etc.....your question is "best approach" and "without losing" speed. Very vague. I'm simply trying to help you to concisely describe what you are trying to achieve. – Simon Jul 03 '13 at 14:16
  • 1
    You're right, i'm adjusting the question. Thank you for your feedback. – Chris Jul 03 '13 at 14:20

1 Answers1

1

Nothing you can do about the speed of retrieving from Azure (short of selecting a cloud service based on performance but Azure is probably as good as any) and assuming your SQL code is efficient, the Q becomes where and how to store/retrieve and how to keep the UI responsive as you download and install the images.

I would store in private storage since it's generally much higher performance than SDCard and has fewer unknowns.

You should also scale down the bigger images to the minimum resolution that still works on your highest resolution target devices for your UI. Remember that a bitmap in memory takes x*y*4 bytes by default which is about 2.6MB each in your case.

Android: high quality image resizing / scaling

I assume that the main UI you have shown is a ListView of some sort so you should be implementing lazy loading of the images and definitely recycling them in getView() in your underlying adapter.

Lazy load of images in ListView

There is not much you can do about the speed to download from the cloud so you should be doing that on a background thread, e.g. AsyncTask, and using placeholder images in your list view until the actual image is downloaded. Use notifyDataSetChanged() on your adapter to let the list view know that there's been a change.

http://android-developers.blogspot.co.uk/2010/07/multithreading-for-performance.html

http://codehenge.net/blog/2011/06/android-development-tutorial-asynchronous-lazy-loading-and-caching-of-listview-images/

Finally, if you really want a good Android OOP solution, consider implementing a content provider.

http://developer.android.com/guide/topics/providers/content-providers.html#creating

What is the use of private Content Providers?

Community
  • 1
  • 1
Simon
  • 14,407
  • 8
  • 46
  • 61
  • Thank you verry much for this complete answer. What i forgot to mention is that the app will only have to perform this task every 2 - 3 weeks and when performing it, it doesn't have to be running the UI. A progress page will be in place for initializing/updating the app. I'll evaluate the options you posted here with my collegues. Many many thanks. – Chris Jul 03 '13 at 15:19
  • You're welcome. I hope you get the point about detail in the question since I spent about 20 minutes crafting my answer which is now redundant because this information was not in your original question nor the edit. Good luck with your app. Cheers – Simon Jul 03 '13 at 15:25
  • 1
    Yes, i do. I will take more time in the future to formulate more comprehensive and complete questions for everybody to understand. – Chris Jul 03 '13 at 15:29