Skip to content

jcerdenia/StarSearch

Repository files navigation

StarSearch

This is a sample master-detail application that retrieves and displays the results of search query "star" from the iTunes API. The master page displays a list of iTunes tracks with minimal info. Clicking on an item opens a new page with more information about that specific item.

Persistence
The app uses different methods of data persistence. Long-term persistence is achieved through Shared Preferences:

  • The user's choice of how items are sorted (by relevance, title, genre, or price)
  • The user's last viewed page — the app always opens with the most recently viewed page before it was last closed. If the app opens with the detail page, the last viewed item is loaded.
  • A date in the list header of when the user last visited.

In addition to the above, I have implemented a caching system using a local database. Each time data is retrieved from the API, it is saved to the database and retrieved when the device is not connected to the internet.

The app assumes that data from the API can change at any time. My implementation automatically deletes any old items in the database that are not part of a more recently retrieved list, ensuring that the database is always current. Whenever the device is offline, the most recent data is still fed to the UI.

Architecture
The architecture is based on the MVVM pattern, which cleanly separates the user interface from the data source and any data manipulation. The model layer consists of a repository (TrackFetcher) which decides whether data should be sourced from the iTunes API or the local database. This data is fed to the ViewModel layer, which handles all manipulation needed by the UI (e.g., sorting and filtering). The View layer simply reacts to any changes in the data that it observes in the ViewModel, and updates the UI accordingly.

Extras
I added options to search and reorder tracks to demonstrate keeping business logic strictly in the ViewModel and limiting the data stream that is exposed to the UI.

Download APK: https://github.com/joshuacerdenia/StarSearch/blob/master/StarSearch.apk

About

Sample app that retrieves data from iTunes Search API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages