feat:iOS load Resource use NSDictionary
This commit is contained in:
parent
e270b9c520
commit
7978900a4f
@ -25,8 +25,6 @@
|
||||
|
||||
- (void)unRegisterLoader:(id <DoricResourceLoader>)loader;
|
||||
|
||||
- (__kindof DoricResource *)load:(NSString *)resId
|
||||
withIdentifier:(NSString *)identifier
|
||||
withResourceType:(NSString *)resourceType
|
||||
- (__kindof DoricResource *)load:(NSDictionary *)resource
|
||||
withContext:(DoricContext *)context;
|
||||
@end
|
||||
|
@ -49,20 +49,21 @@ - (void)unRegisterLoader:(id <DoricResourceLoader>)loader {
|
||||
});
|
||||
}
|
||||
|
||||
- (__kindof DoricResource *)load:(NSString *)resId
|
||||
withIdentifier:(NSString *)identifier
|
||||
withResourceType:(NSString *)resourceType
|
||||
- (__kindof DoricResource *)load:(NSDictionary *)resource
|
||||
withContext:(DoricContext *)context {
|
||||
__block __kindof DoricResource *resource;
|
||||
NSString *type = resource[@"type"];
|
||||
NSString *identifier = resource[@"identifier"];
|
||||
NSString *resId = resource[@"resId"];
|
||||
__block __kindof DoricResource *doricResource;
|
||||
dispatch_sync(self.mapQueue, ^() {
|
||||
resource = [self.cachedResources objectForKey:resId];
|
||||
if (!resource) {
|
||||
id <DoricResourceLoader> loader = self.loaders[resourceType];
|
||||
resource = [loader load:identifier withContext:context];
|
||||
[self.cachedResources setObject:resource forKey:resId];
|
||||
doricResource = [self.cachedResources objectForKey:resId];
|
||||
if (!doricResource) {
|
||||
id <DoricResourceLoader> loader = self.loaders[type];
|
||||
doricResource = [loader load:identifier withContext:context];
|
||||
[self.cachedResources setObject:doricResource forKey:resId];
|
||||
}
|
||||
});
|
||||
return resource;
|
||||
return doricResource;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -236,13 +236,8 @@ - (UIImage *)currentErrorImage {
|
||||
|
||||
- (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id)prop {
|
||||
if ([@"image" isEqualToString:name]) {
|
||||
NSString *type = prop[@"type"];
|
||||
NSString *identifier = prop[@"identifier"];
|
||||
NSString *resId = prop[@"resId"];
|
||||
DoricAsyncResult <NSData *> *asyncResult = [[self.doricContext.driver.registry.loaderManager
|
||||
load:resId
|
||||
withIdentifier:identifier
|
||||
withResourceType:type
|
||||
load:prop
|
||||
withContext:self.doricContext] fetchRaw];
|
||||
[asyncResult setResultCallback:^(NSData *imageData) {
|
||||
[self.doricContext dispatchToMainQueue:^{
|
||||
|
Reference in New Issue
Block a user