File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ function getSDK() {
11
11
return SDK_INT ;
12
12
}
13
13
function getSVG ( src : string | ImageAsset | File ) {
14
+ if ( ! src ) {
15
+ return null ;
16
+ }
14
17
let imagePath : string ;
15
18
if ( src instanceof File ) {
16
19
return com . caverock . androidsvg . SVG . getFromInputStream ( new java . io . FileInputStream ( new java . io . File ( src . path ) ) ) ;
@@ -402,12 +405,20 @@ export class SVGView extends SVGViewBase {
402
405
}
403
406
async handleSrc ( src ) {
404
407
if ( src instanceof Promise ) {
405
- this . handleSrc ( await src ) ;
408
+ try {
409
+ this . handleSrc ( await src ) ;
410
+ } catch ( error ) {
411
+ this . handleSrc ( null ) ;
412
+ }
406
413
return ;
407
414
} else if ( typeof src === 'function' ) {
408
- const newSrc = src ( ) ;
415
+ let newSrc = src ( ) ;
409
416
if ( newSrc instanceof Promise ) {
410
- await newSrc ;
417
+ try {
418
+ await newSrc ;
419
+ } catch ( error ) {
420
+ newSrc = null ;
421
+ }
411
422
}
412
423
this . handleSrc ( newSrc ) ;
413
424
return ;
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ function getUIImageScaleType(scaleType: string) {
21
21
22
22
let bgdImagePaint : Paint ;
23
23
function getRenderer ( src : string | ImageAsset | File ) {
24
+ if ( ! src ) {
25
+ return null ;
26
+ }
24
27
let imagePath : string ;
25
28
if ( src instanceof File ) {
26
29
return SVGRenderer . alloc ( ) . initWithInputStream ( NSInputStream . alloc ( ) . initWithFileAtPath ( src . path ) ) ;
@@ -45,6 +48,9 @@ function getRenderer(src: string | ImageAsset | File) {
45
48
return SVGRenderer . alloc ( ) . initWithString ( imagePath ) ;
46
49
}
47
50
function getSVGKImage ( src : string | ImageAsset | File ) {
51
+ if ( ! src ) {
52
+ return null ;
53
+ }
48
54
let imagePath : string ;
49
55
if ( src instanceof File ) {
50
56
return SVGKImage . alloc ( ) . initWithData ( NSData . alloc ( ) . initWithContentsOfFile ( src . path ) ) ;
@@ -322,12 +328,20 @@ export class SVGView extends SVGViewBase {
322
328
}
323
329
async handleSrc ( src ) {
324
330
if ( src instanceof Promise ) {
325
- this . handleSrc ( await src ) ;
331
+ try {
332
+ this . handleSrc ( await src ) ;
333
+ } catch ( error ) {
334
+ this . handleSrc ( null ) ;
335
+ }
326
336
return ;
327
337
} else if ( typeof src === 'function' ) {
328
- const newSrc = src ( ) ;
338
+ let newSrc = src ( ) ;
329
339
if ( newSrc instanceof Promise ) {
330
- await newSrc ;
340
+ try {
341
+ await newSrc ;
342
+ } catch ( error ) {
343
+ newSrc = null ;
344
+ }
331
345
}
332
346
this . handleSrc ( newSrc ) ;
333
347
return ;
You can’t perform that action at this time.
0 commit comments