// Path: app/src/main/java/com/chrynan/android_guitar_tuner/exception/MissingListenerException.java
// public class MissingListenerException extends RuntimeException {
// 
//     /**
//      * Constructor for this exception class.
//      *
//      * @param listenerClass          The Listener {@link Class}.
//      * @param classExpectingListener The {@link Class} that discovered the missing Listener.
//      */
//     public MissingListenerException(final Class<?> listenerClass, final Class<?> classExpectingListener) {
//         super("Class " + classExpectingListener.getName() + " expects the listener " + listenerClass.getCanonicalName() +
//                 " to be set.");
//     }
// 
//     /**
//      * Constructor for this exception class.
//      *
//      * @param listenerClass            The Listener {@link Class}.
//      * @param classToImplementListener The {@link Class} that should implement the Listener but does not.
//      * @param classExpectingListener   The {@link Class} that discovered the missing Listener.
//      */
//     public MissingListenerException(final Class<?> listenerClass, final Class<?> classToImplementListener, final Class<?> classExpectingListener) {
//         super("Class " + classExpectingListener.getName() + " expects the class " + classToImplementListener.getName() +
//                 "to implement the listener " + listenerClass.getCanonicalName());
//     }
// }


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.exception.MissingListenerException;
package com.chrynan.android_guitar_tuner.ui.dialog;



/**
 * A {@link DialogFragment} that displays more information on why the AUDIO_RECORD permission is
 * needed.
 */
public class PermissionRationalDialogFragment extends DialogFragment {

    public static final String TAG = "PermissionRationalDialogFragment";

    private DialogListener listener;

    public static PermissionRationalDialogFragment newInstance() {
        return new PermissionRationalDialogFragment();
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        if (DialogListener.class.isInstance(getParentFragment())) {
            listener = (DialogListener) getParentFragment();
        } else if (DialogListener.class.isInstance(getActivity())) {
            listener = (DialogListener) getActivity();
        } else {
            Class<?> parentClazz = getParentFragment() != null ? getParentFragment().getClass() : getActivity().getClass();

// Path: app/src/main/java/com/chrynan/android_guitar_tuner/exception/MissingListenerException.java
// public class MissingListenerException extends RuntimeException {
// 
//     /**
//      * Constructor for this exception class.
//      *
//      * @param listenerClass          The Listener {@link Class}.
//      * @param classExpectingListener The {@link Class} that discovered the missing Listener.
//      */
//     public MissingListenerException(final Class<?> listenerClass, final Class<?> classExpectingListener) {
//         super("Class " + classExpectingListener.getName() + " expects the listener " + listenerClass.getCanonicalName() +
//                 " to be set.");
//     }
// 
//     /**
//      * Constructor for this exception class.
//      *
//      * @param listenerClass            The Listener {@link Class}.
//      * @param classToImplementListener The {@link Class} that should implement the Listener but does not.
//      * @param classExpectingListener   The {@link Class} that discovered the missing Listener.
//      */
//     public MissingListenerException(final Class<?> listenerClass, final Class<?> classToImplementListener, final Class<?> classExpectingListener) {
//         super("Class " + classExpectingListener.getName() + " expects the class " + classToImplementListener.getName() +
//                 "to implement the listener " + listenerClass.getCanonicalName());
//     }
// }


// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/dialog/PermissionRationalDialogFragment.java
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.exception.MissingListenerException;

package com.chrynan.android_guitar_tuner.ui.dialog;



/**
 * A {@link DialogFragment} that displays more information on why the AUDIO_RECORD permission is
 * needed.
 */
public class PermissionRationalDialogFragment extends DialogFragment {

    public static final String TAG = "PermissionRationalDialogFragment";

    private DialogListener listener;

    public static PermissionRationalDialogFragment newInstance() {
        return new PermissionRationalDialogFragment();
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        if (DialogListener.class.isInstance(getParentFragment())) {
            listener = (DialogListener) getParentFragment();
        } else if (DialogListener.class.isInstance(getActivity())) {
            listener = (DialogListener) getActivity();
        } else {
            Class<?> parentClazz = getParentFragment() != null ? getParentFragment().getClass() : getActivity().getClass();

            throw new MissingListenerException(DialogListener.class, parentClazz, PermissionRationalDialogFragment.class);