mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Added lightweight generic annotations
Summary: public Added lightweight genarics annotations to make the code more readable and help the compiler catch bugs. Fixed some type bugs and improved bridge validation in a few places. Reviewed By: javache Differential Revision: D2600189 fb-gh-sync-id: f81e22f2cdc107bf8d0b15deec6d5b83aacc5b56
This commit is contained in:
committed by
facebook-github-bot-7
parent
31565781f2
commit
c5b990f65f
@@ -42,8 +42,8 @@ RCT_EXPORT_MODULE()
|
||||
if (imageCount > 1) {
|
||||
|
||||
NSTimeInterval duration = 0;
|
||||
NSMutableArray *delays = [NSMutableArray arrayWithCapacity:imageCount];
|
||||
NSMutableArray *images = [NSMutableArray arrayWithCapacity:imageCount];
|
||||
NSMutableArray<NSNumber *> *delays = [NSMutableArray arrayWithCapacity:imageCount];
|
||||
NSMutableArray<id /* CGIMageRef */> *images = [NSMutableArray arrayWithCapacity:imageCount];
|
||||
for (size_t i = 0; i < imageCount; i++) {
|
||||
|
||||
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(imageSource, i, NULL);
|
||||
@@ -75,7 +75,7 @@ RCT_EXPORT_MODULE()
|
||||
}
|
||||
CFRelease(imageSource);
|
||||
|
||||
NSMutableArray *keyTimes = [NSMutableArray arrayWithCapacity:delays.count];
|
||||
NSMutableArray<NSNumber *> *keyTimes = [NSMutableArray arrayWithCapacity:delays.count];
|
||||
NSTimeInterval runningDuration = 0;
|
||||
for (NSNumber *delayNumber in delays) {
|
||||
[keyTimes addObject:@(runningDuration / duration)];
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
|
||||
@implementation RCTImageLoader
|
||||
{
|
||||
NSArray *_loaders;
|
||||
NSArray *_decoders;
|
||||
NSArray<id<RCTImageURLLoader>> *_loaders;
|
||||
NSArray<id<RCTImageDataDecoder>> *_decoders;
|
||||
NSURLCache *_cache;
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ RCT_EXPORT_MODULE()
|
||||
- (void)setBridge:(RCTBridge *)bridge
|
||||
{
|
||||
// Get image loaders and decoders
|
||||
NSMutableArray *loaders = [NSMutableArray array];
|
||||
NSMutableArray *decoders = [NSMutableArray array];
|
||||
NSMutableArray<id<RCTImageURLLoader>> *loaders = [NSMutableArray array];
|
||||
NSMutableArray<id<RCTImageDataDecoder>> *decoders = [NSMutableArray array];
|
||||
for (id<RCTBridgeModule> module in bridge.modules.allValues) {
|
||||
if ([module conformsToProtocol:@protocol(RCTImageURLLoader)]) {
|
||||
[loaders addObject:module];
|
||||
[loaders addObject:(id<RCTImageURLLoader>)module];
|
||||
}
|
||||
if ([module conformsToProtocol:@protocol(RCTImageDataDecoder)]) {
|
||||
[decoders addObject:module];
|
||||
[decoders addObject:(id<RCTImageDataDecoder>)module];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user