Authored by Xenon

Added support for SDWebImageAvoidAutoSetImage option to UIButton and highlighted UIImageView

@@ -74,7 +74,12 @@ static char imageURLStorageKey; @@ -74,7 +74,12 @@ static char imageURLStorageKey;
74 dispatch_main_sync_safe(^{ 74 dispatch_main_sync_safe(^{
75 __strong UIButton *sself = wself; 75 __strong UIButton *sself = wself;
76 if (!sself) return; 76 if (!sself) return;
77 - if (image) { 77 + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock)
  78 + {
  79 + completedBlock(image, error, cacheType, url);
  80 + return;
  81 + }
  82 + else if (image) {
78 [sself setImage:image forState:state]; 83 [sself setImage:image forState:state];
79 } 84 }
80 if (completedBlock && finished) { 85 if (completedBlock && finished) {
@@ -117,7 +122,12 @@ static char imageURLStorageKey; @@ -117,7 +122,12 @@ static char imageURLStorageKey;
117 dispatch_main_sync_safe(^{ 122 dispatch_main_sync_safe(^{
118 __strong UIButton *sself = wself; 123 __strong UIButton *sself = wself;
119 if (!sself) return; 124 if (!sself) return;
120 - if (image) { 125 + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock)
  126 + {
  127 + completedBlock(image, error, cacheType, url);
  128 + return;
  129 + }
  130 + else if (image) {
121 [sself setBackgroundImage:image forState:state]; 131 [sself setBackgroundImage:image forState:state];
122 } 132 }
123 if (completedBlock && finished) { 133 if (completedBlock && finished) {
@@ -39,7 +39,12 @@ @@ -39,7 +39,12 @@
39 dispatch_main_sync_safe (^ 39 dispatch_main_sync_safe (^
40 { 40 {
41 if (!wself) return; 41 if (!wself) return;
42 - if (image) { 42 + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock)
  43 + {
  44 + completedBlock(image, error, cacheType, url);
  45 + return;
  46 + }
  47 + else if (image) {
43 wself.highlightedImage = image; 48 wself.highlightedImage = image;
44 [wself setNeedsLayout]; 49 [wself setNeedsLayout];
45 } 50 }