NewPatientIDPopWindow.java
5.94 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package com.sw.laryngoscope.popWindow;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.PopupWindow;
import android.widget.RadioGroup;
import com.sw.laryngoscope.R;
import com.sw.laryngoscope.activity.HomeActivity;
import com.sw.laryngoscope.common.InitParam;
import com.sw.laryngoscope.databinding.LayoutMainShowUserinfoDialogBinding;
@SuppressLint("NonConstantResourceId")
public class NewPatientIDPopWindow extends BasePopWindow<LayoutMainShowUserinfoDialogBinding> implements RadioGroup.OnCheckedChangeListener {
private boolean isMetric = false;
private InputMethodManager imm;
private final HomeActivity homeActivity;
public NewPatientIDPopWindow(HomeActivity activity, Context context) {
super(context);
homeActivity = activity;
}
@Override
protected LayoutMainShowUserinfoDialogBinding getViewBinding(LayoutInflater inflater) {
return LayoutMainShowUserinfoDialogBinding.inflate(inflater);
}
@Override
public void init() {
setFocusable(true);
imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
ActionModeCallbackInterceptor interceptor = new ActionModeCallbackInterceptor();
//edit_login_new_account_name.setCustomSelectionActionModeCallback(interceptor);
//edit_login_new_account_name.setCustomInsertionActionModeCallback(interceptor);
}
@Override
public void setListener() {
/*ed_patient_id.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER
&& event.getAction() == KeyEvent.ACTION_UP) {
hideInput();
}
return false;
}
});
ed_patient_id.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.toString().length() > 0) {
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
ed_patient_age.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER
&& event.getAction() == KeyEvent.ACTION_UP) {
hideInput();
}
return false;
}
});
ed_patient_age.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.toString().length() > 0) {
}
}
@Override
public void afterTextChanged(Editable s) {
}
});*/
binding.rgSex.setOnCheckedChangeListener(this);
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (group.getCheckedRadioButtonId()) {
case R.id.rb_male:
InitParam.patientSex = 0;
break;
case R.id.rb_female:
InitParam.patientSex = 1;
break;
case R.id.rb_blank:
InitParam.patientSex = 2;
break;
}
}
@Override
public void showAtLocation(View parent, int gravity, int x, int y) {
super.showAtLocation(parent, gravity, x, y);
}
@Override
public void showAsDropDown(View parent, int x, int y) {
super.showAsDropDown(parent, x, y);
setOnDismissListener(dismissListener);
binding.rbMale.setChecked(InitParam.patientSex == 0);
binding.rbFemale.setChecked(InitParam.patientSex == 1);
binding.rbBlank.setChecked(InitParam.patientSex == 2);
}
@Override
protected void onCloseClick() {
hideInput();
super.onCloseClick();
}
private void showInput() {
if (!imm.isActive()) {
imm.showSoftInput(binding.edPatientId,
InputMethodManager.SHOW_IMPLICIT);
}
}
private void hideInput() {
if (imm.isActive()) {
imm.hideSoftInputFromWindow(
binding.edPatientId.getWindowToken(), 0);
}
}
private final Runnable immMission = new Runnable() {
@Override
public void run() {
binding.edPatientId.requestFocus();
binding.edPatientId.performClick();
imm.showSoftInput(binding.edPatientId,
InputMethodManager.SHOW_IMPLICIT);
}
};
private PopupWindow.OnDismissListener dismissListener = new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if ( minfoCallback != null ) {
minfoCallback.getinfo(binding.edPatientId.getText().toString(),
binding.edPatientAge.getText().toString(),
homeActivity.getString(InitParam.SEX_VAL_RES[InitParam.patientSex]));
}
}
};
public infoCallback minfoCallback;
public void setInfoCallback(infoCallback infoCallback) {
this.minfoCallback = infoCallback;
}
public interface infoCallback {
void getinfo(String id, String age, String sex);
}
}