forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRCTImageResponseObserverProxy.mm
More file actions
47 lines (39 loc) · 1.22 KB
/
RCTImageResponseObserverProxy.mm
File metadata and controls
47 lines (39 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "RCTImageResponseObserverProxy.h"
#import <react/imagemanager/ImageResponse.h>
#import <react/imagemanager/ImageResponseObserver.h>
namespace facebook {
namespace react {
RCTImageResponseObserverProxy::RCTImageResponseObserverProxy(void *delegate)
: delegate_((__bridge id<RCTImageResponseDelegate>)delegate)
{
}
void RCTImageResponseObserverProxy::didReceiveImage(const ImageResponse &imageResponse)
{
UIImage *image = (__bridge UIImage *)imageResponse.getImage().get();
void *this_ = this;
dispatch_async(dispatch_get_main_queue(), ^{
[delegate_ didReceiveImage:image fromObserver:this_];
});
}
void RCTImageResponseObserverProxy::didReceiveProgress(float p)
{
void *this_ = this;
dispatch_async(dispatch_get_main_queue(), ^{
[delegate_ didReceiveProgress:p fromObserver:this_];
});
}
void RCTImageResponseObserverProxy::didReceiveFailure()
{
void *this_ = this;
dispatch_async(dispatch_get_main_queue(), ^{
[delegate_ didReceiveFailureFromObserver:this_];
});
}
} // namespace react
} // namespace facebook