DetailCopyInfoPopWindow.java
8.77 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package com.sw.laryngoscope.popWindow;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.sw.laryngoscope.R;
import com.sw.laryngoscope.activity.HomeActivity;
import com.sw.laryngoscope.manager.SpManager;
import com.sw.laryngoscope.utils.Logger;
import butterknife.BindView;
@SuppressLint("NonConstantResourceId")
public class DetailCopyInfoPopWindow extends BasePopWindow implements RadioGroup.OnCheckedChangeListener {
@BindView(R.id.lay_copy_info)
RelativeLayout lay_copy_info;
@BindView(R.id.rg_format)
RadioGroup rg_format;
@BindView(R.id.rb_dicom)
RadioButton rb_dicom;
@BindView(R.id.rb_basic)
RadioButton rb_basic;
@BindView(R.id.ed_patient_id)
EditText ed_patient_id;
@BindView(R.id.ed_name)
EditText ed_name;
@BindView(R.id.ed_age)
EditText ed_age;
@BindView(R.id.rg_sex)
RadioGroup rg_sex;
@BindView(R.id.rb_male)
RadioButton rb_male;
@BindView(R.id.rb_female)
RadioButton rb_female;
@BindView(R.id.img_export_close)
ImageView img_export_close;
@BindView(R.id.img_export)
ImageView img_export;
@BindView(R.id.lay_copying)
RelativeLayout lay_copying;
@BindView(R.id.txt_tip_3)
TextView txt_tip_3;
@BindView(R.id.txt_ok)
TextView txt_ok;
@BindView(R.id.lay_2)
RelativeLayout lay_2;
@BindView(R.id.lay_3)
RelativeLayout lay_3;
@BindView(R.id.lay_4)
RelativeLayout lay_4;
@BindView(R.id.lay_5)
RelativeLayout lay_5;
@BindView(R.id.lay_6)
RelativeLayout lay_6;
/**
* 是否为公制
*/
private boolean isMetric = false;
private InputMethodManager imm;
private final HomeActivity homeActivity;
public DetailCopyInfoPopWindow(HomeActivity activity, Context context) {
super(context);
homeActivity = activity;
}
@Override
public int getPopLayoutId() {
return R.layout.layout_detail_copy_info_dialog;
}
@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);
setOutsideTouchable(false);
//setFocusable(false);
setTouchable(true);
setWidth(mContext.getResources()
.getDimensionPixelSize(R.dimen.dp_x_1019));
setHeight(mContext.getResources()
.getDimensionPixelSize(R.dimen.dp_y_755));
if ( SpManager.get_copy_file_type() == 0 ) {
rb_dicom.setChecked(true);
setLayDicomShow(View.VISIBLE);
} else if ( SpManager.get_copy_file_type() == 1 ) {
rb_basic.setChecked(true);
setLayDicomShow(View.GONE);
}
rb_male.setChecked(true);
/*setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if ( event.getY() >= 0 ) {//PopupWindow内部的事件
return false;
}
if ( mCopyCallback != null ) {
mCopyCallback.cancelCopy();
}
return true;
}
});*/
}
void setLayDicomShow(int visibility) {
lay_2.setVisibility(visibility);
lay_3.setVisibility(visibility);
lay_4.setVisibility(visibility);
lay_5.setVisibility(visibility);
lay_6.setVisibility(visibility == View.VISIBLE ? View.GONE : View.VISIBLE);
}
@Override
public void setListener() {
img_export_close.setOnClickListener(this);
img_export.setOnClickListener(this);
txt_ok.setOnClickListener(this);
rg_format.setOnCheckedChangeListener(this);
rg_sex.setOnCheckedChangeListener(this);
ed_patient_id.setOnClickListener(this);
ed_name.setOnClickListener(this);
ed_age.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.ed_patient_id://拉起软键盘
showInput();
break;
case R.id.ed_name://拉起软键盘
showInput();
break;
case R.id.ed_age://拉起软键盘
showInput();
break;
case R.id.img_export_close:
dismiss();
break;
case R.id.img_export:
if ( mCopyCallback != null ) {
lay_copy_info.setVisibility(View.GONE);
lay_copying.setVisibility(View.VISIBLE);
mCopyCallback.startCopy(SpManager.get_copy_file_type(), ed_name.getText().toString().trim(),
rb_male.isChecked() ? "M" : "F",
ed_patient_id.getText().toString().trim(),
ed_age.getText().toString().trim());
}
break;
case R.id.txt_ok:
if ( mCopyCallback != null ) {
mCopyCallback.cancelCopy();
}
break;
default:
break;
}
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
@Override
public void showAtLocation(View parent, int gravity, int x, int y) {
super.showAtLocation(parent, gravity, x, y);
lay_copy_info.setVisibility(View.VISIBLE);
lay_copying.setVisibility(View.GONE);
setOnDismissListener(dismissListener);
}
@Override
public void showAsDropDown(View parent, int x, int y) {
super.showAsDropDown(parent, x, y);
setOnDismissListener(dismissListener);
}
@Override
protected void onCloseClick() {
hideInput();
super.onCloseClick();
if ( mCopyCallback != null ) {
mCopyCallback.cancelCopy();
}
}
private void showInput() {
//if (!imm.isActive()) {
imm.showSoftInput(ed_patient_id,
InputMethodManager.SHOW_IMPLICIT);
Logger.d("======showInput========");
//}
}
private void hideInput() {
if (imm.isActive()) {
imm.hideSoftInputFromWindow(
ed_patient_id.getWindowToken(), 0);
}
}
private final Runnable immMission = new Runnable() {
@Override
public void run() {
ed_patient_id.requestFocus();
ed_patient_id.performClick();
imm.showSoftInput(ed_patient_id,
InputMethodManager.SHOW_IMPLICIT);
}
};
private OnDismissListener dismissListener = new OnDismissListener() {
@Override
public void onDismiss() {
if ( mCopyCallback != null ) {
hideInput();
onCloseClick();
}
}
};
public copyCallback mCopyCallback;
public void setCopyCallback(copyCallback copyCallback) {
this.mCopyCallback = copyCallback;
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (rg_format.getCheckedRadioButtonId()) {
case R.id.rb_dicom:
SpManager.set_copy_file_type(0);
Logger.d(TAG, "============rb_dicom");
setLayDicomShow(View.VISIBLE);
break;
case R.id.rb_basic:
SpManager.set_copy_file_type(1);
Logger.d(TAG, "============rb_basic");
setLayDicomShow(View.GONE);
break;
default:
break;
}
switch (rg_sex.getCheckedRadioButtonId()) {
case R.id.rb_male:
Logger.d(TAG, "============rb_male");
break;
case R.id.rb_female:
Logger.d(TAG, "============rb_female");
break;
default:
break;
}
}
public interface copyCallback {
void startCopy(int type, String name, String sex, String id,
String age);
void cancelCopy();
}
public void setCopyInfo(String cpNum, String checkNum) {
txt_tip_3.setText( homeActivity.getString(R.string.string_copy_tip, cpNum,
checkNum) );
}
}