package epson.print.storage;

import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;

import android.support.p000v4.app.DialogFragment;
import android.support.p000v4.app.FragmentActivity;




public class ConfirmCancelDialog extends DialogFragment {
    private static final String PARAM_MESSAGE_RESOURCE_ID = "message_id";

    public interface DialogCancelListener {
        void cancel();
    }

    public static ConfirmCancelDialog newInstance(int i) {
        ConfirmCancelDialog confirmCancelDialog = new ConfirmCancelDialog();
        Bundle bundle = new Bundle();
        bundle.putInt(PARAM_MESSAGE_RESOURCE_ID, i);
        confirmCancelDialog.setArguments(bundle);
        return confirmCancelDialog;
    }

    @NonNull
    public Dialog onCreateDialog(Bundle bundle) {
        int i = getArguments().getInt(PARAM_MESSAGE_RESOURCE_ID);
        setCancelable(false);
        return new AlertDialog.Builder(getActivity()).setMessage(i).setPositiveButton((CharSequence) getString(R.string.str_yes), (DialogInterface.OnClickListener) new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                ConfirmCancelDialog.this.doCancel();
            }
        }).setNegativeButton((CharSequence) getString(R.string.str_no), (DialogInterface.OnClickListener) new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
            }
        }).create();
    }

    private void doCancel() {
        FragmentActivity activity = getActivity();
        if (activity != null) {
            ((DialogCancelListener) activity).cancel();
        }
    }
}
