18
18
#import " SDWebImageFirebaseLoader.h"
19
19
20
20
static SDWebImageManager *SharedFirebaseWebImageManager (void ) {
21
- static dispatch_once_t onceToken;
22
- static SDWebImageManager *manager;
23
- dispatch_once (&onceToken, ^{
24
- manager = [[SDWebImageManager alloc ] initWithCache: SDImageCache.sharedImageCache loader: SDWebImageFirebaseLoader.sharedLoader];
25
- });
26
- return manager;
21
+ static dispatch_once_t onceToken;
22
+ static SDWebImageManager *manager;
23
+ dispatch_once (&onceToken, ^{
24
+ manager = [[SDWebImageManager alloc ] initWithCache: SDImageCache.sharedImageCache loader: SDWebImageFirebaseLoader.sharedLoader];
25
+ });
26
+ return manager;
27
27
}
28
28
29
29
@implementation UIImageView (FirebaseStorage)
30
30
31
31
- (void )sd_setImageWithStorageReference : (FIRStorageReference *)storageRef {
32
- [self sd_setImageWithStorageReference: storageRef placeholderImage: nil completion: nil ];
32
+ [self sd_setImageWithStorageReference: storageRef placeholderImage: nil completion: nil ];
33
33
}
34
34
35
35
- (void )sd_setImageWithStorageReference : (FIRStorageReference *)storageRef
36
36
placeholderImage : (UIImage *)placeholder {
37
- [self sd_setImageWithStorageReference: storageRef placeholderImage: placeholder completion: nil ];
37
+ [self sd_setImageWithStorageReference: storageRef placeholderImage: placeholder completion: nil ];
38
38
}
39
39
40
40
- (void )sd_setImageWithStorageReference : (FIRStorageReference *)storageRef
@@ -43,10 +43,10 @@ - (void)sd_setImageWithStorageReference:(FIRStorageReference *)storageRef
43
43
NSError *_Nullable,
44
44
SDImageCacheType,
45
45
FIRStorageReference *))completionBlock {
46
- [self sd_setImageWithStorageReference: storageRef
47
- maxImageSize: SDWebImageFirebaseLoader.sharedLoader.defaultMaxImageSize
48
- placeholderImage: placeholder
49
- completion: completionBlock];
46
+ [self sd_setImageWithStorageReference: storageRef
47
+ maxImageSize: SDWebImageFirebaseLoader.sharedLoader.defaultMaxImageSize
48
+ placeholderImage: placeholder
49
+ completion: completionBlock];
50
50
}
51
51
52
52
- (void )sd_setImageWithStorageReference : (FIRStorageReference *)storageRef
@@ -56,11 +56,11 @@ - (void)sd_setImageWithStorageReference:(FIRStorageReference *)storageRef
56
56
NSError *,
57
57
SDImageCacheType,
58
58
FIRStorageReference *))completionBlock {
59
- [self sd_setImageWithStorageReference: storageRef
60
- maxImageSize: size
61
- placeholderImage: placeholder
62
- options: 0
63
- completion: completionBlock];
59
+ [self sd_setImageWithStorageReference: storageRef
60
+ maxImageSize: size
61
+ placeholderImage: placeholder
62
+ options: 0
63
+ completion: completionBlock];
64
64
}
65
65
66
66
- (void )sd_setImageWithStorageReference : (FIRStorageReference *)storageRef
@@ -71,12 +71,12 @@ - (void)sd_setImageWithStorageReference:(FIRStorageReference *)storageRef
71
71
NSError *,
72
72
SDImageCacheType,
73
73
FIRStorageReference *))completionBlock {
74
- [self sd_setImageWithStorageReference: storageRef
75
- maxImageSize: size
76
- placeholderImage: placeholder
77
- options: options
78
- progress: nil
79
- completion: completionBlock];
74
+ [self sd_setImageWithStorageReference: storageRef
75
+ maxImageSize: size
76
+ placeholderImage: placeholder
77
+ options: options
78
+ progress: nil
79
+ completion: completionBlock];
80
80
}
81
81
82
82
- (void )sd_setImageWithStorageReference : (FIRStorageReference *)storageRef
@@ -90,13 +90,13 @@ - (void)sd_setImageWithStorageReference:(FIRStorageReference *)storageRef
90
90
NSError *,
91
91
SDImageCacheType,
92
92
FIRStorageReference *))completionBlock {
93
- [self sd_setImageWithStorageReference: storageRef
94
- maxImageSize: size
95
- placeholderImage: placeholder
96
- options: options
97
- context: nil
98
- progress: progressBlock
99
- completion: completionBlock];
93
+ [self sd_setImageWithStorageReference: storageRef
94
+ maxImageSize: size
95
+ placeholderImage: placeholder
96
+ options: options
97
+ context: nil
98
+ progress: progressBlock
99
+ completion: completionBlock];
100
100
}
101
101
102
102
- (void )sd_setImageWithStorageReference : (FIRStorageReference *)storageRef
@@ -111,47 +111,47 @@ - (void)sd_setImageWithStorageReference:(FIRStorageReference *)storageRef
111
111
NSError *,
112
112
SDImageCacheType,
113
113
FIRStorageReference *))completionBlock {
114
- NSParameterAssert (storageRef != nil );
115
-
116
- NSURL *url = [NSURL sd_URLWithStorageReference: storageRef];
117
-
118
- SDWebImageMutableContext *mutableContext;
119
- if (context) {
120
- mutableContext = [context mutableCopy ];
121
- } else {
122
- mutableContext = [NSMutableDictionary dictionary ];
114
+ NSParameterAssert (storageRef != nil );
115
+
116
+ NSURL *url = [NSURL sd_URLWithStorageReference: storageRef];
117
+
118
+ SDWebImageMutableContext *mutableContext;
119
+ if (context) {
120
+ mutableContext = [context mutableCopy ];
121
+ } else {
122
+ mutableContext = [NSMutableDictionary dictionary ];
123
+ }
124
+ mutableContext[SDWebImageContextCustomManager] = SharedFirebaseWebImageManager ();
125
+ mutableContext[SDWebImageContextFirebaseMaxImageSize] = @(size);
126
+
127
+ // TODO: Current version use `fullpath` as cache key, but not the URL. Do we need to keep compabitle ?
128
+ SDWebImageCacheKeyFilter *cacheKeyFilter = [SDWebImageCacheKeyFilter cacheKeyFilterWithBlock: ^NSString * _Nullable (NSURL * _Nonnull url) {
129
+ return url.sd_storageReference .fullPath ;
130
+ }];
131
+ mutableContext[SDWebImageContextCacheKeyFilter] = cacheKeyFilter;
132
+
133
+ [self sd_setImageWithURL: url placeholderImage: placeholder options: options context: [mutableContext copy ] progress: ^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
134
+ if (progressBlock) {
135
+ progressBlock (receivedSize, expectedSize, storageRef);
123
136
}
124
- mutableContext[SDWebImageContextCustomManager] = SharedFirebaseWebImageManager ();
125
- mutableContext[SDWebImageContextFirebaseMaxImageSize] = @(size);
126
-
127
- // TODO: Current version use `fullpath` as cache key, but not the URL. Do we need to keep compabitle ?
128
- SDWebImageCacheKeyFilter *cacheKeyFilter = [SDWebImageCacheKeyFilter cacheKeyFilterWithBlock: ^NSString * _Nullable (NSURL * _Nonnull url) {
129
- return url.sd_storageReference .fullPath ;
130
- }];
131
- mutableContext[SDWebImageContextCacheKeyFilter] = cacheKeyFilter;
132
-
133
- [self sd_setImageWithURL: url placeholderImage: placeholder options: options context: [mutableContext copy ] progress: ^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
134
- if (progressBlock) {
135
- progressBlock (receivedSize, expectedSize, storageRef);
136
- }
137
- } completed: ^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
138
- if (completionBlock) {
139
- completionBlock (image, error, cacheType, storageRef);
140
- }
141
- }];
137
+ } completed: ^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
138
+ if (completionBlock) {
139
+ completionBlock (image, error, cacheType, storageRef);
140
+ }
141
+ }];
142
142
}
143
143
144
144
#pragma mark - Getter
145
145
- (FIRStorageDownloadTask *)sd_currentDownloadTask {
146
- SDWebImageCombinedOperation *operation = [self sd_imageLoadOperationForKey: NSStringFromClass (self .class)];
147
- if (operation) {
148
- id <SDWebImageOperation> loaderOperation = operation.loaderOperation ;
149
- // This is a protocol, check the class
150
- if ([loaderOperation isKindOfClass: [FIRStorageDownloadTask class ]]) {
151
- return (FIRStorageDownloadTask *)loaderOperation;
152
- }
146
+ SDWebImageCombinedOperation *operation = [self sd_imageLoadOperationForKey: NSStringFromClass (self .class)];
147
+ if (operation) {
148
+ id <SDWebImageOperation> loaderOperation = operation.loaderOperation ;
149
+ // This is a protocol, check the class
150
+ if ([loaderOperation isKindOfClass: [FIRStorageDownloadTask class ]]) {
151
+ return (FIRStorageDownloadTask *)loaderOperation;
153
152
}
154
- return nil ;
153
+ }
154
+ return nil ;
155
155
}
156
156
157
157
@end
0 commit comments