title: Bottom Sheet Dialog Fragment won't show
body: <p>I created a <code>Modal Bottom Sheet</code> fragment and by default has these lines</p>
  
  <pre><code>/**
  * &lt;p&gt;A fragment that shows a list of items as a modal bottom sheet.&lt;/p&gt;
  * &lt;p&gt;You can show this modal bottom sheet from your activity like this:&lt;/p&gt;
  * &lt;pre&gt;
  * ShoppingCartListDialogFragment.newInstance(30).show(getSupportFragmentManager(), "dialog");
  * &lt;/pre&gt;
  * &lt;p&gt;You activity (or fragment) needs to implement {@link ShoppingCartListDialogFragment.Listener}.&lt;/p&gt;
  */
  </code></pre>
  
  <p>Then on my <code>MainActivity.java</code> i have an <code>onClick</code> function like this:</p>
  
  <pre><code>public void showShoppingCart(View view) {
      // Testing
      ShoppingCartListDialogFragment.newInstance(30).show(getSupportFragmentManager(), "dialog");
  }
  </code></pre>
  
  <p>Whenever i click the button my app crashes i get an error from the fragment's <code>onAttach</code> method</p>
  
  <pre><code>@Override
  public void onAttach(Context context) {
      super.onAttach(context);
      final Fragment parent = getParentFragment();
      if (parent != null) {
          mListener = (Listener) parent;
      } else {
          mListener = (Listener) context; &lt;-- Error on this line
      }
  }
  </code></pre>
  
  <p>Does anyone know what am i missing here? I really don't get the last comment line. Where do i implement a <code>.Listener</code> ?</p>
  
  <p>Error Log: </p>
  
  <pre><code>FATAL EXCEPTION: main
                Process: com.example.johng.assosfood, PID: 28856
                java.lang.ClassCastException: com.example.johng.assosfood.ProductsActivity cannot be cast to com.example.johng.assosfood.ShoppingCartListDialogFragment$Listener
                    at com.example.johng.assosfood.ShoppingCartListDialogFragment.onAttach(ShoppingCartListDialogFragment.java:59)
                    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1367)
                    at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1754)
                    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1822)
                    at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
                    at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2591)
                    at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2378)
                    at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2333)
                    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2240)
                    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:703)
                    at android.os.Handler.handleCallback(Handler.java:751)
                    at android.os.Handler.dispatchMessage(Handler.java:95)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6682)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
  </code></pre>