I'm working on a movie app, when the user first open the app I would fetch the most current popular movie data and populate it in my ListView. The initial fetch provide a list of movies, but only provide the basic information to fill a ListView (id, name, rating, release data, poster image url). To get the remaining data (run time, tagline, description, movie website, etc), I would have to fetch from /movies/{id} endpoint for each of the movies. Also, for a list of trailer, I would need to fetch from /movies/{id}/videos. Currently I'm fetching the movie detail data when they select the movie on the list using AsyncTask and then setting the Views with the data on the initial detail loading. I'm caching the data in a Content Provider and SQLite.
My questions are:
- How do I prefetch the data after getting the initial list of movie from the first fetch? I'm currently using an AsyncTask for the initial fetch, do I just start a list of AsyncTask in the middle of the initial task?
- Should I even be using AsyncTask for this situation or are there better alternatives? It seems like a SyncAdapter is a good idea for the initial fetch, but not sure what is best to use for the additional detail/trailer.
I just started working with Android a few weeks ago, so I don't know if I should even be doing things this way or if there are better solutions. Currently everything works, but I'm not sure if I'm going down the right path. I did read this, but wanted a more specific way on how to prefetch data.