Authored by 于良

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

... ... @@ -159,9 +159,9 @@ static NSArray *kYHEventReportIgnoredViewControllerArray;
self.performanceTrackEnabled = YES;
[UIViewController startTrack];
[UITabBar startTrack];
[UIControl startTrack];
[UITapGestureRecognizer startTrack];
//[NSURLConnection startTrack];
// [UIControl startTrack];
// [UITapGestureRecognizer startTrack];
// [NSURLConnection startTrack];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIWebView startTrack];
... ...
... ... @@ -14,25 +14,9 @@
#import "YHLog.h"
#import "YHEventReport.h"
static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock;
@interface SDWebImageManager()
@property (nonatomic, copy) SDWebImageCompletionWithFinishedBlock actionHandlerBlock;
@end
@implementation SDWebImageManager (AutoTrack)
#pragma mark - 属性
- (SDWebImageCompletionWithFinishedBlock)actionHandlerBlock{
return objc_getAssociatedObject(self, @selector(actionHandlerBlock));
}
- (void)setActionHandlerBlock:(SDWebImageCompletionWithFinishedBlock)actionHandlerBlock{
objc_setAssociatedObject(self, @selector(actionHandlerBlock), actionHandlerBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (void)setYh_webImageId:(NSString *)yh_webImageId{
objc_setAssociatedObject(self,@selector(yh_webImageId),yh_webImageId,OBJC_ASSOCIATION_RETAIN);
... ... @@ -67,7 +51,6 @@ static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock;
progress:(SDWebImageDownloaderProgressBlock)progressBlock
completed:(SDWebImageCompletionWithFinishedBlock)completedBlock
{
objc_setAssociatedObject(self, yher_actionHandlerBlock, completedBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
[[YH_EventCollector sharedInstance] timeEventStartWithWebImageDownload:self];
... ... @@ -85,9 +68,8 @@ static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock;
}
}
SDWebImageCompletionWithFinishedBlock actionHandlerBlock = objc_getAssociatedObject(self, yher_actionHandlerBlock);
if (actionHandlerBlock) {
actionHandlerBlock(image,error,cacheType,finished,imageURL);
if (completedBlock) {
completedBlock(image,error,cacheType,finished,imageURL);
}
}];
}
... ...