title: Issues connecting to RecyclerView and CardAdapter to database
body: <p>So my issue comes up with context in the library fragment. I get the following error.</p>
  
  <blockquote>
    <p>CardAdapter(Android.content.Context, in <code>ArrayList&lt;Card&gt;</code> in
    CardAdapter cannot be applied to Library <code>ArrayList&lt;Card&gt;</code></p>
  </blockquote>
  
  <p>I've got some of this code from a friend thankfully but we can't seem to figure out the difference/error in it.</p>
  
  <p>In <code>Library.java</code>:    </p>
  
  <pre><code>public class Library extends Fragment {
  
      // Private variables
      private RecyclerView recyclerView;
      private CardAdapter cardAdapter;
      private ArrayList&lt;Card&gt; cardArrayList;
      private ArrayList&lt;Card&gt; tempList;
  
      public Library() {}
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate view
          View view = inflater.inflate(R.layout.library, container, false);
  
          // Find recyclerView
          recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
  
          // Initialize cardArrayList
          cardArrayList = new ArrayList&lt;&gt;();
  
          // Initialize cardAdapter
          cardAdapter = new CardAdapter(this.getContext(), cardArrayList);
  
          // Initialize recyclerView
          RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this.getContext(), 1);
          recyclerView.setLayoutManager(layoutManager);
          recyclerView.setItemAnimator(new DefaultItemAnimator());
          recyclerView.setAdapter(cardAdapter);
  
          // Populate cardArrayList with test Cards
          testCards();
  
          // Return inflated view
          return view;
      }
  
      public URL createURL(String constraint) {
          try {
              StringBuilder urlString = new StringBuilder();
              //System.out.print(constraint);
              if (constraint.length() &gt; 0) {
                  urlString.append("https://camerondewey.000webhostapp.com/android_podcast_connect.php");
                  urlString.append(constraint);
                  System.out.print(urlString.toString());
              }
              String muhURL = urlString.toString();
              //System.out.print(muhURL);
              URL myURL = new URL(muhURL);
              System.out.print(myURL);
              return myURL;
              //return new URL(muhURL);
          } catch (Exception e) {
              System.out.print("Failed to return url");
          }
          return null;
      }
  
      public class GetCardTask extends AsyncTask&lt;URL, Void, JSONArray&gt; {
  
          @Override
          protected JSONArray doInBackground(URL... params) {
              //System.out.print("Params: " + params[0]);
              HttpURLConnection connection = null;
              StringBuilder result = new StringBuilder();
              try {
                  connection = (HttpURLConnection) params[0].openConnection();
                  //System.out.println(connection.getResponseCode());
                  if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                      BufferedReader reader = new BufferedReader(
                              new InputStreamReader(connection.getInputStream()));
                      String line;
                      while ((line = reader.readLine()) != null) {
                          result.append(line);
                      }
                      try {
                          //System.out.print("SUCCESS");
                          return new JSONArray(result.toString());
                      } catch (JSONException je) {
                          //System.out.print("FAILURE2");
                          JSONArray jArray = new JSONArray();
                          jArray.put(new JSONObject(result.toString()));
                          return jArray;
                      }
                  } else {
                      throw new Exception();
                  }
              } catch (Exception e) {
                  System.out.print("FAILURE1");
                  e.printStackTrace();
              } finally {
                  connection.disconnect();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(JSONArray article) {
              if (article != null) {
                  convertJSONtoArrayList(article);
                  Library.this.updateDisplay();
              } else {
                  System.out.print("failure to execute json conversion");
              }
          }
      }
  
      private void convertJSONtoArrayList(JSONArray articles) {
          cardArrayList = new ArrayList&lt;Card&gt;(); // clear old player data
          tempList = new ArrayList&lt;Card&gt;();
          try {
              for (int i = 0; i &lt; articles.length(); i++) {
                  JSONObject currentArticle = articles.getJSONObject(i);
                  cardArrayList.add(new Card(
                          currentArticle.has("name") ? currentArticle.getString("name") : "No Headline",
                          currentArticle.has("description") ? currentArticle.getString("description") : "No Name"
                          ));
                  tempList.add(new Card(
                          currentArticle.has("name") ? currentArticle.getString("name") : "No Headline",
                          currentArticle.has("description") ? currentArticle.getString("description") : "No Name"
                  ));
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  
      private void updateDisplay() {
          if (cardArrayList == null) {
              System.out.print("Display failed to update");
          }
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; data = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
          for (Card item : cardArrayList) {
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
              map.put("name", item.getCardName());
              map.put("description", item.getDescription());
              data.add(map);
          }
  
          int resource = R.layout.card;
          String[] from = {"name", "description"};
          int[] to = {R.id.card_name, R.id.podcast_desc};
  //The error happens here.
          CardAdapter cardAdapter = new CardAdapter(this, cardArrayList);
          recyclerView.setAdapter(cardAdapter);
  
          cardAdapter.notifyDataSetChanged();
      }
  </code></pre>
  
  <p>In <code>CardAdapter.java</code></p>
  
  <pre><code>public class CardAdapter extends RecyclerView.Adapter&lt;CardAdapter.CardViewHolder&gt; implements Filterable {
  
      // Private variables
      private Context cardContext;
      ArrayList&lt;Card&gt; cardList, filteredList;
  
      public class CardViewHolder extends RecyclerView.ViewHolder{
          public View view;
          public TextView cardName;
          public Card currentItem;
  
          public CardViewHolder(View v) {
              // Invoke super on view
              super(v);
              view = v;
              this.cardName = (TextView) v.findViewById(R.id.card_name);
              v.setOnClickListener(new View.OnClickListener(){
                  @Override
                  public void onClick(View v){
                      Intent i = new Intent(v.getContext(),PodcastPage.class);
                      //item clicked
                      v.getContext().startActivity(i);
                  }
              });
              // Find cardText
              cardName = (TextView) view.findViewById(R.id.card_name);
          }
      }
  
      public CardAdapter(Context c, ArrayList&lt;Card&gt; l) {
          this.cardContext = c;
          this.cardList = l;
          this.filteredList = l;
      }
  
      @Override
      public CardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card, null);
          return new CardViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(final CardViewHolder holder, int position) {
          Card card = cardList.get(position);
          holder.currentItem = cardList.get(position);
          holder.cardName.setText(card.getCardName());
      }
  
      @Override
      public int getItemCount() {
          return filteredList.size();
      }
  
      @Override
      public Filter getFilter() {
          return new Filter() {
              @Override
              protected FilterResults performFiltering(CharSequence query) {
                  FilterResults results = new FilterResults();
                  if (query != null &amp;&amp; query.length() &gt; 0) {
                      query = query.toString().toUpperCase();
                      ArrayList&lt;Card&gt; searchResults = new ArrayList&lt;Card&gt;();
                      for (int i = 0; i &lt; filteredList.size(); i++) {
                          if (filteredList.get(i).getCardName().toUpperCase().contains(query)) {
                              searchResults.add(filteredList.get(i));
                          }
                          else if (filteredList.get(i).getDescription().toUpperCase().contains(query)) {
                              searchResults.add(filteredList.get(i));
                          }
                      }
                      results.count = searchResults.size();
                      results.values = searchResults;
                  }
                  else {
                      results.count = filteredList.size();
                      results.values = filteredList;
                  }
                  return results;
              }
  
              @Override
              protected void publishResults(CharSequence query, FilterResults results) {
                  filteredList = (ArrayList&lt;Card&gt;) results.values;
                  notifyDataSetChanged();
                  System.out.println(filteredList);
              }
          };
      }
  }
  </code></pre>