Authored by 于良

图片性能采集优化 review by 戴强

@@ -159,9 +159,9 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; @@ -159,9 +159,9 @@ static NSArray *kYHEventReportIgnoredViewControllerArray;
159 self.performanceTrackEnabled = YES; 159 self.performanceTrackEnabled = YES;
160 [UIViewController startTrack]; 160 [UIViewController startTrack];
161 [UITabBar startTrack]; 161 [UITabBar startTrack];
162 - [UIControl startTrack];  
163 - [UITapGestureRecognizer startTrack];  
164 - //[NSURLConnection startTrack]; 162 +// [UIControl startTrack];
  163 +// [UITapGestureRecognizer startTrack];
  164 +// [NSURLConnection startTrack];
165 165
166 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 166 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
167 [UIWebView startTrack]; 167 [UIWebView startTrack];
@@ -14,25 +14,9 @@ @@ -14,25 +14,9 @@
14 #import "YHLog.h" 14 #import "YHLog.h"
15 #import "YHEventReport.h" 15 #import "YHEventReport.h"
16 16
17 -static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock;  
18 -  
19 -@interface SDWebImageManager()  
20 -  
21 -@property (nonatomic, copy) SDWebImageCompletionWithFinishedBlock actionHandlerBlock;  
22 -  
23 -@end  
24 17
25 @implementation SDWebImageManager (AutoTrack) 18 @implementation SDWebImageManager (AutoTrack)
26 19
27 -#pragma mark - 属性  
28 -  
29 -- (SDWebImageCompletionWithFinishedBlock)actionHandlerBlock{  
30 - return objc_getAssociatedObject(self, @selector(actionHandlerBlock));  
31 -}  
32 -  
33 -- (void)setActionHandlerBlock:(SDWebImageCompletionWithFinishedBlock)actionHandlerBlock{  
34 - objc_setAssociatedObject(self, @selector(actionHandlerBlock), actionHandlerBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);  
35 -}  
36 20
37 - (void)setYh_webImageId:(NSString *)yh_webImageId{ 21 - (void)setYh_webImageId:(NSString *)yh_webImageId{
38 objc_setAssociatedObject(self,@selector(yh_webImageId),yh_webImageId,OBJC_ASSOCIATION_RETAIN); 22 objc_setAssociatedObject(self,@selector(yh_webImageId),yh_webImageId,OBJC_ASSOCIATION_RETAIN);
@@ -67,7 +51,6 @@ static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock; @@ -67,7 +51,6 @@ static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock;
67 progress:(SDWebImageDownloaderProgressBlock)progressBlock 51 progress:(SDWebImageDownloaderProgressBlock)progressBlock
68 completed:(SDWebImageCompletionWithFinishedBlock)completedBlock 52 completed:(SDWebImageCompletionWithFinishedBlock)completedBlock
69 { 53 {
70 - objc_setAssociatedObject(self, yher_actionHandlerBlock, completedBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);  
71 54
72 if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){ 55 if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
73 [[YH_EventCollector sharedInstance] timeEventStartWithWebImageDownload:self]; 56 [[YH_EventCollector sharedInstance] timeEventStartWithWebImageDownload:self];
@@ -85,9 +68,8 @@ static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock; @@ -85,9 +68,8 @@ static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock;
85 } 68 }
86 } 69 }
87 70
88 - SDWebImageCompletionWithFinishedBlock actionHandlerBlock = objc_getAssociatedObject(self, yher_actionHandlerBlock);  
89 - if (actionHandlerBlock) {  
90 - actionHandlerBlock(image,error,cacheType,finished,imageURL); 71 + if (completedBlock) {
  72 + completedBlock(image,error,cacheType,finished,imageURL);
91 } 73 }
92 }]; 74 }];
93 } 75 }