iOS:use macro to control use of image and cache library
This commit is contained in:
parent
0c5470d120
commit
31fb5186d3
@ -20,8 +20,9 @@
|
||||
#import "DoricStoragePlugin.h"
|
||||
#import "DoricExtensions.h"
|
||||
#import "DoricSingleton.h"
|
||||
#import "DoricThirdParty.h"
|
||||
|
||||
#if __has_include(<PINCache/PINCache.h>)
|
||||
#if DORIC_USE_PINCACHE
|
||||
|
||||
#import <PINCache/PINCache.h>
|
||||
|
||||
@ -64,7 +65,7 @@ - (void)removeAllObjectsWithBlock:(void (^)(void))block {
|
||||
}
|
||||
@end
|
||||
|
||||
#elif __has_include(<YYCache/YYCache.h>)
|
||||
#elif DORIC_USE_YYCACHE
|
||||
|
||||
#import <YYCache/YYCache.h>
|
||||
|
||||
@ -79,7 +80,7 @@ - (instancetype)initWithName:(NSString *)prefix rootPath:(NSString *)path {
|
||||
}
|
||||
@end
|
||||
|
||||
#elif __has_include(<TMCache/TMCache.h>)
|
||||
#elif DORIC_USE_TMCACHE
|
||||
|
||||
#import <TMCache/TMCache.h>
|
||||
|
||||
|
@ -24,8 +24,9 @@
|
||||
#import "DoricExtensions.h"
|
||||
#import "DoricUtil.h"
|
||||
#import "DoricSuperNode.h"
|
||||
#import "DoricThirdParty.h"
|
||||
|
||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||
#if DORIC_USE_YYWEBIMAGE
|
||||
|
||||
#import <YYWebImage/YYWebImage.h>
|
||||
#import <YYWebImage/_YYWebImageSetter.h>
|
||||
@ -47,7 +48,7 @@ - (void)displayLayer:(CALayer *)layer {
|
||||
}
|
||||
@end
|
||||
|
||||
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
||||
#elif DORIC_USE_SDWEBIMAGE
|
||||
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
|
||||
@ -131,9 +132,9 @@ - (UIImage *)currentPlaceHolderImage {
|
||||
}
|
||||
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64
|
||||
options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||
#if DORIC_USE_YYWEBIMAGE
|
||||
YYImage *image = [YYImage imageWithData:imageData scale:self.imageScale];
|
||||
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
||||
#elif DORIC_USE_SDWEBIMAGE
|
||||
UIImage *image = [SDAnimatedImage imageWithData:imageData scale:self.imageScale];
|
||||
if (!image) {
|
||||
image = [UIImage imageWithData:imageData scale:self.imageScale];
|
||||
@ -187,9 +188,9 @@ - (UIImage *)currentErrorImage {
|
||||
}
|
||||
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64
|
||||
options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||
#if DORIC_USE_YYWEBIMAGE
|
||||
YYImage *image = [YYImage imageWithData:imageData scale:self.imageScale];
|
||||
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
||||
#elif DORIC_USE_SDWEBIMAGE
|
||||
UIImage *image = [SDAnimatedImage imageWithData:imageData scale:self.imageScale];
|
||||
if (!image) {
|
||||
image = [UIImage imageWithData:imageData scale:self.imageScale];
|
||||
@ -236,7 +237,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
||||
__weak typeof(self) _self = self;
|
||||
__block BOOL async = NO;
|
||||
view.doricLayout.undefined = YES;
|
||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||
#if DORIC_USE_YYWEBIMAGE
|
||||
dispatch_async([_YYWebImageSetter setterQueue], ^{
|
||||
[view yy_cancelCurrentImageRequest];
|
||||
|
||||
@ -273,7 +274,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
||||
}
|
||||
}];
|
||||
});
|
||||
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
||||
#elif DORIC_USE_SDWEBIMAGE
|
||||
[view sd_setImageWithURL:[NSURL URLWithString:prop]
|
||||
placeholderImage:[self currentPlaceHolderImage]
|
||||
options:0
|
||||
@ -336,9 +337,9 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
||||
}
|
||||
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64
|
||||
options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||
#if DORIC_USE_YYWEBIMAGE
|
||||
YYImage *image = [YYImage imageWithData:imageData scale:self.imageScale];
|
||||
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
||||
#elif DORIC_USE_SDWEBIMAGE
|
||||
UIImage *image = [SDAnimatedImage imageWithData:imageData scale:self.imageScale];
|
||||
if (!image) {
|
||||
image = [UIImage imageWithData:imageData scale:self.imageScale];
|
||||
@ -433,9 +434,9 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
||||
}
|
||||
|
||||
- (UIImage *)imageNamed:(NSString *)name {
|
||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||
#if DORIC_USE_YYWEBIMAGE
|
||||
YYImage *image = [YYImage imageNamed:name];
|
||||
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
||||
#elif DORIC_USE_SDWEBIMAGE
|
||||
UIImage *image = [SDAnimatedImage imageNamed:name];
|
||||
if (!image) {
|
||||
image = [UIImage imageNamed:name];
|
||||
@ -447,9 +448,9 @@ - (UIImage *)imageNamed:(NSString *)name {
|
||||
}
|
||||
|
||||
- (UIImage *)imageFromData:(NSData *)imgData {
|
||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||
#if DORIC_USE_YYWEBIMAGE
|
||||
YYImage *image = [YYImage imageWithData:imgData scale:self.imageScale];
|
||||
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
||||
#elif DORIC_USE_SDWEBIMAGE
|
||||
UIImage *image = [SDAnimatedImage imageWithData:imgData scale:self.imageScale];
|
||||
if (!image) {
|
||||
image = [UIImage imageWithData:imgData scale:self.imageScale];
|
||||
|
46
doric-iOS/Pod/Classes/Util/DoricThirdParty.h
Normal file
46
doric-iOS/Pod/Classes/Util/DoricThirdParty.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright [2021] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//
|
||||
// DoricThirdParty.h
|
||||
// Doric
|
||||
//
|
||||
// Created by pengfei.zhou on 2021/9/6.
|
||||
//
|
||||
|
||||
|
||||
#if __has_include(<SDWebImage/SDWebImage.h>)
|
||||
#ifndef DORIC_USE_SDWEBIMAGE
|
||||
#define DORIC_USE_SDWEBIMAGE 1
|
||||
#endif
|
||||
#elif __has_include(<YYWebImage/YYWebImage.h>)
|
||||
#ifndef DORIC_USE_YYWEBIMAGE
|
||||
#define DORIC_USE_YYWEBIMAGE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __has_include(<PINCache/PINCache.h>)
|
||||
#ifndef DORIC_USE_PINCACHE
|
||||
#define DORIC_USE_PINCACHE 1
|
||||
#endif
|
||||
#elif __has_include(<YYCache/YYCache.h>)
|
||||
#ifndef DORIC_USE_YYCACHE
|
||||
#define DORIC_USE_YYCACHE 1
|
||||
#endif
|
||||
#elif __has_include(<TMCache/TMCache.h>)
|
||||
#ifndef DORIC_USE_TMCACHE
|
||||
#define DORIC_USE_TMCACHE 1
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user