0

I am writing a small app which queries a REST API to get JSON Data about movies. Which includes

  • Movie ID
  • Movie's Poster
  • URL Movie Overview etc

My main view consists of a RecyclerView which uses a GridLayout Manager to display a grid of movie posters. On tapping, a grid view item would transition to an activity where details of the movie will be presented.

As mentioned above, the API Call would return all important details to build the experience, including the URL to download the Poster.

I will be using Okhttp and Picasso for networking and Image Download. This is my first app which interacts with the network so I need to know where should I put the Okhttp Async Networking Code to get the JSON Data and WHY?

  • In the Fragment's OnCreate?
  • In the hosting Activity's OnCreate?
  • In the RecyclerView's Adapter?

I don't want the code, I just need to know what's the right place to fetch the JSON via Okhttp and why?

Prateek Prasad
  • 827
  • 2
  • 10
  • 19
  • Pls read http://stackoverflow.com/questions/32492011/how-to-load-datajson-into-recycler-view-using-volley/32492513?s=0|4.7136#32492513. I use Volley, however, you can see the logic for your app – BNK Apr 24 '16 at 04:06

1 Answers1

0

You can fetch the JSON via Okhttp in your main fragment or activity, and parse it and store it in an ArrayList, then pass the ArrayList in adapter class, where you need to use picasso library for image download.

MrRobot9
  • 2,402
  • 4
  • 31
  • 68