title: RecyclerView Not Showing Data Passed From List Through Bundle
body: <p>I have a recyclerview in a dialog fragment, which hosts a tab layout, containing a list of checkable items and a button each. When an item is selected, it is passed on click through the bundle to this parent dialog fragment like this:</p>
  
  <pre><code>doneBtn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              retrieveSessions();
          }
      });
  
  private void retrieveSessions() {
      NewProgramDialog dialog = new NewProgramDialog(); // parent dialog fragment is passed the list items here
  
      Bundle bundle = new Bundle();
      String s = new Gson().toJson(myItemsList);
      bundle.putString(KEY_MY_SESSIONS, s);
      bundle.putBoolean("from_selections", true);
  
      dialog.setArguments(bundle);
      dialog.show(getChildFragmentManager(), "NewProgramDialog");
      dismiss();
  }
  </code></pre>
  
  <p>The data for recyclerview is received through a bundle lie shown above and the list items are retrieved using <code>Gson</code> and converted to type String, a query is run on the database to get the session model class info. 
  These sessions are added to the adapter arraylist like below:</p>
  
  <pre><code>private void populateSessions() {
  
      addProgramSessionsRV.setHasFixedSize(true);
      addProgramSessionsRV.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
  
      // TODO: 2/05/2019 show the added sessions here
  
      Bundle bundle = getArguments();
      if (bundle != null) {
          String s = bundle.getString(KEY_MY_SESSIONS); / getting the items from bundle
          myItemsList = new Gson().fromJson(s, ArrayList.class); // parsing to List&lt;String&gt; type
          Log.d(TAG, "Items size:\t" + myItemsList.size()); //works
      }
  
      adapter = new AddProgramSessionsAdapter(getActivity(), sessionsList);
      addProgramSessionsRV.setAdapter(adapter);
      Log.d(TAG, "Items in adapter:\t" + adapter.getItemCount()); // shows total items received from bundle
  
      for (String s : myItemsList){
          Log.d(TAG, "Ids:\t" + s);
  
          Sessions session = SQLite.select()
                  .from(Sessions.class)
                  .where(Sessions_Table.prog_sessionId.eq(s))
                  .querySingle();
  
          sessionsList.add(session);
          Log.d(TAG, "Session List Size:\t" + sessionsList.size());
  
          adapter = new AddProgramSessionsAdapter(getActivity(), sessionsList);
         addProgramSessionsRV.setAdapter(adapter);
         Log.d(TAG, "Items in adapter:\t" + adapter.getItemCount());
  
      }
  
  }
  </code></pre>
  
  <p>Still the ui shows no items from this method. I have added the data manually using this snippet and it shows <code>Session 1</code> item in view but not the data from db in for loop.
  Test Case:</p>
  
  <pre><code>    Sessions sessions = new Sessions();
      sessions.setSession_name("Test one");
      sessions.setProgram_id("234");
      sessions.setProg_sessionId("91");
      sessionsList.add(sessions);
  
      adapter = new AddProgramSessionsAdapter(getActivity(), sessionsList);
      addProgramSessionsRV.setAdapter(adapter);
      Log.d(TAG, "Items in adapter:\t" + adapter.getItemCount());
  </code></pre>
  
  <p>Is there any reason why setting the adapter to a list which has items does not work in the for loop db query (works)? Please explain to me why the ui shows nothing. Thanks.</p>
  
  <p>Here's the adapter code:</p>
  
  <pre><code>public class AddProgramSessionsAdapter extends RecyclerView.Adapter&lt;AddProgramSessionViewHolder&gt; {
  
  private final Context context;
  private List&lt;Sessions&gt; itemsList;
  
  public AddProgramSessionsAdapter(Context context, List&lt;Sessions&gt; itemsList) {
      this.context = context;
      this.itemsList = itemsList;
  }
  
  @Override
  public AddProgramSessionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.add_program_sessions_items_layout, parent, false);
      return new AddProgramSessionViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(AddProgramSessionViewHolder viewholder, int position) {
      Sessions sessions = itemsList.get(position);
  
      viewholder.add_program_sessionNameTV.setText(sessions.session_name);
      Picasso.with(context)
              .load(R.drawable.app_logo_resized)
              .into(viewholder.add_program_sessionIV);
  
  }
  
  @Override
  public int getItemCount() {
      if (itemsList == null) {
          return 0;
      }
      return itemsList.size();
  }
  }
  </code></pre>