title: How to connect volley to recyclerview?
body: <p>I am trying to take data from web and by the help of volley and display it in Recylerview.</p>
  
  <p>I can easily display data in toast but in case of recylerview I am having problem. I have follow Slidenerd from youtube:</p>
  
  <p><a href="https://www.youtube.com/playlist?list=PLonJJ3BVjZW6CtAMbJz1XD8ELUs1KXaTD" rel="nofollow">https://www.youtube.com/playlist?list=PLonJJ3BVjZW6CtAMbJz1XD8ELUs1KXaTD</a></p>
  
  <p>but it not displaying in Recyclerview, any ideas?</p>
  
  <p>FragmentCollege.java class:</p>
  
  <pre><code>public class FragmentCollege extends Fragment {
  
  public static final String URL_EDUSANJAL_COLLEGE = "http://edusanjal.com/api/edusanjal/college/?format=json";
  
  private VolleySingleton volleySingleton;
  private ImageLoader imageLoader;
  private RequestQueue requestQueue;
  private ArrayList&lt;College&gt; listCollege = new ArrayList&lt;&gt;();
  private RecyclerView listCollegeHits;
  private AdapterCollege mAdapterCollege;
  
  public FragmentCollege() {
      // Required empty public constructor
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      volleySingleton = VolleySingleton.getInstance();
      requestQueue = volleySingleton.getRequestQueue();
  
  
  }
  
  private void sendJsonRequest() {
  
      JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET,
              URL_EDUSANJAL_COLLEGE,
              (String) null,
              new Response.Listener&lt;JSONObject&gt;() {
                  @Override
                  public void onResponse(JSONObject response) {
                      listCollege = parseJSONResponse(response);
                      mAdapterCollege.setCollegeList(listCollege);
                  }
              }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
  
          }
      });
      requestQueue.add(request);
  }
  
  private ArrayList&lt;College&gt; parseJSONResponse(JSONObject response) {
      ArrayList&lt;College&gt; listCollege = new ArrayList&lt;&gt;();
      if (response == null || response.length() == 0) {
  
          try {
          StringBuilder data = new StringBuilder();
              JSONArray arrayCollege = response.getJSONArray(KEY_OBJECTS);
              for (int i = 0; i &lt; arrayCollege.length(); i++) {
                  JSONObject currentCollege = arrayCollege.getJSONObject(i);
  
                  Long id = currentCollege.getLong(KEY_ID);
                  String title = currentCollege.getString(KEY_TITLE);
                  String city = currentCollege.getString(KEY_CITY);
                  String phone = currentCollege.getString(KEY_PHONE);
              data.append(id + "\n" + title + "\n" + city + "\t" + phone + "\n" + "\n");
  
  
                  College college = new College();
                  college.setId(id);
                  college.setTitle(title);
                  college.setCity(city);
                  college.setPhone(phone);
  
                  listCollege.add(college);
              }
  
  
  
          } catch (JSONException e) {
  
  
          }
          L.T(getActivity(), listCollege.toString());
      }
  
      return listCollege;
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_college, container, false);
      listCollegeHits = (RecyclerView) view.findViewById(R.id.listCollegeHits);
      listCollegeHits.setLayoutManager(new LinearLayoutManager(getActivity()));
      mAdapterCollege = new AdapterCollege(getActivity());
      listCollegeHits.setAdapter(mAdapterCollege);
  
      sendJsonRequest();
      // Inflate the layout for this fragment
      return view;
  }
  }
  </code></pre>
  
  <p>fragemnt_college.xml:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
           xmlns:tools="http://schemas.android.com/tools"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           tools:context="com.edusanjal.edusanjal.activity.CollegeFragment"&gt;
  
  &lt;!-- TODO: Update blank fragment layout --&gt;
  &lt;android.support.v7.widget.RecyclerView
      android:id="@+id/listCollegeHits"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  &lt;TextView
      android:id="@+id/textVolleyError"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:padding="@dimen/size_word"
      android:text="#FF4444"
      android:visibility="gone"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>custom_college_layout.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_marginBottom="@dimen/size_byte"
              android:layout_marginLeft="@dimen/size_word"
              android:layout_marginRight="@dimen/size_word"
              android:layout_marginTop="@dimen/size_byte"&gt;
  
  &lt;ImageView
      android:id="@+id/collegeLogo"
      android:layout_width="@dimen/college_thumbnail_width"
      android:layout_height="@dimen/college_thumbnail_height"
      android:layout_centerVertical="true"
  
      android:src="@mipmap/ic_launcher"/&gt;
  
  &lt;TextView
      android:id="@+id/collegeTitle"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentRight="true"
      android:layout_alignTop="@+id/collegeLogo"
      android:layout_marginLeft="56dp"
      android:alpha="0.87"
      android:gravity="right"
      android:padding="@dimen/size_half_byte"
      android:text="Aadikabi Bhanubhakta Higher Secondary School"
      android:textSize="@dimen/size_text_primary"/&gt;
  
  &lt;TextView
      android:id="@+id/collegePhone"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentRight="true"
      android:layout_below="@+id/collegeTitle"
      android:layout_marginLeft="56dp"
      android:alpha="0.87"
      android:gravity="right"
      android:padding="@dimen/size_half_byte"
      android:text="Phone"
      android:textSize="@dimen/size_text_primary"/&gt;
  
  &lt;TextView
      android:id="@+id/collegeCity"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentRight="true"
      android:layout_below="@+id/collegePhone"
      android:layout_marginLeft="56dp"
      android:alpha="0.87"
      android:gravity="right"
      android:padding="@dimen/size_half_byte"
      android:text="city"
      android:textSize="@dimen/size_text_primary"/&gt;
  
  &lt;TextView
      android:id="@+id/collegeCreatedOn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_below="@id/collegeCity"
      android:alpha="0.87"
      android:padding="@dimen/size_half_byte"
      android:text="31-31-31"
      android:textSize="@dimen/size_text_secondary"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>AdapterCollege.java:</p>
  
  <pre><code>public class AdapterCollege extends RecyclerView.Adapter&lt;AdapterCollege.ViewHolderCollege&gt; {
  private ArrayList&lt;College&gt; listCollege = new ArrayList&lt;&gt;();
  private LayoutInflater mLayoutInflater;
  private VolleySingleton volleySingleton;
  private ImageLoader imageLoader;
  private DateFormat dateFormatter=new SimpleDateFormat("yyyy-MM-dd");
  
  public AdapterCollege(Context context) {
      mLayoutInflater = mLayoutInflater.from(context);
      volleySingleton = VolleySingleton.getInstance();
      imageLoader = volleySingleton.getImageLoader();
  
  }
  
  public void setCollegeList(ArrayList&lt;College&gt; listCollege) {
      this.listCollege = listCollege;
      notifyItemRangeChanged(0, listCollege.size());
  }
  
  @Override
  public ViewHolderCollege onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = mLayoutInflater.inflate(R.layout.custom_college_layout, parent, false);
      ViewHolderCollege viewHolder = new ViewHolderCollege(view);
      return viewHolder;
  }
  
  @Override
  public void onBindViewHolder(ViewHolderCollege holder, int position) {
      College currentCollege = listCollege.get(position);
      holder.collegeTitle.setText(currentCollege.getTitle());
      Date collegeCreatedOn=currentCollege.getCreatedOn();
      if(collegeCreatedOn!=null){
          String formattedDate=dateFormatter.format(collegeCreatedOn);
          holder.collegeCreatedOn.setText(formattedDate);
      }
      else{
          holder.collegeCreatedOn.setText(Constants.NA);
      }
  
      holder.collegeCity.setText(currentCollege.getCity());
      holder.collegePhone.setText(currentCollege.getPhone());
  
  
      String urlLogo = currentCollege.getUrlLogo();
      loadImages(urlLogo, holder);
  
  }
  
  private void loadImages(String urlLogo, final ViewHolderCollege holder) {
      if (!urlLogo.equals(Constants.NA)) {
          imageLoader.get(urlLogo, new ImageLoader.ImageListener() {
              @Override
              public void onResponse(ImageLoader.ImageContainer response,       boolean isImmediate) {
                  holder.collegeLogo.setImageBitmap(response.getBitmap());
              }
  
              @Override
              public void onErrorResponse(VolleyError error) {
  
              }
          });
      }
  }
  
  @Override
  public int getItemCount() {
      return listCollege.size();
  }
  
  static class ViewHolderCollege extends RecyclerView.ViewHolder {
  
      ImageView collegeLogo;
      TextView collegeTitle;
      TextView collegeCreatedOn;
      TextView collegePhone;
      TextView collegeCity;
  
  
      public ViewHolderCollege(View itemView) {
          super(itemView);
          collegeLogo = (ImageView) itemView.findViewById(R.id.collegeLogo);
          collegeTitle = (TextView) itemView.findViewById(R.id.collegeTitle);
          collegeCreatedOn = (TextView) itemView.findViewById(R.id.collegeCreatedOn);
          collegePhone = (TextView) itemView.findViewById(R.id.collegePhone);
          collegeCity = (TextView) itemView.findViewById(R.id.collegeCity);
  
      }
  }
  </code></pre>
  
  <p>pojo class  => College.java:</p>
  
  <pre><code>public class College {
  
  private long id;
  private String title;
  private Date createdOn;
  private String phone;
  private String city;
  private String urlLogo;
  
  
  public College(){
  
  }
  
  public College(long id,
               String title,
               Date createdOn,
               String phone,
               String city,
               String urlLogo){
      this.id=id;
      this.title=title;
      this.createdOn=createdOn;
      this.phone=phone;
      this.city=city;
      this.urlLogo=urlLogo;
  
  }
  
  public String getTitle() {
      return title;
  }
  
  public void setTitle(String title) {
      this.title = title;
  }
  
  public long getId() {
      return id;
  }
  
  public void setId(long id) {
      this.id = id;
  }
  
  public Date getCreatedOn() {
      return createdOn;
  }
  
  public void setCreatedOn(Date createdOn) {
      this.createdOn = createdOn;
  }
  
  public String getPhone() {
      return phone;
  }
  
  public void setPhone(String phone) {
      this.phone = phone;
  }
  
  public String getCity() {
      return city;
  }
  
  public void setCity(String city) {
      this.city = city;
  }
  
  public String getUrlLogo() {
      return urlLogo;
  }
  
  public void setUrlLogo(String urlLogo) {
      this.urlLogo = urlLogo;
  }
  
  @Override
  public String toString() {
      return "ID: "+id+
              "Title "+title+
              "Date "+createdOn+
              "Phone "+phone+
              "City "+city+
              "urlLogo "+urlLogo+
              "\n";
  }
           }
  </code></pre>
  
  <p>network class => VolleySingleton.java:</p>
  
  <pre><code>public class VolleySingleton {
  private static VolleySingleton sInstance = null;
  private ImageLoader mImageLoader;
  private RequestQueue mRequestQueue;
  
  private VolleySingleton() {
      mRequestQueue = Volley.newRequestQueue(MyApplication.getAppContext());
      mImageLoader = new ImageLoader(mRequestQueue, new    ImageLoader.ImageCache() {
  
          private LruCache&lt;String, Bitmap&gt; cache = new LruCache&lt;&gt;((int) (Runtime.getRuntime().maxMemory() / 1024) / 8);
  
          @Override
          public Bitmap getBitmap(String url) {
              return cache.get(url);
          }
  
          @Override
          public void putBitmap(String url, Bitmap bitmap) {
              cache.put(url, bitmap);
          }
      });
  }
  
  
  
  public static VolleySingleton getInstance() {
      if (sInstance == null) {
          sInstance = new VolleySingleton();
      }
      return sInstance;
  }
  
  public RequestQueue getRequestQueue() {
      return mRequestQueue;
  }
  public ImageLoader getImageLoader(){
      return mImageLoader;
  }
  </code></pre>