title: get Image from Json data and show it as cover image in RecyclerView android
body: <p>I am trying to get json data from Rest Api , deserialize it and show it to RecyclerView. </p>
  
  <p>I am using retrofit 1.9. In JSONArray(s) I can see data api in logcat. </p>
  
  <p>I can deserialize the data outside array of json, like body, title etc. </p>
  
  <p>But there are some images as Array inside json. I have created two static inner class for appimage and testImage. </p>
  
  <p>AppImage has 3 or four images. Test Image have only one image source. </p>
  
  <p>At first I want to get TeaserimageSample to set it as RecyclerView heading image. </p>
  
  <p>I am trying to get the src value from it. But could not get it how to do it. </p>
  
  <p>I would also like to know if my model class is correct based on the given JSON. I have explained in detail inside the code.</p>
  
  <p><strong>Edited Controller Class</strong></p>
  
  <pre><code>    public class NewsController {
      private static final String TAG = NewsController.class.getSimpleName();
      private UserCallbackListener mListener;
      private NewsRestApiManager mApiManager;
  
      public NewsController(UserCallbackListener listener) {
          mListener = listener;
          mApiManager = new NewsRestApiManager();
      }
  
      public void startFetching(){
  
          mApiManager.getNewsApi().getNews(new Callback&lt;String&gt;() {
  
              @Override
              public void success(String s, Response response) {
                  Log.d(TAG, "JSON :: " + s);
  
                  try {
                      JSONArray array = new JSONArray(s);
  
                      for(int i = 0; i &lt; array.length(); i++) {
                          JSONObject object = array.getJSONObject(i);
  
                          NewsModel news = new NewsModel();
                          news.setTitle( object.optString( "title") );
                          news.setBody( object.optString( "body" ) );
  
                          ArrayList&lt;NewsModel.AppImage&gt; list = new ArrayList();
                          JSONArray imageArray =object.getJSONArray("appImages");
                          for(int j=0; j&lt;imageArray.length();j++){
                              NewsModel.AppImage appImages  = new NewsModel.AppImage();
                              appImages.setSrc(imageArray.getJSONObject( j ).getString( "src" ));
                              list.add(appImages);
                          }
                          news.setAppImages( list );
  
                          JSONObject jo=object.getJSONObject( "teaserImageSmall​" );
                          NewsModel.TeaserImageSmall coverImage=new NewsModel.TeaserImageSmall();
                          coverImage.setSrc( jo.optString( "src" ));
                          news.setTeaserImageSmall(coverImage);
                          mListener.onFetchProgress(news);
  
                      }
  
                  } catch (JSONException e) {
                      mListener.onFetchFailed();
                  }
  
  
                  mListener.onFetchComplete();
              }
  
              @Override
              public void failure(RetrofitError error) {
                  Log.d(TAG, "Error :: " + error.getMessage());
                  mListener.onFetchComplete();
              }
          });
  
      }
      public interface UserCallbackListener{
          void onFetchStart();
          void onFetchProgress(NewsModel news);
          void onFetchProgress(List&lt;NewsModel&gt; userList);
          void onFetchComplete();
          void onFetchFailed();
      }
  }
  </code></pre>
  
  <p><strong>My Edited Adapter Class Where I set Picasso to set image for cover image. But still I can see nothing in recyclerview</strong></p>
  
  <pre><code>...............
      // create new views (invoked by the layout manager)
      @Override
      public NewsHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.news_row_layout,parent,false);
          return new NewsHolder(view);
      }
  
      @Override
      public void onBindViewHolder(NewsHolder holder, int position) {
  
          final NewsModel currentNews = mNews.get(position);
          Picasso.with(holder.itemView.getContext());
          Picasso.with(holder.itemView.getContext()).load(currentNews.getTeaserImageSmall().getSrc()).into( holder.newsImage );
  
          holder.newsImage.setImageResource( R.drawable.image1 );
          holder.newsHeadline.setText(currentNews.getTitle());
          holder.newsDate.setText(currentNews.getPostDate());
  
      }
  
      @Override
      public int getItemCount() {
          return mNews.size();
      }
  
  
      public class NewsHolder extends RecyclerView.ViewHolder {
  
          public CardView cardView;
          public ImageView newsImage;
          public TextView newsHeadline;
          public TextView newsDate;
  
          public NewsHolder(View itemView) {
              super(itemView);
              newsImage=(ImageView)itemView.findViewById(R.id.news_picture);
              newsHeadline=(TextView)itemView.findViewById(R.id.news_headline);
              newsDate=(TextView) itemView.findViewById(R.id.news_date);
              cardView=(CardView)itemView.findViewById(R.id.cardview_news);
          }
      }
  }
  </code></pre>