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