title: java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called
body: <p>I want to display vertical list in RecyclerView. Each list row contains more than one YoutubeThumbnailView. To initialize I make a separate class that take parameter as reference of YoutubethumbnailView and video key. It gives Exception.</p>
  
  <p>Here is my Recycler Adapter code</p>
  
  <pre><code>public class DashBoardRecyclerAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {
  private static final int TYPE_HEADER = 1;
  private static final int TYPE_ITEM = 2;
  ThumbnailImageView thumbnailImageView;
  
  private ArrayList&lt;VideoDetailsModel&gt; nonCateList;
  private Activity activity;
  private ArrayList&lt;ArrayList&lt;DashBoardModel&gt;&gt; mainContent;
  
  public DashBoardRecyclerAdapter(Activity activity,ArrayList&lt;VideoDetailsModel&gt; nonCateList,ArrayList&lt;ArrayList&lt;DashBoardModel&gt;&gt; mainContent) {
      this.activity = activity;
      this.nonCateList = nonCateList;
      this.mainContent = mainContent;
  }
  public class DashViewHolder extends RecyclerView.ViewHolder{
      private TextView suCategoryName;
      private TextView more;
      private TextView videoTitle;
      private TextView videoTitle2;
      private TextView videoDescription;
      private TextView videoDescription2;
      private YouTubeThumbnailView youTubeThumbnailViewOne;
      private YouTubeThumbnailView getYouTubeThumbnailViewTwo;
  
      public DashViewHolder(View itemView) {
          super(itemView);
          suCategoryName = (TextView)itemView.findViewById(R.id.dash_subcate_title);
          more = (TextView)itemView.findViewById(R.id.dash_more);
          videoTitle = (TextView)itemView.findViewById(R.id.dash_video_title);
          videoTitle2 = (TextView)itemView.findViewById(R.id.dash_video_title2);
          getYouTubeThumbnailViewTwo = (YouTubeThumbnailView)itemView.findViewById(R.id.dash_thumbnail_two);
          youTubeThumbnailViewOne = (YouTubeThumbnailView)itemView.findViewById(R.id.dash_thumbnail_one);
      }
  }
  public class HeaderViewHolder extends RecyclerView.ViewHolder{
      private TextView single_image_title,double_image_title,double_image_title2,more_item_title;
      YouTubeThumbnailView singleView,doubleView1,doubleView2,thirdView;
      public HeaderViewHolder(View itemView) {
          super(itemView);
          single_image_title = (TextView)itemView.findViewById(R.id.single_video_title);
          double_image_title = (TextView)itemView.findViewById(R.id.two_video_title);
          double_image_title2  = (TextView)itemView.findViewById(R.id.two_video_title2);
          more_item_title = (TextView)itemView.findViewById(R.id.more_video_title);
          singleView = (YouTubeThumbnailView)itemView.findViewById(R.id.single_video_dash_thumbnail);
          doubleView1 = (YouTubeThumbnailView)itemView.findViewById(R.id.two_video_thumbnail_one);
          doubleView2 = (YouTubeThumbnailView)itemView.findViewById(R.id.two_video_thumbnail_two);
          thirdView = (YouTubeThumbnailView)itemView.findViewById(R.id.third_thumbnail);
  
      }
  }
  
  @Override
  public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
  
      if(holder instanceof HeaderViewHolder){
          HeaderViewHolder headerView = (HeaderViewHolder)holder;
  
  
      }else {
          DashViewHolder holder1 = (DashViewHolder) holder;
          final ArrayList&lt;DashBoardModel&gt; content = mainContent.get(position-1);
          holder1.suCategoryName.setText(content.get(position-1).getSubCategoryName());
          holder1.videoTitle.setText(content.get(position-1).getVideoDetailsModels().get(0).getVideoTitle());
          // holder1.videoDescription.setText(dashBoardModels.get(position).getVideoDetailsModels().get(position).getDescription());
          holder1.videoTitle2.setText(content.get(position-1).getVideoDetailsModels().get(1).getVideoTitle());
          // holder1.videoDescription2.setText(dashBoardModels.get(position).getVideoDetailsModels().get(position+1).getDescription());
          thumbnailImageView = new ThumbnailImageView(holder1.youTubeThumbnailViewOne,content.get(position-1).getVideoDetailsModels().get(0).getVideoId());
          thumbnailImageView = new ThumbnailImageView(holder1.youTubeThumbnailViewOne,content.get(position-1).getVideoDetailsModels().get(1).getVideoId());
      }
  
  }
  @Override
  public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      if(viewType == TYPE_HEADER){
          if(nonCateList.size()==1){
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.single_video_layout,parent,false);
          return new HeaderViewHolder(v);
          }else if(nonCateList.size()==2){
              View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.two_video_layout,parent,false);
              return new HeaderViewHolder(v);
          }
          else if(nonCateList.size()&gt;2){
              View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.one_video_with_more,parent,false);
              return new HeaderViewHolder(v);
  
          }
      }else if(viewType == TYPE_ITEM) {
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dash_board, parent, false);
          return new DashViewHolder(v);
      }
      return null;
  }
  
  @Override
  public void onAttachedToRecyclerView(RecyclerView recyclerView) {
      super.onAttachedToRecyclerView(recyclerView);
  }
  
  @Override
  public int getItemCount()
  {
      return mainContent.size()+1;
  }
  private boolean isPositionHeader (int position) {
      return position == 0;
  }
  
      @Override
  public int getItemViewType(int position) {
          if(isPositionHeader (position)) {
              return TYPE_HEADER;
          }
          return TYPE_ITEM;
  
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my ThumbnailImageView.java class</p>
  
  <pre><code>public class ThumbnailImageView {
  private YouTubeThumbnailView youTubeThumbnailView;
  String videoKey;
  
  public ThumbnailImageView(YouTubeThumbnailView youTubeThumbnailView, String videoKey) {
      this.youTubeThumbnailView = youTubeThumbnailView;
      this.videoKey = videoKey;
      initializeThumbNail();
  }
  
  private void initializeThumbNail() {
      final YouTubeThumbnailLoader.OnThumbnailLoadedListener onThumbnailLoadedListener = new YouTubeThumbnailLoader.OnThumbnailLoadedListener() {
          @Override
          public void onThumbnailError(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader.ErrorReason errorReason) {
  
          }
  
          @Override
          public void onThumbnailLoaded(YouTubeThumbnailView youTubeThumbnailView, String s) {
              youTubeThumbnailView.setVisibility(View.VISIBLE);
              //holder.relativeLayoutOverYouTubeThumbnailView.setVisibility(View.VISIBLE);
          }
      };
  
      youTubeThumbnailView.initialize(new Constant().YOU_TUBE_API_KEY, new YouTubeThumbnailView.OnInitializedListener() {
          @Override
          public void onInitializationSuccess(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader youTubeThumbnailLoader) {
  
              youTubeThumbnailLoader.setVideo(videoKey);
              youTubeThumbnailLoader.setOnThumbnailLoadedListener(onThumbnailLoadedListener);
          }
  
          @Override
          public void onInitializationFailure(YouTubeThumbnailView youTubeThumbnailView, YouTubeInitializationResult youTubeInitializationResult) {
              //write something for failure
          }
      });
  }
  </code></pre>
  
  <p>here is my logcat message</p>
  
  <pre><code>FATAL EXCEPTION: main
    Process: com.dp.videostore, PID: 2200
    java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called.
     at com.google.android.youtube.player.internal.r.i(Unknown Source)
    at com.google.android.youtube.player.internal.o.k(Unknown Source)
    at com.google.android.youtube.player.internal.o.a(Unknown Source)
  at com.google.android.youtube.player.internal.p.&lt;init&gt;(Unknown Source)
  at com.google.android.youtube.player.internal.ac.a(Unknown Source)
  at com.google.android.youtube.player.YouTubeThumbnailView$a.a(Unknown Source)
  at com.google.android.youtube.player.internal.r.g(Unknown Source)
  at com.google.android.youtube.player.internal.r$c.a(Unknown Source)
  at com.google.android.youtube.player.internal.r$b.a(Unknown Source)
  at com.google.android.youtube.player.internal.r$a.handleMessage(Unknown Source)
  at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5417)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>