title: Populating RecyclerView with parsed JSON. onPostExecute error
body: <p>I have created a HTTPManager class to make the GET request to download a simple JSON file from <a href="http://dev1.digitalnativeshq.com/userJSONtest.json" rel="nofollow">http://dev1.digitalnativeshq.com/userJSONtest.json</a></p>
  
  <p>In ASyncTask, the GET request is made and a string is returned. That string is parsed by the JSONParser class. JSONParser returns a array of User objects. In onPostExecute I want to set the adapter data to the information that is downloaded and parsed in doInBackGround. I am getting an error when I try
      adapter =  new ContactAdapter(MainActivity.this, contactList);</p>
  
  <p>MainActivity.java </p>
  
  <pre><code>public class MainActivity extends Activity {
  
  private ContactAdapter adapter;
  private static String testURL = "http://dev1.digitalnativeshq.com/userJSONtest.json";
  private RecyclerView rView;
  private List&lt;ContactInfo&gt; contactList = new ArrayList&lt;&gt;();
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      RecyclerView rView = (RecyclerView)findViewById(R.id.list);
      rView.setHasFixedSize(true);
      LinearLayoutManager layout = new LinearLayoutManager(this);
      layout.setOrientation(LinearLayoutManager.VERTICAL);
      rView.setLayoutManager(layout);
  
      fillRecyclerview task = new fillRecyclerview();
      task.execute();
  }
  
  
  
  private class fillRecyclerview extends AsyncTask&lt;Void, Void, List&lt;ContactInfo&gt;&gt;{
  
      @Override
      protected List&lt;ContactInfo&gt; doInBackground(Void... params) {
          String json = HTTPManager.getData(testURL);
          contactList = JSONParser.parseFeed(json);
          return contactList;
      }
  
      @Override
      protected void onPostExecute(List&lt;ContactInfo&gt; result){
          adapter =  new ContactAdapter(MainActivity.this, contactList);
          rView.setAdapter(adapter);
      }
  }
  </code></pre>
  
  <p>JSONParser.java</p>
  
  <pre><code>public class JSONParser {
  
  public static List&lt;ContactInfo&gt; parseFeed(String content){
      try {
          JSONArray ar = new JSONArray(content);
          List&lt;ContactInfo&gt; userList = new ArrayList&lt;&gt;();
  
          //iterate through JSON object and set fields to strings
          for (int i = 0; i &lt; ar.length(); i++) {
              JSONObject obj = ar.getJSONObject(i);
              ContactInfo user = new ContactInfo();
              user.setName(obj.getString("name"));
              user.setEmail(obj.getString("email"));
  
              userList.add(user);
          }
          return userList;
      } catch (JSONException e) {
          e.printStackTrace();
          return null;
      }
  }
  </code></pre>
  
  <p>ContactAdapter.java</p>
  
  <pre><code>public class ContactAdapter extends RecyclerView.Adapter&lt;ContactAdapter.ContactViewHolder&gt; {
  
  private List&lt;ContactInfo&gt; contactList;
  
  public ContactAdapter(List&lt;ContactInfo&gt; contactList) {
      this.contactList = contactList;
  }
  
  @Override
  public int getItemCount() {
      return contactList.size();
  }
  
  public static class ContactViewHolder extends RecyclerView.ViewHolder {
      protected TextView vName;
      protected TextView vEmail;
  
      public ContactViewHolder(View v) {
          super(v);
          vName =  (TextView) v.findViewById(R.id.name);
          vEmail = (TextView)  v.findViewById(R.id.email);
      }
  }
  @Override
  public void onBindViewHolder(ContactViewHolder contactViewHolder, int i) {
      ContactInfo ci = contactList.get(i);
      contactViewHolder.vName.setText(ci.name);
      contactViewHolder.vEmail.setText(ci.email);
  
  
  }
  //select XML layout for each card
  @Override
  public ContactViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
      View itemView = LayoutInflater.
              from(viewGroup.getContext()).
              inflate(R.layout.cardview, viewGroup, false);
  
      return new ContactViewHolder(itemView);
  }
  }
  </code></pre>
  
  <p>HTTPManager.java</p>
  
  <pre><code>public class HTTPManager {
  public static String getData(String uri){
  
      BufferedReader reader = null;
      try{
          URL url = new URL(uri);
          HttpURLConnection con = (HttpURLConnection) url.openConnection();
  
          StringBuilder sb = new StringBuilder();
          reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
          String line;
          while((line = reader.readLine()) != null){
              sb.append(line + "\n");
          }
  
          return sb.toString();
  
      } catch (Exception e){
          e.printStackTrace();
          return null;
      } finally {
          if (reader == null) {
              try {
                  reader.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  
  
  }
  }
  </code></pre>