title: Child Fragment to Parent Fragment communication
body: <p>In my child Fragment, I have a Recyclerview, and I haved an Appbar layout in my parent Fragment. When the Recyclerview's first item is visible, I need to update the appbar layout in my parent fragment</p>
  
  <p>My interface</p>
  
  <pre><code>public interface OnListFirstItemVisibleListener {
      public void sendDataToFragmentOnFirstItemVisible(boolean data, int dy);
  }
  </code></pre>
  
  <p>in Child Fragment class</p>
  
  <pre><code>public class MyChildFragment extends Fragment{
  private OnListFirstItemVisibleListener mListFirstItemVisibleListener;
  .............
    @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          mListFirstItemVisibleListener=(OnListFirstItemVisibleListener) new ParentFragment();
  
          return view;
      }
   @Override
      public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
  
          if(mLinearLayoutManager.findFirstCompletelyVisibleItemPosition()==0&amp;&amp;mListFirstItemVisibleListener != null){
              mListFirstItemVisibleListener.sendDataToFragmentOnFirstItemVisible(true,dy);
          }else{
              mListFirstItemVisibleListener.sendDataToFragmentOnFirstItemVisible(false,dy);
  
          }
  
      }
  </code></pre>
  
  <p>In Parent Fragment class</p>
  
  <p>I implemented the interface</p>
  
  <pre><code>public class MyParentFragment extends Fragment implements OnListFirstItemVisibleListener{
  
  ............
  
  @Override
      public void sendDataToFragmentOnFirstItemVisible(boolean data, int dy) {
          if (dy &lt; 0&amp;&amp;data==true)
              mAppBarLayout.setExpanded(true);
      }
  
  }
  </code></pre>
  
  <p>But I get Appbar layout as null</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.design.widget.AppBarLayout.setExpanded(boolean)' on a null object
  </code></pre>
  
  <p>Where am I going wrong?</p>