-
Notifications
You must be signed in to change notification settings - Fork 0
/
CourseDoneDialogConfirmation.java
44 lines (38 loc) · 1.58 KB
/
CourseDoneDialogConfirmation.java
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
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.scoresheet.discgolf;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
/**
* Created by Joe Post on 5/8/2017.
*/
public class CourseDoneDialogConfirmation extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage("Are you sure you're done?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
notifyToTarget(Activity.RESULT_OK);
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
notifyToTarget(Activity.RESULT_CANCELED);
}
});
return builder.create();
}
private void notifyToTarget(int code) {
Fragment targetFragment = getTargetFragment();
if (targetFragment != null) {
targetFragment.onActivityResult(getTargetRequestCode(), code, null);
// DatabaseHelperScoringTable dbh = new DatabaseHelperScoringTable(getActivity());
// dbh.done();
}
}
}