-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathSimpleMessageDialogProvider.java
45 lines (37 loc) · 1.34 KB
/
SimpleMessageDialogProvider.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
45
package com.yayandroid.locationmanager.providers.dialogprovider;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
public class SimpleMessageDialogProvider extends DialogProvider implements DialogInterface.OnClickListener {
private String message;
public SimpleMessageDialogProvider(String message) {
this.message = message;
}
public String message() {
return message;
}
@Override
public Dialog getDialog(@NonNull Context context) {
return new AlertDialog.Builder(context)
.setMessage(message)
.setCancelable(false)
.setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, this)
.create();
}
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
if (getDialogListener() != null) getDialogListener().onPositiveButtonClick();
break;
}
case DialogInterface.BUTTON_NEGATIVE: {
if (getDialogListener() != null) getDialogListener().onNegativeButtonClick();
break;
}
}
}
}