@@ -152,36 +152,7 @@ public void onCancel(DialogInterface dialog) {
152
152
public void launchCamera (final ReadableMap options , final Callback callback ) {
153
153
response = Arguments .createMap ();
154
154
155
- if (options .hasKey ("noData" )) {
156
- noData = options .getBoolean ("noData" );
157
- }
158
- if (options .hasKey ("maxWidth" )) {
159
- maxWidth = options .getInt ("maxWidth" );
160
- }
161
- if (options .hasKey ("maxHeight" )) {
162
- maxHeight = options .getInt ("maxHeight" );
163
- }
164
- if (options .hasKey ("aspectX" )) {
165
- aspectX = options .getInt ("aspectX" );
166
- }
167
- if (options .hasKey ("aspectY" )) {
168
- aspectY = options .getInt ("aspectY" );
169
- }
170
- if (options .hasKey ("quality" )) {
171
- quality = (int )(options .getDouble ("quality" ) * 100 );
172
- }
173
- tmpImage = true ;
174
- if (options .hasKey ("storageOptions" )) {
175
- tmpImage = false ;
176
- }
177
- if (options .hasKey ("allowsEditing" )) {
178
- allowEditing = options .getBoolean ("allowsEditing" );
179
- }
180
- forceAngle = false ;
181
- if (options .hasKey ("angle" )) {
182
- forceAngle = true ;
183
- angle = options .getInt ("angle" );
184
- }
155
+ parseOptions (options );
185
156
186
157
Intent cameraIntent = new Intent (MediaStore .ACTION_IMAGE_CAPTURE );
187
158
if (cameraIntent .resolveActivity (mReactContext .getPackageManager ()) == null ) {
@@ -221,36 +192,7 @@ public void launchCamera(final ReadableMap options, final Callback callback) {
221
192
public void launchImageLibrary (final ReadableMap options , final Callback callback ) {
222
193
response = Arguments .createMap ();
223
194
224
- if (options .hasKey ("noData" )) {
225
- noData = options .getBoolean ("noData" );
226
- }
227
- if (options .hasKey ("maxWidth" )) {
228
- maxWidth = options .getInt ("maxWidth" );
229
- }
230
- if (options .hasKey ("maxHeight" )) {
231
- maxHeight = options .getInt ("maxHeight" );
232
- }
233
- if (options .hasKey ("aspectX" )) {
234
- aspectX = options .getInt ("aspectX" );
235
- }
236
- if (options .hasKey ("aspectY" )) {
237
- aspectY = options .getInt ("aspectY" );
238
- }
239
- if (options .hasKey ("quality" )) {
240
- quality = (int )(options .getDouble ("quality" ) * 100 );
241
- }
242
- tmpImage = true ;
243
- if (options .hasKey ("storageOptions" )) {
244
- tmpImage = false ;
245
- }
246
- if (options .hasKey ("allowsEditing" )) {
247
- allowEditing = options .getBoolean ("allowsEditing" );
248
- }
249
- forceAngle = false ;
250
- if (options .hasKey ("angle" )) {
251
- forceAngle = true ;
252
- angle = options .getInt ("angle" );
253
- }
195
+ parseOptions (options );
254
196
255
197
Intent libraryIntent = new Intent (Intent .ACTION_PICK ,
256
198
android .provider .MediaStore .Images .Media .EXTERNAL_CONTENT_URI );
@@ -567,4 +509,37 @@ private File createNewFile() {
567
509
return f ;
568
510
}
569
511
}
512
+
513
+ private void parseOptions (final ReadableMap options ) {
514
+ if (options .hasKey ("noData" )) {
515
+ noData = options .getBoolean ("noData" );
516
+ }
517
+ if (options .hasKey ("maxWidth" )) {
518
+ maxWidth = options .getInt ("maxWidth" );
519
+ }
520
+ if (options .hasKey ("maxHeight" )) {
521
+ maxHeight = options .getInt ("maxHeight" );
522
+ }
523
+ if (options .hasKey ("aspectX" )) {
524
+ aspectX = options .getInt ("aspectX" );
525
+ }
526
+ if (options .hasKey ("aspectY" )) {
527
+ aspectY = options .getInt ("aspectY" );
528
+ }
529
+ if (options .hasKey ("quality" )) {
530
+ quality = (int )(options .getDouble ("quality" ) * 100 );
531
+ }
532
+ tmpImage = true ;
533
+ if (options .hasKey ("storageOptions" )) {
534
+ tmpImage = false ;
535
+ }
536
+ if (options .hasKey ("allowsEditing" )) {
537
+ allowEditing = options .getBoolean ("allowsEditing" );
538
+ }
539
+ forceAngle = false ;
540
+ if (options .hasKey ("angle" )) {
541
+ forceAngle = true ;
542
+ angle = options .getInt ("angle" );
543
+ }
544
+ }
570
545
}
0 commit comments