@@ -33,13 +33,18 @@ public class ImageLoadEvent extends Event<ImageLoadEvent> {
33
33
private final @ Nullable String mImageUri ;
34
34
private final int mWidth ;
35
35
private final int mHeight ;
36
+ private final @ Nullable String mImageError ;
36
37
37
38
public ImageLoadEvent (int viewId , @ ImageEventType int eventType ) {
38
39
this (viewId , eventType , null );
39
40
}
40
41
42
+ public ImageLoadEvent (int viewId , @ ImageEventType int eventType , boolean error , String message ) {
43
+ this (viewId , eventType , null , 0 , 0 , message );
44
+ }
45
+
41
46
public ImageLoadEvent (int viewId , @ ImageEventType int eventType , String imageUri ) {
42
- this (viewId , eventType , imageUri , 0 , 0 );
47
+ this (viewId , eventType , imageUri , 0 , 0 , null );
43
48
}
44
49
45
50
public ImageLoadEvent (
@@ -48,11 +53,22 @@ public ImageLoadEvent(
48
53
@ Nullable String imageUri ,
49
54
int width ,
50
55
int height ) {
56
+ this (viewId , eventType , imageUri , width , height , null );
57
+ }
58
+
59
+ public ImageLoadEvent (
60
+ int viewId ,
61
+ @ ImageEventType int eventType ,
62
+ @ Nullable String imageUri ,
63
+ int width ,
64
+ int height ,
65
+ @ Nullable String message ) {
51
66
super (viewId );
52
67
mEventType = eventType ;
53
68
mImageUri = imageUri ;
54
69
mWidth = width ;
55
70
mHeight = height ;
71
+ mImageError = message ;
56
72
}
57
73
58
74
public static String eventNameForType (@ ImageEventType int eventType ) {
@@ -88,7 +104,7 @@ public short getCoalescingKey() {
88
104
public void dispatch (RCTEventEmitter rctEventEmitter ) {
89
105
WritableMap eventData = null ;
90
106
91
- if (mImageUri != null || mEventType == ON_LOAD ) {
107
+ if (mImageUri != null || ( mEventType == ON_LOAD || mEventType == ON_ERROR ) ) {
92
108
eventData = Arguments .createMap ();
93
109
94
110
if (mImageUri != null ) {
@@ -103,6 +119,8 @@ public void dispatch(RCTEventEmitter rctEventEmitter) {
103
119
source .putString ("url" , mImageUri );
104
120
}
105
121
eventData .putMap ("source" , source );
122
+ } else if (mEventType == ON_ERROR ) {
123
+ eventData .putString ("error" , mImageError );
106
124
}
107
125
}
108
126
0 commit comments