package com.saq.android.utils;

import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Handler;
import android.widget.Toast;

public class DialogHandler {
    private static Handler handler;

    /* renamed from: com.saq.android.utils.DialogHandler.1 */
    static class C00931 implements OnClickListener {
        C00931() {
        }

        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    }

    /* renamed from: com.saq.android.utils.DialogHandler.2 */
    static class C00942 implements OnClickListener {
        private final /* synthetic */ Runnable val$r;

        C00942(Runnable runnable) {
            this.val$r = runnable;
        }

        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
            this.val$r.run();
        }
    }

    /* renamed from: com.saq.android.utils.DialogHandler.3 */
    static class C00953 implements OnClickListener {
        private final /* synthetic */ Runnable val$positiveAction;

        C00953(Runnable runnable) {
            this.val$positiveAction = runnable;
        }

        public void onClick(DialogInterface dialog, int id) {
            if (this.val$positiveAction != null) {
                DialogHandler.handler.post(this.val$positiveAction);
                dialog.dismiss();
                return;
            }
            dialog.dismiss();
        }
    }

    /* renamed from: com.saq.android.utils.DialogHandler.4 */
    static class C00964 implements OnClickListener {
        private final /* synthetic */ Runnable val$negativeAction;

        C00964(Runnable runnable) {
            this.val$negativeAction = runnable;
        }

        public void onClick(DialogInterface dialog, int which) {
            if (this.val$negativeAction != null) {
                DialogHandler.handler.post(this.val$negativeAction);
                dialog.dismiss();
                return;
            }
            dialog.dismiss();
        }
    }

    static {
        handler = new Handler();
    }

    public static void showDialogMessage(String title, String content, String buttonText, Context context) {
        Builder builder = new Builder(context);
        builder.setTitle(title);
        builder.setMessage(content).setCancelable(false).setPositiveButton(buttonText, new C00931());
        builder.create().show();
    }

    public static void showDialogMessage(String title, String content, String buttonText, Runnable r, Context context) {
        Builder builder = new Builder(context);
        builder.setTitle(title);
        builder.setMessage(content).setCancelable(false).setPositiveButton(buttonText, new C00942(r));
        builder.create().show();
    }

    public static void showDialogMessagePositiveNegative(String title, String content, String positiveButtonText, String negativeButtonText, Runnable positiveAction, Runnable negativeAction, Context context) {
        Builder builder = new Builder(context);
        builder.setTitle(title);
        builder.setMessage(content).setCancelable(false).setPositiveButton(positiveButtonText, new C00953(positiveAction)).setNegativeButton(negativeButtonText, new C00964(negativeAction));
        builder.create().show();
    }

    public static void showToastMessage(String text, Context context) {
        Toast.makeText(context, text, Toast.LENGTH_LONG).show();
    }

    public static void showToastMessage(String text, int duration, Context context) {
        Toast.makeText(context, text, duration).show();
    }

    public static ProgressDialog prepareProgressDialog(Context context, String title, String content, boolean indeterminate, boolean cancellable, int maxProgress) {
        ProgressDialog mProgressDialog = new ProgressDialog(context);
        mProgressDialog.setTitle(title);
        mProgressDialog.setProgressStyle(1);
        mProgressDialog.setMax(maxProgress);
        return mProgressDialog;
    }
}
