]>
Commit | Line | Data |
---|---|---|
1 | package ro.ieval.unical; | |
2 | ||
3 | import android.annotation.SuppressLint; | |
4 | import android.app.Activity; | |
5 | import android.app.AlertDialog; | |
6 | import android.app.Dialog; | |
7 | import android.app.DialogFragment; | |
8 | import android.content.DialogInterface; | |
9 | import android.os.Bundle; | |
10 | ||
11 | @SuppressLint("ValidFragment") | |
12 | public final class DeleteEventDialog extends DialogFragment { | |
13 | private final Event event; | |
14 | private final Activity activity; | |
15 | ||
16 | public DeleteEventDialog(final Event event, final Activity activity) { | |
17 | super(); | |
18 | this.event=event; | |
19 | this.activity=activity; | |
20 | } | |
21 | ||
22 | @Override | |
23 | public Dialog onCreateDialog(final Bundle savedInstanceState) { | |
24 | final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |
25 | builder.setMessage(R.string.askdeleteevent) | |
26 | .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { | |
27 | @Override | |
28 | public void onClick(final DialogInterface dialog, final int id) { | |
29 | event.delete(getActivity()); | |
30 | activity.finish(); | |
31 | } | |
32 | }) | |
33 | .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { | |
34 | @Override | |
35 | public void onClick(final DialogInterface dialog, final int id) { | |
36 | // User cancelled the dialog | |
37 | } | |
38 | }); | |
39 | return builder.create(); | |
40 | } | |
41 | } |