title: Passing ArreyList between Fragments with Parcelable
body: <p>After consuming a json with Retrofit and using unsynchronous callback I can't pass An ArrayList from The MainActivity to a fragment .</p>
  
  <p>Code from MainActivity:</p>
  
  <pre><code> lFragmentManager = getFragmentManager();
              lFragment = lFragmentManager.findFragmentById(R.id.frame_container);
              lFragment = new Fragment_Categories();
              Bundle bundle = new Bundle();
              bundle.putParcelableArrayList("list_categories", Categories_.getCategories());
              //for(int a = 0 ; a &lt; Categories_.getCategories().size(); a++)
              //   Log.d("billy",Categories_.getCategories().get(a).getTitle());
              lFragment.setArguments(bundle);
          lFragmentManager.beginTransaction().replace(R.id.frame_container ,lFragment ).commit();
  </code></pre>
  
  <p><strong>Note that the Log inside comments does print the context of the list</strong>, so I take the <code>ArrayList</code> in the fragment with this code inside <code>onCreateView</code>:</p>
  
  <pre><code>if(savedInstanceState != null)
          categories =  savedInstanceState.getParcelableArrayList("list_categories");
  
      /*
       * initialize the Recycler view
       */
      mRecycler = (RecyclerView)view.findViewById(R.id.categories_list);
      mAdapter = new AdapterCategories(categories,getActivity());
      mRecycler.setAdapter(mAdapter);
  </code></pre>
  
  <p>Here is my Class Category :</p>
  
  <pre><code>public class Categories implements Parcelable{
  
  private ArrayList&lt;NavDrawerItem&gt; categories;
  
  @Override
  public int describeContents() {
      return 0;
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
      dest.writeTypedList(categories);
  
  }
  
  public static final Parcelable.Creator&lt;Categories&gt; CREATOR = new Parcelable.Creator&lt;Categories&gt;() {
  
      public Categories createFromParcel(Parcel in) {
          return new Categories(in);
  
      }
  
      public Categories[] newArray(int size){
          return new Categories[size];
      }
  };
  
  private Categories(Parcel in){
  
      categories = in.createTypedArrayList(NavDrawerItem.CREATOR);
  }
  
  public ArrayList&lt;NavDrawerItem&gt; getCategories() {
      return categories;
  }
  }
  </code></pre>
  
  <p>And here is the Class NavDrawerItem:</p>
  
  <pre><code>public class NavDrawerItem implements Parcelable {
  
  private String title;
  private String description;
  private String image;
  private String post_count;
  private String id;
  private String slug;
  private int parent;
  
  @Override
  public int describeContents() {
      return 0;
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
      dest.writeString(title);
      dest.writeString(description);
      dest.writeString(image);
      dest.writeString(post_count);
      dest.writeString(id);
      dest.writeString(slug);
      dest.writeInt(parent);
  }
  
  public static final Parcelable.Creator&lt;NavDrawerItem&gt; CREATOR = new Parcelable.Creator&lt;NavDrawerItem&gt;() {
  
      public NavDrawerItem createFromParcel(Parcel in) {
          return new NavDrawerItem(in);
  
      }
  
      public NavDrawerItem[] newArray(int size){
          return new NavDrawerItem[size];
      }
  };
  
  private NavDrawerItem(Parcel in){
      title = in.readString();
      description = in.readString();
      image = in.readString();
      post_count = in.readString();
      id = in.readString();
      slug = in.readString();
      parent = in.readInt();
  }
  </code></pre>
  
  <p>The problem is that inside fragment (when trying to pass the list to the Adapter of the <code>RecyclerView</code>) or inside the adapter of the <code>RecyclerView</code> I take a null exception : </p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList android.os.Bundle.getParcelableArrayList(java.lang.String)' on a null object reference</p>
  </blockquote>
  
  <p>Thank you for the help!!</p>