tharak-android 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/build.gradle +45 -0
- package/consumer-rules.pro +0 -0
- package/libs/vital-sdk.aar +0 -0
- package/package.json +22 -0
- package/proguard-rules.pro +21 -0
- package/src/androidTest/androidTest.iml +11 -0
- package/src/androidTest/java/org/tharak/core/ExampleInstrumentedTest.java +27 -0
- package/src/androidTest/java/org/thiragatisoft/core/ExampleInstrumentedTest.java +26 -0
- package/src/main/AndroidManifest.xml +5 -0
- package/src/main/java/org/thiragatisoft/core/AppUtils.java +31 -0
- package/src/main/java/org/thiragatisoft/core/FileSelector.java +162 -0
- package/src/main/java/org/thiragatisoft/core/MainActivity.java +27 -0
- package/src/main/java/org/thiragatisoft/core/RestClient.java +298 -0
- package/src/main/java/org/thiragatisoft/core/VitalActivity.java +612 -0
- package/src/main/java/org/thiragatisoft/core/VitalsPlugin.java +15 -0
- package/src/main/java/org/thiragatisoft/core/VolleyMultipartRequest.java +218 -0
- package/src/main/java/org/thiragatisoft/core/http/CapacitorCookieManager.java +175 -0
- package/src/main/java/org/thiragatisoft/core/http/CapacitorHttpUrlConnection.java +408 -0
- package/src/main/java/org/thiragatisoft/core/http/FilesystemUtils.java +65 -0
- package/src/main/java/org/thiragatisoft/core/http/FormUploader.java +219 -0
- package/src/main/java/org/thiragatisoft/core/http/Http.java +275 -0
- package/src/main/java/org/thiragatisoft/core/http/HttpRequestHandler.java +515 -0
- package/src/main/java/org/thiragatisoft/core/http/ICapacitorHttpUrlConnection.java +15 -0
- package/src/main/java/org/thiragatisoft/core/http/JSValue.java +68 -0
- package/src/main/java/org/thiragatisoft/core/http/MimeType.java +17 -0
- package/src/main/main.iml +12 -0
- package/src/test/java/org/tharak/ExampleUnitTest.java +17 -0
- package/src/test/java/org/tharak/JSObjectTest.java +209 -0
- package/src/test/java/org/tharak/PluginMethodHandleTest.java +44 -0
- package/src/test/java/org/tharak/util/HostMaskTest.java +70 -0
- package/src/test/java/org/thiragatisoft/core/ExampleUnitTest.java +17 -0
- package/src/test/test.iml +11 -0
@@ -0,0 +1,612 @@
|
|
1
|
+
package org.thiragatisoft.core;
|
2
|
+
|
3
|
+
import android.app.Activity;
|
4
|
+
import android.content.Intent;
|
5
|
+
import android.content.res.Resources;
|
6
|
+
import android.os.Bundle;
|
7
|
+
import android.os.Handler;
|
8
|
+
import android.os.Message;
|
9
|
+
import android.view.View;
|
10
|
+
import android.webkit.JavascriptInterface;
|
11
|
+
import android.widget.ImageView;
|
12
|
+
import android.widget.TextView;
|
13
|
+
import android.widget.Toast;
|
14
|
+
|
15
|
+
import com.creative.SpotCheck.SpotSendCMDThread;
|
16
|
+
import com.creative.SpotCheck.StatusMsg;
|
17
|
+
import com.getcapacitor.BridgeActivity;
|
18
|
+
import com.getcapacitor.PluginCall;
|
19
|
+
import com.getcapacitor.PluginResult;
|
20
|
+
|
21
|
+
import org.json.JSONObject;
|
22
|
+
import org.tharak.vital.bluetooth.ConnectActivity;
|
23
|
+
import org.tharak.vital.bluetooth.MyBluetoooth;
|
24
|
+
import org.tharak.vital.recvdata.ReceiveService;
|
25
|
+
import org.tharak.vital.recvdata.StaticReceive;
|
26
|
+
|
27
|
+
public class VitalActivity extends BridgeActivity {
|
28
|
+
|
29
|
+
/*private TextView tv_SYS, tv_DIA, tv_SPO, tv_PR, tv_TMP, tv_GLU, tv_MSG,
|
30
|
+
tv_MODE;
|
31
|
+
private Button bt_BIBP, bt_ECG;*/
|
32
|
+
//private ImageView img_Pulse, img_Battery;
|
33
|
+
/**
|
34
|
+
* 300�����߳�
|
35
|
+
*/
|
36
|
+
//private DrawThreadPC300 drawRunablePC300;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* 300��״ͼ
|
40
|
+
*/
|
41
|
+
//private DrawPC300SPO2Rect drawPC300SPO2Rect;
|
42
|
+
|
43
|
+
/** ����300��״ͼ�߳� */
|
44
|
+
//private Thread drawPC300SPO2RectThread;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* 300��״ͼ�����߳�
|
48
|
+
*/
|
49
|
+
//private DrawPC300NIBPRect drawPC300NIBPRect;
|
50
|
+
/**
|
51
|
+
* ��ͼ�߳�
|
52
|
+
*/
|
53
|
+
//private Thread drawThread;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* �����ȼ�
|
57
|
+
*/
|
58
|
+
/*private int batteryRes[] = { R.mipmap.battery_0, R.mipmap.battery_1,
|
59
|
+
R.mipmap.battery_2, R.mipmap.battery_3 };*/
|
60
|
+
|
61
|
+
/**
|
62
|
+
* ��س��״̬
|
63
|
+
*/
|
64
|
+
/*private int batteryRes_img[] = { R.mipmap.battery_0_ing,
|
65
|
+
R.mipmap.battery_1_ing, R.mipmap.battery_2_ing,
|
66
|
+
R.mipmap.battery_3_ing };*/
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Ѫѹ����������
|
70
|
+
*/
|
71
|
+
private String[] nibpERR;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* �ĵ����������
|
75
|
+
*/
|
76
|
+
private String[] ecgERR;
|
77
|
+
|
78
|
+
private Resources myResources;
|
79
|
+
|
80
|
+
/**
|
81
|
+
* �ĵ����״̬
|
82
|
+
*/
|
83
|
+
private boolean isECGIng = false;
|
84
|
+
/**
|
85
|
+
* Ѫѹ����״̬
|
86
|
+
*/
|
87
|
+
private boolean isNIBPIng = false;
|
88
|
+
/**
|
89
|
+
* Ѫ���������
|
90
|
+
*/
|
91
|
+
private boolean isSpo2Ing = false;
|
92
|
+
/*private final static int ECG = 1;
|
93
|
+
private final static int NBP = 2;*/
|
94
|
+
private final static int HEIGHT = 1;
|
95
|
+
private final static int WEIGHT = 2;
|
96
|
+
private final static int NBP = 3;
|
97
|
+
private final static int TEMP = 4;
|
98
|
+
private final static int PULSE_RATE = 5;
|
99
|
+
private final static int HEMOGLOBIN = 6;
|
100
|
+
private final static int OXY_SAT = 7;
|
101
|
+
private final static int RESP_RATE = 8;
|
102
|
+
private final static int CHOLESTEROL = 9;
|
103
|
+
private final static int ECG = 10;
|
104
|
+
private String mCallback;
|
105
|
+
private PluginCall mCall;
|
106
|
+
@Override
|
107
|
+
protected void onCreate(Bundle savedInstanceState) {
|
108
|
+
super.onCreate(savedInstanceState);
|
109
|
+
//setContentView(R.layout.activity_main);
|
110
|
+
myResources = getResources();
|
111
|
+
nibpERR = myResources.getStringArray(org.tharak.vital.R.array.bp_err_new);
|
112
|
+
ecgERR = myResources.getStringArray(org.tharak.vital.R.array.ecg_measureres);
|
113
|
+
|
114
|
+
/*tv_SYS = (TextView) findViewById(R.id.realplay_pc300_tv_sys);
|
115
|
+
tv_DIA = (TextView) findViewById(R.id.realplay_pc300_tv_dia);
|
116
|
+
tv_SPO = (TextView) findViewById(R.id.realplay_pc300_tv_spo);
|
117
|
+
tv_PR = (TextView) findViewById(R.id.realplay_pc300_tv_pr);
|
118
|
+
tv_TMP = (TextView) findViewById(R.id.realplay_pc300_tv_temp);
|
119
|
+
tv_GLU = (TextView) findViewById(R.id.realplay_pc300_tv_glu);
|
120
|
+
tv_MSG = (TextView) findViewById(R.id.realplay_pc300_tv_msg);
|
121
|
+
tv_MODE = (TextView) findViewById(R.id.realplay_pc300_tv_mode);
|
122
|
+
|
123
|
+
bt_BIBP = (Button) findViewById(R.id.realplay_pc300_bt_nibp);
|
124
|
+
bt_ECG = (Button) findViewById(R.id.realplay_pc300_bt_ecg);*/
|
125
|
+
|
126
|
+
/*drawRunablePC300 = (DrawThreadPC300) findViewById(R.id.realpaly_pc300_view_draw);
|
127
|
+
drawRunablePC300.setmHandler(mHandler);
|
128
|
+
drawThread = new Thread(drawRunablePC300, "DrawPC300SNT");
|
129
|
+
drawThread.start();*/
|
130
|
+
|
131
|
+
/*drawPC300SPO2Rect = (DrawPC300SPO2Rect) findViewById(R.id.realpaly_pc300_draw_spo_rect);
|
132
|
+
drawPC300NIBPRect = (DrawPC300NIBPRect) findViewById(R.id.realpaly_pc300_draw_nibp_rect);
|
133
|
+
drawPC300SPO2RectThread = new Thread(drawPC300SPO2Rect,
|
134
|
+
"DrawPC300RectThread");
|
135
|
+
drawPC300SPO2RectThread.start();*/
|
136
|
+
|
137
|
+
/*img_Pulse = (ImageView) findViewById(R.id.realplay_pc300_img_pulse);
|
138
|
+
img_Battery = (ImageView) findViewById(R.id.realplay_pc300_img_battery);*/
|
139
|
+
|
140
|
+
/*bt_BIBP.setOnClickListener(myOnClickListener);
|
141
|
+
bt_ECG.setOnClickListener(myOnClickListener);
|
142
|
+
load(this);*/
|
143
|
+
startService(new Intent(this, ReceiveService.class));
|
144
|
+
}
|
145
|
+
@JavascriptInterface
|
146
|
+
public void searchDevice(int type, String callback){
|
147
|
+
switch (type) {
|
148
|
+
case ECG: {
|
149
|
+
if (!MyBluetoooth.isConnected) {
|
150
|
+
connectDevice();
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
if (StatusMsg.ECG_DEVICE_STATUS == StatusMsg.ECG_LEAD_ON) {
|
154
|
+
this.mCallback = callback;
|
155
|
+
if (isECGIng) {
|
156
|
+
SpotSendCMDThread.SendStopECG();
|
157
|
+
} else {
|
158
|
+
SpotSendCMDThread.SendStartECG();
|
159
|
+
}
|
160
|
+
} else {
|
161
|
+
Toast.makeText(this,
|
162
|
+
org.tharak.vital.R.string.measure_ecg_connect_dev,
|
163
|
+
Toast.LENGTH_SHORT).show();
|
164
|
+
}
|
165
|
+
}
|
166
|
+
break;
|
167
|
+
default: {
|
168
|
+
if (!MyBluetoooth.isConnected) {
|
169
|
+
connectDevice();
|
170
|
+
break;
|
171
|
+
}
|
172
|
+
this.mCallback = callback;
|
173
|
+
if (isNIBPIng) {
|
174
|
+
SpotSendCMDThread.SendStopMeasure();
|
175
|
+
} else {
|
176
|
+
SpotSendCMDThread.SendStartMeasure();
|
177
|
+
}
|
178
|
+
}
|
179
|
+
}
|
180
|
+
}
|
181
|
+
public void searchDevice2(PluginCall call){
|
182
|
+
int type = call.getInt("type");
|
183
|
+
switch (type) {
|
184
|
+
case ECG: {
|
185
|
+
if (!MyBluetoooth.isConnected) {
|
186
|
+
connectDevice();
|
187
|
+
break;
|
188
|
+
}
|
189
|
+
if (StatusMsg.ECG_DEVICE_STATUS == StatusMsg.ECG_LEAD_ON) {
|
190
|
+
this.mCall = call;
|
191
|
+
if (isECGIng) {
|
192
|
+
SpotSendCMDThread.SendStopECG();
|
193
|
+
} else {
|
194
|
+
SpotSendCMDThread.SendStartECG();
|
195
|
+
}
|
196
|
+
} else {
|
197
|
+
Toast.makeText(this,
|
198
|
+
org.tharak.vital.R.string.measure_ecg_connect_dev,
|
199
|
+
Toast.LENGTH_SHORT).show();
|
200
|
+
}
|
201
|
+
}
|
202
|
+
break;
|
203
|
+
default: {
|
204
|
+
if (!MyBluetoooth.isConnected) {
|
205
|
+
connectDevice();
|
206
|
+
break;
|
207
|
+
}
|
208
|
+
this.mCall = call;
|
209
|
+
if (isNIBPIng) {
|
210
|
+
SpotSendCMDThread.SendStopMeasure();
|
211
|
+
} else {
|
212
|
+
SpotSendCMDThread.SendStartMeasure();
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}
|
216
|
+
}
|
217
|
+
/**
|
218
|
+
* �����豸
|
219
|
+
*/
|
220
|
+
private void connectDevice() {
|
221
|
+
if (MyBluetoooth.isConnected)
|
222
|
+
return;
|
223
|
+
Intent i = new Intent(this, ConnectActivity.class);
|
224
|
+
i.putExtra("device", 0);
|
225
|
+
startActivityForResult(i, 0x100);
|
226
|
+
}
|
227
|
+
|
228
|
+
@Override
|
229
|
+
protected void onActivityResult(int arg0, int arg1, Intent arg2) {
|
230
|
+
super.onActivityResult(arg0, arg1, arg2);
|
231
|
+
switch (arg0) {
|
232
|
+
case 0x100: {
|
233
|
+
if (arg1 == 1) {// ���ӳɹ�
|
234
|
+
StaticReceive.setmHandler(mHandler);
|
235
|
+
Toast.makeText(this, "���ӳɹ�", Toast.LENGTH_SHORT).show();
|
236
|
+
}
|
237
|
+
}
|
238
|
+
break;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
private Handler mHandler = new Handler() {
|
243
|
+
|
244
|
+
@Override
|
245
|
+
public void handleMessage(Message msg) {
|
246
|
+
super.handleMessage(msg);
|
247
|
+
switch (msg.what) {
|
248
|
+
case StaticReceive.MSG_DATA_DEVICE_SHUT:
|
249
|
+
case StaticReceive.MSG_DATA_DISCON: {
|
250
|
+
Toast.makeText(VitalActivity.this, org.tharak.vital.R.string.connect_connect_off,
|
251
|
+
Toast.LENGTH_SHORT).show();
|
252
|
+
}
|
253
|
+
break;
|
254
|
+
case StaticReceive.MSG_DATA_DEVICE_ID: {
|
255
|
+
}
|
256
|
+
break;
|
257
|
+
case StaticReceive.MSG_DATA_BATTERY: {
|
258
|
+
//setBattery(msg.arg1, msg.arg2);
|
259
|
+
}
|
260
|
+
break;
|
261
|
+
case StaticReceive.MSG_DATA_ECG_STATUS_CH: {
|
262
|
+
if (msg.arg1 == 0) {// �ĵ翪ʼ����
|
263
|
+
isECGIng = true;
|
264
|
+
checkECGStatus(true);
|
265
|
+
setTVtext("MODE", "ECG");
|
266
|
+
//setTVtext(tv_MODE, "ECG");
|
267
|
+
if (!isSpo2Ing) {
|
268
|
+
setPR("");
|
269
|
+
}
|
270
|
+
} else if (msg.arg1 == 1) {// �ĵ����ֹͣ
|
271
|
+
isECGIng = false;
|
272
|
+
checkECGStatus(false);
|
273
|
+
//drawRunablePC300.cleanWaveData();
|
274
|
+
} else if (msg.arg1 == 2) {// �ĵ�������
|
275
|
+
isECGIng = false;
|
276
|
+
checkECGStatus(false);
|
277
|
+
Toast.makeText(VitalActivity.this, ecgERR[msg.arg2],
|
278
|
+
Toast.LENGTH_SHORT).show();
|
279
|
+
//drawRunablePC300.cleanWaveData();
|
280
|
+
if (!isSpo2Ing) {
|
281
|
+
setPR(String.valueOf(msg.obj));
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
break;
|
286
|
+
case StaticReceive.MSG_DATA_ECG_WAVE: {
|
287
|
+
Bundle d = msg.getData();
|
288
|
+
if (!d.getBoolean("bLeadoff")) {
|
289
|
+
setTVtext("MSG",
|
290
|
+
myResources.getString(R.string.measure_lead_off));
|
291
|
+
/*setTVtext(tv_MSG,
|
292
|
+
myResources.getString(R.string.measure_lead_off));*/
|
293
|
+
} else {
|
294
|
+
setTVtext("MSG", "");
|
295
|
+
//tv_MSG.setText("");
|
296
|
+
}
|
297
|
+
}
|
298
|
+
break;
|
299
|
+
case StaticReceive.MSG_DATA_GLU: {
|
300
|
+
if (msg.arg1 == 1) {
|
301
|
+
setGLU("L");
|
302
|
+
} else if (msg.arg1 == 2) {
|
303
|
+
setGLU("H");
|
304
|
+
} else if (msg.arg1 == 0) {
|
305
|
+
setGLU(((float) msg.obj) + "");
|
306
|
+
}
|
307
|
+
}
|
308
|
+
break;
|
309
|
+
case StaticReceive.MSG_DATA_NIBP_STATUS_CH: {
|
310
|
+
if (msg.arg1 == 1) {
|
311
|
+
isNIBPIng = true;
|
312
|
+
checkNIBPStatus(true);
|
313
|
+
setSYS("0");
|
314
|
+
setDIA("0");
|
315
|
+
if (!isSpo2Ing)
|
316
|
+
setPR("0");
|
317
|
+
} else if (msg.arg1 == 2) {
|
318
|
+
isNIBPIng = false;
|
319
|
+
checkNIBPStatus(false);
|
320
|
+
setSYS("0");
|
321
|
+
setDIA("0");
|
322
|
+
}
|
323
|
+
}
|
324
|
+
break;
|
325
|
+
case StaticReceive.MSG_DATA_NIBP_REALTIME: {
|
326
|
+
setSYS(msg.arg2 + "");
|
327
|
+
if (msg.arg1 == 0) {
|
328
|
+
showPulse(true);
|
329
|
+
}
|
330
|
+
//drawPC300NIBPRect.setNIBP(msg.arg2, false);
|
331
|
+
}
|
332
|
+
break;
|
333
|
+
case StaticReceive.MSG_DATA_NIBP_END: {
|
334
|
+
isNIBPIng = false;
|
335
|
+
checkNIBPStatus(false);
|
336
|
+
Bundle data = msg.getData();
|
337
|
+
data.getBoolean("bHR");
|
338
|
+
int pr = data.getInt("nPulse");
|
339
|
+
int sys = data.getInt("nSYS");
|
340
|
+
int dia = data.getInt("nDIA");
|
341
|
+
int grade = data.getInt("nGrade");
|
342
|
+
int err = data.getInt("nBPErr");
|
343
|
+
if (err == StatusMsg.NIBP_ERROR_NO_ERROR) {
|
344
|
+
setSYS(sys + "");
|
345
|
+
setDIA(dia + "");
|
346
|
+
if (!isSpo2Ing && !isECGIng) {
|
347
|
+
setPR(pr + "");
|
348
|
+
}
|
349
|
+
//drawPC300NIBPRect.setNIBP(grade, true);
|
350
|
+
} else {
|
351
|
+
setSYS("0");
|
352
|
+
setDIA("0");
|
353
|
+
if (!isSpo2Ing)
|
354
|
+
setPR("0");
|
355
|
+
if (err == 15)
|
356
|
+
err = nibpERR.length - 1;
|
357
|
+
//drawPC300NIBPRect.setNIBP(0, false);
|
358
|
+
}
|
359
|
+
}
|
360
|
+
break;
|
361
|
+
case StaticReceive.MSG_DATA_SPO2_PARA: {
|
362
|
+
Bundle d = msg.getData();
|
363
|
+
if (!isECGIng) {
|
364
|
+
//setTVtext(tv_MODE, "Pleth");
|
365
|
+
setTVtext("MODE", "Pleth");
|
366
|
+
}
|
367
|
+
if (!d.getBoolean("bProbe")) {
|
368
|
+
isSpo2Ing = false;
|
369
|
+
//drawRunablePC300.cleanWaveData();
|
370
|
+
setSPO2("");
|
371
|
+
setPR("");
|
372
|
+
} else {
|
373
|
+
isSpo2Ing = true;
|
374
|
+
setSPO2(d.getInt("nSpO2") + "");
|
375
|
+
if (!isECGIng) {
|
376
|
+
setPR(d.getInt("nPR") + "");
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
break;
|
381
|
+
case StaticReceive.MSG_DATA_TEMP: {
|
382
|
+
Bundle d = msg.getData();
|
383
|
+
if (d.getInt("nResultStatus") == 0) {
|
384
|
+
setTMP(msg.getData().getFloat("nTmp") + "");
|
385
|
+
} else if (d.getInt("nResultStatus") == 1) {
|
386
|
+
setTMP("L");
|
387
|
+
} else if (d.getInt("nResultStatus") == 2) {
|
388
|
+
setTMP("H");
|
389
|
+
}
|
390
|
+
}
|
391
|
+
break;
|
392
|
+
case RECEIVEMSG_PULSE_OFF: {
|
393
|
+
showPulse(false);
|
394
|
+
}
|
395
|
+
break;
|
396
|
+
case StaticReceive.MSG_DATA_PULSE: {
|
397
|
+
showPulse(true);
|
398
|
+
}
|
399
|
+
break;
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
};
|
404
|
+
|
405
|
+
/**
|
406
|
+
* �ı��ĵ簴ť״̬
|
407
|
+
*
|
408
|
+
* @param isStart
|
409
|
+
* ����״̬ true ���ڲ��� false û�в���
|
410
|
+
*/
|
411
|
+
private void checkECGStatus(boolean isStart) {
|
412
|
+
if (isStart) {
|
413
|
+
//bt_ECG.setText(R.string.measure_stop);
|
414
|
+
} else {
|
415
|
+
//bt_ECG.setText(R.string.measure_ecg);
|
416
|
+
}
|
417
|
+
}
|
418
|
+
|
419
|
+
/**
|
420
|
+
* �ı�Ѫѹ��ť״̬
|
421
|
+
*
|
422
|
+
* @param isStart
|
423
|
+
* ����״̬ true ���ڲ��� false û�в���
|
424
|
+
*/
|
425
|
+
private void checkNIBPStatus(boolean isStart) {
|
426
|
+
if (isStart) {
|
427
|
+
//bt_BIBP.setText(R.string.measure_stop);
|
428
|
+
} else {
|
429
|
+
//bt_BIBP.setText(R.string.measure_nibp);
|
430
|
+
}
|
431
|
+
}
|
432
|
+
|
433
|
+
/** ȡ��������� */
|
434
|
+
public static final int RECEIVEMSG_PULSE_OFF = 0x115;
|
435
|
+
|
436
|
+
/**
|
437
|
+
* �������
|
438
|
+
*/
|
439
|
+
private void showPulse(boolean isShow) {
|
440
|
+
if (isShow) {
|
441
|
+
/*img_Pulse.setVisibility(View.VISIBLE);
|
442
|
+
new Thread() {
|
443
|
+
@Override
|
444
|
+
public void run() {
|
445
|
+
super.run();
|
446
|
+
try {
|
447
|
+
Thread.sleep(50);
|
448
|
+
} catch (InterruptedException e) {
|
449
|
+
e.printStackTrace();
|
450
|
+
}
|
451
|
+
mHandler.sendEmptyMessage(RECEIVEMSG_PULSE_OFF);
|
452
|
+
}
|
453
|
+
}.start();*/
|
454
|
+
} else {
|
455
|
+
//img_Pulse.setVisibility(View.INVISIBLE);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
private int batteryCnt = 0;
|
460
|
+
|
461
|
+
private long batteryTime = 0L;
|
462
|
+
|
463
|
+
/*private void setBattery(int battery, int cell) {
|
464
|
+
if (cell == 0) {// û�г��
|
465
|
+
batteryCnt = 0;
|
466
|
+
img_Battery.setImageResource(batteryRes[battery]);
|
467
|
+
if (battery == 0) {
|
468
|
+
long time = System.currentTimeMillis();
|
469
|
+
if (time - batteryTime < 500) {
|
470
|
+
return;
|
471
|
+
}
|
472
|
+
batteryTime = time;
|
473
|
+
int visible = img_Battery.isShown() ? View.INVISIBLE
|
474
|
+
: View.VISIBLE;
|
475
|
+
img_Battery.setVisibility(visible);
|
476
|
+
} else {
|
477
|
+
img_Battery.setVisibility(View.VISIBLE);
|
478
|
+
}
|
479
|
+
} else if (cell == 1) {// �����
|
480
|
+
setImgResource(img_Battery, batteryRes_img[batteryCnt]);
|
481
|
+
batteryCnt = (batteryCnt + 1) % batteryRes_img.length;
|
482
|
+
} else if (cell == 2) {// ������
|
483
|
+
batteryCnt = 0;
|
484
|
+
setImgResource(img_Battery, batteryRes_img[2]);
|
485
|
+
}
|
486
|
+
}*/
|
487
|
+
|
488
|
+
/**
|
489
|
+
* ����ͼƬ
|
490
|
+
*
|
491
|
+
* @param img
|
492
|
+
* @param res
|
493
|
+
*/
|
494
|
+
private void setImgResource(ImageView img, int res) {
|
495
|
+
if (!img.isShown()) {
|
496
|
+
img.setVisibility(View.VISIBLE);
|
497
|
+
}
|
498
|
+
img.setImageResource(res);
|
499
|
+
}
|
500
|
+
|
501
|
+
private void setSPO2(String data) {
|
502
|
+
//setTVtext(tv_SPO, data);
|
503
|
+
setTVtext("SPO", data);
|
504
|
+
}
|
505
|
+
|
506
|
+
private void setPR(String data) {
|
507
|
+
//setTVtext(tv_PR, data);
|
508
|
+
setTVtext("PR", data);
|
509
|
+
}
|
510
|
+
|
511
|
+
private void setSYS(String data) {
|
512
|
+
//setTVtext(tv_SYS, data);
|
513
|
+
setTVtext("SYS", data);
|
514
|
+
}
|
515
|
+
|
516
|
+
private void setDIA(String data) {
|
517
|
+
//setTVtext(tv_DIA, data);
|
518
|
+
setTVtext("DIA", data);
|
519
|
+
}
|
520
|
+
|
521
|
+
private void setTMP(String itemp) {
|
522
|
+
//setTVtext(tv_TMP, itemp + "");
|
523
|
+
setTVtext("TMP", itemp + "");
|
524
|
+
}
|
525
|
+
|
526
|
+
private void setGLU(String data) {
|
527
|
+
//setTVtext(tv_GLU, data);
|
528
|
+
setTVtext("GLU", data);
|
529
|
+
}
|
530
|
+
|
531
|
+
/**
|
532
|
+
* ����TextView��ʾ������
|
533
|
+
*/
|
534
|
+
private void setTVtext(TextView tv, String msg) {
|
535
|
+
if (tv != null) {
|
536
|
+
if (msg != null) {
|
537
|
+
if (msg.equals("0") || msg.equals("") || msg.equals("0.0")) {
|
538
|
+
tv.setText(myResources
|
539
|
+
.getString(org.tharak.vital.R.string.const_data_nodata));
|
540
|
+
} else {
|
541
|
+
tv.setText(msg);
|
542
|
+
}
|
543
|
+
}
|
544
|
+
}
|
545
|
+
}
|
546
|
+
protected void postData(String tag, String data){
|
547
|
+
if(mCall != null){
|
548
|
+
PluginResult pResult = new PluginResult();
|
549
|
+
pResult.put(tag, data);
|
550
|
+
mCall.successCallback(pResult);
|
551
|
+
}else {
|
552
|
+
String callback = "javascript:window['" + mCallback + "']('" + tag + "','" + data + "')";
|
553
|
+
getBridge().getWebView().loadUrl(callback);
|
554
|
+
}
|
555
|
+
}
|
556
|
+
|
557
|
+
private void setTVtext(String tag, String msg) {
|
558
|
+
if (tag != null) {
|
559
|
+
if (msg != null) {
|
560
|
+
if (msg.equals("0") || msg.equals("") || msg.equals("0.0")) {
|
561
|
+
postData(tag, myResources
|
562
|
+
.getString(org.tharak.vital.R.string.const_data_nodata));
|
563
|
+
} else {
|
564
|
+
postData(tag, msg);
|
565
|
+
}
|
566
|
+
}
|
567
|
+
}
|
568
|
+
}
|
569
|
+
@Override
|
570
|
+
public void onPause() {
|
571
|
+
super.onPause();
|
572
|
+
/*if (drawThread != null && !drawRunablePC300.isPause()) {
|
573
|
+
drawRunablePC300.Pause();
|
574
|
+
}*/
|
575
|
+
/*if (drawPC300SPO2RectThread != null && !drawPC300SPO2Rect.isPause()) {
|
576
|
+
drawPC300SPO2Rect.Pause();
|
577
|
+
}*/
|
578
|
+
}
|
579
|
+
|
580
|
+
@Override
|
581
|
+
public void onResume() {
|
582
|
+
super.onResume();
|
583
|
+
/*if (drawThread == null) {
|
584
|
+
drawThread = new Thread(drawRunablePC300, "DrawPC300Thread");
|
585
|
+
drawThread.start();
|
586
|
+
} else if (drawRunablePC300.isPause()) {
|
587
|
+
drawRunablePC300.Continue();
|
588
|
+
}*/
|
589
|
+
/*if (drawPC300SPO2RectThread == null) {
|
590
|
+
drawPC300SPO2RectThread = new Thread(drawPC300SPO2Rect,
|
591
|
+
"DrawPC300RectThread");
|
592
|
+
drawPC300SPO2RectThread.start();
|
593
|
+
} else if (drawPC300SPO2Rect.isPause()) {
|
594
|
+
drawPC300SPO2Rect.Continue();
|
595
|
+
}*/
|
596
|
+
}
|
597
|
+
|
598
|
+
@Override
|
599
|
+
public void onDestroy() {
|
600
|
+
super.onDestroy();
|
601
|
+
sendBroadcast(new Intent(ReceiveService.BLU_ACTION_DISCONNECT));
|
602
|
+
/*if (!drawRunablePC300.isStop()) {
|
603
|
+
drawRunablePC300.Stop();
|
604
|
+
}*/
|
605
|
+
//drawThread = null;
|
606
|
+
/*if (!drawPC300SPO2Rect.isStop()) {
|
607
|
+
drawPC300SPO2Rect.Stop();
|
608
|
+
}*/
|
609
|
+
//drawPC300SPO2RectThread = null;
|
610
|
+
stopService(new Intent(this, ReceiveService.class));
|
611
|
+
}
|
612
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
package org.thiragatisoft.core;
|
2
|
+
|
3
|
+
import com.getcapacitor.NativePlugin;
|
4
|
+
import com.getcapacitor.Plugin;
|
5
|
+
import com.getcapacitor.PluginCall;
|
6
|
+
import com.getcapacitor.PluginMethod;
|
7
|
+
|
8
|
+
@NativePlugin
|
9
|
+
public class VitalsPlugin extends Plugin {
|
10
|
+
@PluginMethod(returnType=PluginMethod.RETURN_CALLBACK)
|
11
|
+
public void searchDevice(PluginCall call) {
|
12
|
+
VitalActivity activity = (VitalActivity)this.getActivity();
|
13
|
+
activity.searchDevice2(call);
|
14
|
+
}
|
15
|
+
}
|