Repository navigation
Expand file tree
/
Copy pathJUIAlertDialog.java
More file actions
82 lines (68 loc) · 2.26 KB
/
Copy pathJUIAlertDialog.java
File metadata and controls
82 lines (68 loc) · 2.26 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.sample.helper;
import android.view.View;
import android.widget.RelativeLayout;
import android.app.AlertDialog;
import android.app.NativeActivity;
import android.content.DialogInterface;
/*
* Java UI AlertDialog implementation
* Helper functions for jui_helper
*/
public class JUIAlertDialog extends AlertDialog {
NativeActivity activity_;
RelativeLayout dialogRelativeLayout_;
int id_ = 0;
public JUIAlertDialog(final NativeActivity act) {
super(act);
activity_ = act;
// Setup relative layout
dialogRelativeLayout_ = new RelativeLayout(activity_);
setView(dialogRelativeLayout_);
setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (id_ != 0)
JUIHelper.JUICallbackHandler(id_,
JUIHelper.JUICALLBACK_DIALOG_DISMISSED, 0, 0);
}
});
setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (id_ != 0)
JUIHelper.JUICallbackHandler(id_,
JUIHelper.JUICALLBACK_DIALOG_CANCELLED, 0, 0);
}
});
}
public void setID(int id) {
id_ = id;
}
public void addView(final View view) {
activity_.runOnUiThread(new Runnable() {
@Override
public void run() {
if (dialogRelativeLayout_ != null)
dialogRelativeLayout_.addView(view);
}
});
return;
}
private OnClickListener listener = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (id_ != 0)
JUIHelper.JUICallbackHandler(id_,
JUIHelper.JUICALLBACK_BUTTON_UP, which, 0);
}
};
public void setButtonPositive(CharSequence text) {
setButton(BUTTON_POSITIVE, text, listener);
}
public void setButtonNegative(CharSequence text) {
setButton(BUTTON_NEGATIVE, text, listener);
}
public void setButtonNeutral(CharSequence text) {
setButton(BUTTON_NEUTRAL, text, listener);
}
}