react-native-mytatva-rn-sdk 1.2.50 → 1.2.52

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.
Files changed (27) hide show
  1. package/android/src/main/java/cgmblelib/base/BApplication.java +57 -57
  2. package/android/src/main/java/cgmblelib/ble/BleService.java +1 -1
  3. package/android/src/main/java/cgmblelib/ble/gattcallback/BleGattCallback.java +1 -1
  4. package/android/src/main/java/cgmblelib/database/dao/DaoDevice.java +4 -0
  5. package/android/src/main/java/cgmblelib/database/dao/DaoGlucose.java +334 -332
  6. package/android/src/main/java/cgmblelib/database/repository/RepositoryDevice.java +5 -0
  7. package/android/src/main/java/cgmblelib/database/repository/RepositoryGlucose.java +167 -162
  8. package/android/src/main/java/cgmblelib/database/source/SourceDevice.java +2 -0
  9. package/android/src/main/java/cgmblelib/database/source/SourceGlucose.java +2 -0
  10. package/android/src/main/java/cgmblelib/database/source/db/DeviceDBDataSource.java +171 -165
  11. package/android/src/main/java/cgmblelib/database/source/db/GlucoseDBDataSource.java +305 -296
  12. package/android/src/main/java/cgmblelib/utils/SharedPreferencesLibraryUtil.java +66 -44
  13. package/android/src/main/java/com/mytatvarnsdk/CgmTrackyLibModule.kt +13 -9
  14. package/android/src/main/java/com/mytatvarnsdk/MainApplication.kt +2 -2
  15. package/android/src/main/java/com/mytatvarnsdk/activity/PermissionActivity.kt +10 -4
  16. package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +5 -1
  17. package/android/src/main/java/com/mytatvarnsdk/model/BaseViewModel.java +88 -84
  18. package/ios/Database/KLTBluetoothManager.m +4 -0
  19. package/ios/Database/KLTDatabaseHandler.m +77 -7
  20. package/ios/ViewModel/FinalViewModel.swift +6 -1
  21. package/lib/commonjs/CGMConnect.js +2 -2
  22. package/lib/commonjs/CGMConnect.js.map +1 -1
  23. package/lib/module/CGMConnect.js +3 -3
  24. package/lib/module/CGMConnect.js.map +1 -1
  25. package/lib/typescript/CGMConnect.d.ts +2 -2
  26. package/package.json +1 -1
  27. package/src/CGMConnect.ts +63 -54
@@ -24,171 +24,177 @@ import ist.com.sdk.EDevice;
24
24
  * @author minyuchun
25
25
  */
26
26
  public class DeviceDBDataSource extends DBDataSource implements SourceDevice {
27
- /**
28
- * 持久化 -- 单例
29
- */
30
- private static volatile DeviceDBDataSource INSTANCE;
31
- /**
32
- * dao
33
- */
34
- private DaoDevice mDaoDevice;
35
- /***
36
- * 线程池
37
- */
38
- private AppExecutors mAppExecutors;
39
-
40
-
41
- private DeviceDBDataSource(@NonNull AppExecutors appExecutors,
42
- @NonNull DaoDevice daoDevice) {
43
- mAppExecutors = appExecutors;
44
- mDaoDevice = daoDevice;
45
- }
46
-
47
-
48
- public static DeviceDBDataSource getInstance(@NonNull AppExecutors appExecutors, @NonNull DaoDevice daoDevice) {
49
- if (INSTANCE == null) {
50
- synchronized (DeviceDBDataSource.class) {
27
+ /**
28
+ * 持久化 -- 单例
29
+ */
30
+ private static volatile DeviceDBDataSource INSTANCE;
31
+ /**
32
+ * dao
33
+ */
34
+ private DaoDevice mDaoDevice;
35
+ /***
36
+ * 线程池
37
+ */
38
+ private AppExecutors mAppExecutors;
39
+
40
+
41
+ private DeviceDBDataSource(@NonNull AppExecutors appExecutors,
42
+ @NonNull DaoDevice daoDevice) {
43
+ mAppExecutors = appExecutors;
44
+ mDaoDevice = daoDevice;
45
+ }
46
+
47
+
48
+ public static DeviceDBDataSource getInstance(@NonNull AppExecutors appExecutors, @NonNull DaoDevice daoDevice) {
51
49
  if (INSTANCE == null) {
52
- INSTANCE = new DeviceDBDataSource(appExecutors, daoDevice);
50
+ synchronized (DeviceDBDataSource.class) {
51
+ if (INSTANCE == null) {
52
+ INSTANCE = new DeviceDBDataSource(appExecutors, daoDevice);
53
+ }
54
+ }
55
+ }
56
+ return INSTANCE;
57
+ }
58
+
59
+ @Override
60
+ public long insertDeviceIoThread(PocDevice device) {
61
+ try {
62
+ CheckIoThread();
63
+ return mDaoDevice.insert(device);
64
+ } catch (Exception e) {
65
+ e.printStackTrace();
53
66
  }
54
- }
55
- }
56
- return INSTANCE;
57
- }
58
-
59
- @Override
60
- public long insertDeviceIoThread(PocDevice device) {
61
- try {
62
- CheckIoThread();
63
- return mDaoDevice.insert(device);
64
- } catch (Exception e) {
65
- e.printStackTrace();
66
- }
67
- return 0;
68
- }
69
-
70
- @Override
71
- public long insertDeviceIoThread(String address, String name) {
72
- try {
73
- CheckIoThread();
74
- PocDevice mPocBoundDevice = new PocDevice();
75
- mPocBoundDevice.setAddress(address);
76
- mPocBoundDevice.setName(name);
77
- Date date = new Date();
78
- mPocBoundDevice.setBindDate(date);
79
- mPocBoundDevice.setConnectDate(date);
80
- SharedPreferencesLibraryUtil sharedPreferencesLibraryUtil = new SharedPreferencesLibraryUtil(BApplication.getContext());
81
- QRInformation qrInformation = sharedPreferencesLibraryUtil.getQRInformation();
82
- int algorithm = EDevice.getEnumDevice(name).getAlgorithm();
83
- mPocBoundDevice.setAlgorithmVersion(algorithm);
84
- QRInformation information = sharedPreferencesLibraryUtil.getQRInformation();
85
- EDevice eDevice = EDevice.getEnumDevice(name);
86
- if (information != null && information.isEffective(name, information.getR(), information.getK())) {
87
- mPocBoundDevice.setQrMessage(information.getQRMessage());
88
- }
89
- mPocBoundDevice.setInitCount(eDevice.getInitNumber());
90
- mPocBoundDevice.setEndCount(eDevice.getEndNumber());
91
- return insertDeviceIoThread(mPocBoundDevice);
92
- } catch (Exception e) {
93
- e.printStackTrace();
94
- }
95
- return 0;
96
- }
97
-
98
- @Override
99
- public void deleteDevice(PocDevice device) {
100
- Runnable deleteRunnable = () -> mDaoDevice.delete(device);
101
- mAppExecutors.diskIO().execute(deleteRunnable);
102
- }
103
-
104
- @Override
105
- public void deleteAllDevices() {
106
- throw new UnsupportedOperationException("TBD");
107
- }
108
-
109
- @Override
110
- public void updateDevice(PocDevice device) {
111
- Runnable updateRunnable = () -> mDaoDevice.update(device);
112
- mAppExecutors.diskIO().execute(updateRunnable);
113
- }
114
-
115
- @Override
116
- public int updateDeviceIoThread(PocDevice device) {
117
- try {
118
- CheckIoThread();
119
- return mDaoDevice.update(device);
120
- } catch (Exception e) {
121
- e.printStackTrace();
122
- }
123
- return 0;
124
- }
125
-
126
- @Override
127
- public PocDevice getLatestDeviceIoThread() {
128
- try {
129
- CheckIoThread();
130
- return mDaoDevice.getLatestDevice();
131
- } catch (Exception e) {
132
- e.printStackTrace();
133
- }
134
- return null;
135
- }
136
-
137
-
138
- @Override
139
- public PocDevice getLatestDeviceIoThread(String address) {
140
- try {
141
- CheckIoThread();
142
- return mDaoDevice.getLatestDeviceByAddress(address);
143
- } catch (Exception e) {
144
- e.printStackTrace();
145
- }
146
- return null;
147
- }
148
-
149
- @Override
150
- public LiveData<PocDevice> getLiveDataLatestDeviceIoThread() {
151
- return mDaoDevice.getLiveDataLatestDevice();
152
- }
153
-
154
- @Override
155
- public PocDevice getDeviceByIdIoThread(int deviceId) {
156
- try {
157
- CheckIoThread();
158
- return mDaoDevice.getDeviceById(deviceId);
159
- } catch (Exception e) {
160
- e.printStackTrace();
161
- }
162
- return null;
163
- }
164
-
165
- @Override
166
- public List<PocDevice> getDeviceListGroupByAddressIoThread() {
167
- try {
168
- CheckIoThread();
169
- return mDaoDevice.getDifferentAddressDevices();
170
- } catch (Exception e) {
171
- e.printStackTrace();
172
- }
173
- return null;
174
- }
175
-
176
- @Override
177
- public List<PocDevice> getDeviceListByAddressIoThread(@NonNull String address) {
178
- try {
179
- CheckIoThread();
180
- return mDaoDevice.getDifferentDateDevicesByAddress(address);
181
- } catch (Exception e) {
182
- e.printStackTrace();
183
- }
184
- return null;
185
- }
186
-
187
- @Override
188
- public void getLatestFlowableDevice(Consumer<PocDevice> consumer) {
189
- mDaoDevice.getFlowableLatestDevice()
190
- .subscribeOn(Schedulers.io())
191
- .observeOn(AndroidSchedulers.mainThread())
192
- .subscribe(consumer);
193
- }
67
+ return 0;
68
+ }
69
+
70
+ @Override
71
+ public long insertDeviceIoThread(String address, String name) {
72
+ try {
73
+ CheckIoThread();
74
+ PocDevice mPocBoundDevice = new PocDevice();
75
+ mPocBoundDevice.setAddress(address);
76
+ mPocBoundDevice.setName(name);
77
+ Date date = new Date();
78
+ mPocBoundDevice.setBindDate(date);
79
+ mPocBoundDevice.setConnectDate(date);
80
+ SharedPreferencesLibraryUtil sharedPreferencesLibraryUtil = new SharedPreferencesLibraryUtil(BApplication.getContext());
81
+ QRInformation qrInformation = sharedPreferencesLibraryUtil.getQRInformation();
82
+ int algorithm = EDevice.getEnumDevice(name).getAlgorithm();
83
+ mPocBoundDevice.setAlgorithmVersion(algorithm);
84
+ QRInformation information = sharedPreferencesLibraryUtil.getQRInformation();
85
+ EDevice eDevice = EDevice.getEnumDevice(name);
86
+ if (information != null && information.isEffective(name, information.getR(), information.getK())) {
87
+ mPocBoundDevice.setQrMessage(information.getQRMessage());
88
+ }
89
+ mPocBoundDevice.setInitCount(eDevice.getInitNumber());
90
+ mPocBoundDevice.setEndCount(eDevice.getEndNumber());
91
+ return insertDeviceIoThread(mPocBoundDevice);
92
+ } catch (Exception e) {
93
+ e.printStackTrace();
94
+ }
95
+ return 0;
96
+ }
97
+
98
+ @Override
99
+ public void deleteDevice(PocDevice device) {
100
+ Runnable deleteRunnable = () -> mDaoDevice.delete(device);
101
+ mAppExecutors.diskIO().execute(deleteRunnable);
102
+ }
103
+
104
+ @Override
105
+ public void deleteAllDevices() {
106
+ throw new UnsupportedOperationException("TBD");
107
+ }
108
+
109
+ @Override
110
+ public void deleteAllDeviceData() {
111
+ Runnable deleteRunnable = () -> mDaoDevice.clearDeviceTable();
112
+ mAppExecutors.diskIO().execute(deleteRunnable);
113
+ }
114
+
115
+ @Override
116
+ public void updateDevice(PocDevice device) {
117
+ Runnable updateRunnable = () -> mDaoDevice.update(device);
118
+ mAppExecutors.diskIO().execute(updateRunnable);
119
+ }
120
+
121
+ @Override
122
+ public int updateDeviceIoThread(PocDevice device) {
123
+ try {
124
+ CheckIoThread();
125
+ return mDaoDevice.update(device);
126
+ } catch (Exception e) {
127
+ e.printStackTrace();
128
+ }
129
+ return 0;
130
+ }
131
+
132
+ @Override
133
+ public PocDevice getLatestDeviceIoThread() {
134
+ try {
135
+ CheckIoThread();
136
+ return mDaoDevice.getLatestDevice();
137
+ } catch (Exception e) {
138
+ e.printStackTrace();
139
+ }
140
+ return null;
141
+ }
142
+
143
+
144
+ @Override
145
+ public PocDevice getLatestDeviceIoThread(String address) {
146
+ try {
147
+ CheckIoThread();
148
+ return mDaoDevice.getLatestDeviceByAddress(address);
149
+ } catch (Exception e) {
150
+ e.printStackTrace();
151
+ }
152
+ return null;
153
+ }
154
+
155
+ @Override
156
+ public LiveData<PocDevice> getLiveDataLatestDeviceIoThread() {
157
+ return mDaoDevice.getLiveDataLatestDevice();
158
+ }
159
+
160
+ @Override
161
+ public PocDevice getDeviceByIdIoThread(int deviceId) {
162
+ try {
163
+ CheckIoThread();
164
+ return mDaoDevice.getDeviceById(deviceId);
165
+ } catch (Exception e) {
166
+ e.printStackTrace();
167
+ }
168
+ return null;
169
+ }
170
+
171
+ @Override
172
+ public List<PocDevice> getDeviceListGroupByAddressIoThread() {
173
+ try {
174
+ CheckIoThread();
175
+ return mDaoDevice.getDifferentAddressDevices();
176
+ } catch (Exception e) {
177
+ e.printStackTrace();
178
+ }
179
+ return null;
180
+ }
181
+
182
+ @Override
183
+ public List<PocDevice> getDeviceListByAddressIoThread(@NonNull String address) {
184
+ try {
185
+ CheckIoThread();
186
+ return mDaoDevice.getDifferentDateDevicesByAddress(address);
187
+ } catch (Exception e) {
188
+ e.printStackTrace();
189
+ }
190
+ return null;
191
+ }
192
+
193
+ @Override
194
+ public void getLatestFlowableDevice(Consumer<PocDevice> consumer) {
195
+ mDaoDevice.getFlowableLatestDevice()
196
+ .subscribeOn(Schedulers.io())
197
+ .observeOn(AndroidSchedulers.mainThread())
198
+ .subscribe(consumer);
199
+ }
194
200
  }