I have worked on some enhancements and performance upgrades for the previously posted movies app.
Performance Improvements
Problem
- While moving through the list on phone or emulator, the images are loaded from internet directly. Because of this if it is on WIFI, the list moves faster and if it is on 3G, the list moves slower
Solution
- Pictures must be loaded using a cache/multi-threaded synchronous model
- Initially the file is downloaded and retrieved using a synchronized process
- This image is cached using hash maps
- Requires permission type - WRITE_EXTERNAL_STORAGE
 |
| Initial Screen |
|
|
 |
While scrolling a temporary image is loaded first
and then the original image from cache |
|
Enhancements
- Check on WIFI status and issue a caution note
- The WIFI status is retrieved by invoking a system service which returns the network info
- Requires permission type - ACCESS_NETWORK_STATE
 |
When there is no WIFI,
the warning is displayed |
|
|
 |
When the WIFI is enabled.
the warning is not displayed |
|
- Show a progress dialog while the movies list is loaded
- Initiate the progress dialog
- Moved the retrieval of movies list and movie adapter retrieval in an async task
- Destroy the progress dialog after the adapter object is retrieved
- set this adapter to the ListActivity
- Filter text box to filter/search the movies based on contains
- Placed a text box and list view in the main layout
- Associated the main layout to the ListActivity
- Implemented text box functions
- Invoke adapters getFilter and provide the CharSequence entered
- Override the getFilter,getCount and getPosition methods in the adapter
- write the functionality to filter the movies which contains the CharSequence (StartsWith can be implmented if needed)
- In getCount method check if filtered list has any items and return the size of this list
 |
| Results when Filter/Search term is "Anr" |
|
|
 |
| Results when Filter/Search term is "Ntr" |
|
Lessons learnt
- While trying to cache the list of movies objects. The Bitmap does not get saved to the object and throws notserialized exception
- The position inside the getView depends on the getCount from the list