package com.example.ismailamrani.comptable.utils;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

import com.example.ismailamrani.comptable.R;

/**
 * Created by Mohammed Aouf ZOUAG on 27/04/2016.
 */
public class DialogUtil {
    /**
     * Shows a custom dialog.
     *
     * @param title      of the dialog
     * @param message    of the dialog
     * @param actionText text of the dialog's action button
     * @param listener   on the action button
     */
    public static void showDialog(Context context, final String title,
                                  final String message, final String actionText,
                                  final DialogInterface.OnClickListener listener) {

        AlertDialog.Builder builder = new AlertDialog.Builder(
                context, R.style.AppCompatAlertDialogStyle);
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setPositiveButton(actionText, listener);

        AlertDialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(true);
        alertDialog.show();
    }
}

@@ -762,16 +762,352 @@
 ener) %7B%0A
+        AlertDialog alertDialog = buildDialog(context, title, message, actionText, listener);%0A        alertDialog.show();%0A    %7D%0A%0A    private static AlertDialog buildDialog(Context context, String title, String message, final String actionText,%0A                                           final DialogInterface.OnClickListener listener) %7B
 %0A       
@@ -1455,16 +1455,532 @@
 e(true);
+%0A%0A        return alertDialog;%0A    %7D%0A%0A    public static void showDialog(Context context, final String title,%0A                                  final String message, final String actionText,%0A                                  final DialogInterface.OnClickListener listener,%0A                                  final DialogInterface.OnDismissListener dismissListener) %7B%0A        AlertDialog alertDialog = buildDialog(context, title, message, actionText, listener);%0A        alertDialog.setOnDismissListener(dismissListener);
 %0A       

add a method to show an AlertDialog with a dismiss listener.