xyz.candycoded.alertconfirmdialog 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
 
3
3
  package com.candycoded.alertconfirmdialog;
4
4
 
5
+ import android.app.Activity;
5
6
  import android.content.Context;
6
7
  import android.app.AlertDialog;
7
8
  import android.os.Bundle;
@@ -10,52 +11,60 @@ import com.unity3d.player.UnityPlayer;
10
11
 
11
12
  public class AndroidPlugin {
12
13
 
13
- private Context context;
14
+ private Activity activity;
14
15
 
15
16
  public AndroidPlugin(Context context) {
16
- this.context = context;
17
+ this.activity = (Activity) context;
17
18
  }
18
19
 
19
20
  public void Alert(String title, String message, String okButtonLabel) {
20
21
 
21
- AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
22
+ activity.runOnUiThread(() -> {
22
23
 
23
- alertDialog.setTitle(title);
24
- alertDialog.setMessage(message);
25
- alertDialog.setPositiveButton(okButtonLabel, (dialog, which) -> {
24
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
26
25
 
27
- dialog.dismiss();
26
+ alertDialog.setTitle(title);
27
+ alertDialog.setMessage(message);
28
+ alertDialog.setPositiveButton(okButtonLabel, (dialog, which) -> {
28
29
 
29
- UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "OK");
30
+ dialog.dismiss();
31
+
32
+ UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "OK");
33
+
34
+ });
35
+ alertDialog.create();
36
+ alertDialog.show();
30
37
 
31
38
  });
32
- alertDialog.create();
33
- alertDialog.show();
34
39
 
35
40
  }
36
41
 
37
42
  public void Confirm(String title, String message, String okButtonLabel, String cancelButtonLabel) {
38
43
 
39
- AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
44
+ activity.runOnUiThread(() -> {
40
45
 
41
- alertDialog.setTitle(title);
42
- alertDialog.setMessage(message);
43
- alertDialog.setPositiveButton(okButtonLabel, (dialog, which) -> {
46
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
44
47
 
45
- dialog.dismiss();
48
+ alertDialog.setTitle(title);
49
+ alertDialog.setMessage(message);
50
+ alertDialog.setPositiveButton(okButtonLabel, (dialog, which) -> {
46
51
 
47
- UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "OK");
52
+ dialog.dismiss();
48
53
 
49
- });
50
- alertDialog.setNegativeButton(cancelButtonLabel, (dialog, which) -> {
54
+ UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "OK");
55
+
56
+ });
57
+ alertDialog.setNegativeButton(cancelButtonLabel, (dialog, which) -> {
58
+
59
+ dialog.dismiss();
51
60
 
52
- dialog.dismiss();
61
+ UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "CANCEL");
53
62
 
54
- UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "CANCEL");
63
+ });
64
+ alertDialog.create();
65
+ alertDialog.show();
55
66
 
56
67
  });
57
- alertDialog.create();
58
- alertDialog.show();
59
68
 
60
69
  }
61
70
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xyz.candycoded.alertconfirmdialog",
3
3
  "displayName": "Alert Confirm Dialog",
4
- "version": "1.0.0",
4
+ "version": "2.0.0",
5
5
  "unity": "2019.2",
6
6
  "unityRelease": "0f1",
7
7
  "description": "Display simple alert and confirm dialogs on both iOS and Android.",