summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/photoeditor/YesCancelDialogBuilder.java
blob: 4df76e6785f8feee31d77e1f531b1a886e19b4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.android.gallery3d.photoeditor;

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

import com.android.gallery3d.R;

/**
 * Alert dialog builder that builds a simple Yes/Cancel dialog.
 */
public class YesCancelDialogBuilder extends AlertDialog.Builder {

    public YesCancelDialogBuilder(Context context, final Runnable yes, int messageId) {
        super(context);
        setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                yes.run();
            }
        })
        .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // no-op
            }
        }).setMessage(messageId);
    }
}