@@ -94,6 +94,7 @@ public void update(
94
94
}
95
95
} catch (JSONException e ) {
96
96
e .printStackTrace ();
97
+ returnError (e .getMessage ());
97
98
}
98
99
}
99
100
@@ -103,6 +104,7 @@ public void initSdk(String license) {
103
104
AnylineSdk .init (license , reactContext );
104
105
} catch (LicenseException e ) {
105
106
e .printStackTrace ();
107
+ returnError (e .getMessage ());
106
108
}
107
109
}
108
110
@@ -160,36 +162,34 @@ private void routeScanMode(String scanMode) {
160
162
private void scanAnyline4 () {
161
163
try {
162
164
configObject = new JSONObject (this .config );
163
- // JSONObject options = configObject;
164
165
if (configObject != null ) {
165
166
scan ();
166
167
} else {
167
168
returnError ("No ViewPlugin in config. Please check your configuration." );
168
169
}
170
+ } catch (LicenseException e ) {
171
+ e .printStackTrace ();
172
+ returnError ("LICENSE ERROR: " + e .getMessage ());
169
173
} catch (JSONException e ) {
170
174
e .printStackTrace ();
175
+ returnError ("JSON ERROR: " + e .getMessage ());
171
176
}
172
177
}
173
178
174
- private void scan () {
179
+ private void scan () throws LicenseException , JSONException {
175
180
176
181
Intent intent = new Intent (getCurrentActivity (), ScanActivity .class );
177
182
178
- try {
179
- configObject = new JSONObject (this .config );
180
-
181
- license = configObject .get ("license" ).toString ();
182
- JSONObject optionsJSONObject = configObject .optJSONObject ("options" );
183
+ configObject = new JSONObject (this .config );
183
184
184
- if (optionsJSONObject != null ) {
185
- intent .putExtra (
186
- EXTRA_ENABLE_BARCODE_SCANNING ,
187
- optionsJSONObject .optBoolean ("nativeBarcodeEnabled" , false )
188
- );
189
- }
185
+ license = configObject .get ("license" ).toString ();
186
+ JSONObject optionsJSONObject = configObject .optJSONObject ("options" );
190
187
191
- } catch (JSONException e ) {
192
- returnError ("JSON ERROR: " + e .getMessage ());
188
+ if (optionsJSONObject != null ) {
189
+ intent .putExtra (
190
+ EXTRA_ENABLE_BARCODE_SCANNING ,
191
+ optionsJSONObject .optBoolean ("nativeBarcodeEnabled" , false )
192
+ );
193
193
}
194
194
195
195
intent .putExtra (EXTRA_LICENSE_KEY , license );
@@ -198,13 +198,7 @@ private void scan() {
198
198
ResultReporter .setListener (this );
199
199
intent .setFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
200
200
201
- try {
202
- AnylineSdk .init (configObject .getString ("license" ), reactContext );
203
- } catch (LicenseException e ) {
204
- e .printStackTrace ();
205
- } catch (JSONException e ) {
206
- e .printStackTrace ();
207
- }
201
+ AnylineSdk .init (configObject .getString ("license" ), reactContext );
208
202
reactContext .startActivityForResult (intent , 1111 , intent .getExtras ());
209
203
}
210
204
0 commit comments