@Override
  public void onAttach(Activity activity) {
    super.onAttach(activity);

    try {
      mDialogListenerRef = new WeakReference<>((DialogListener) activity);
    } catch (ClassCastException e) {
      throw new ClassCastException(activity.toString() + " must implement DialogListener");
    }
  }