Permalink
Browse files

Updated SDWebImage.

  • Loading branch information...
1 parent aa4fd90 commit be6791b43a5442c11282b3ed3fd9d87b2698af79 @mwaterfall committed May 28, 2012
Showing with 1,673 additions and 201 deletions.
  1. +33 −31 Demo/PhotoBrowserDemo.xcodeproj/project.pbxproj
  2. +1 −9 MWPhotoBrowser/Classes/MWPhoto.m
  3. +1 −0 MWPhotoBrowser/Classes/MWZoomingScrollView.m
  4. +0 −2 MWPhotoBrowser/Libraries/SDWebImage/.gitignore
  5. +93 −0 MWPhotoBrowser/Libraries/SDWebImage/MKAnnotationView+WebCache.h
  6. +80 −0 MWPhotoBrowser/Libraries/SDWebImage/MKAnnotationView+WebCache.m
  7. +179 −41 MWPhotoBrowser/Libraries/SDWebImage/README.md
  8. +108 −0 MWPhotoBrowser/Libraries/SDWebImage/SDImageCache.h
  9. +75 −22 MWPhotoBrowser/Libraries/SDWebImage/SDImageCache.m
  10. +20 −0 MWPhotoBrowser/Libraries/SDWebImage/SDImageCacheDelegate.h
  11. +78 −7 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageCompat.h
  12. +32 −1 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageDecoder.h
  13. +8 −8 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageDecoder.m
  14. +37 −1 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageDownloader.h
  15. +130 −25 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageDownloader.m
  16. +25 −0 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageDownloaderDelegate.h
  17. +115 −4 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageManager.h
  18. +220 −23 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageManager.m
  19. +36 −0 MWPhotoBrowser/Libraries/SDWebImage/SDWebImageManagerDelegate.h
  20. +14 −1 MWPhotoBrowser/Libraries/SDWebImage/SDWebImagePrefetcher.h
  21. +6 −4 MWPhotoBrowser/Libraries/SDWebImage/SDWebImagePrefetcher.m
  22. +127 −4 MWPhotoBrowser/Libraries/SDWebImage/UIButton+WebCache.h
  23. +127 −3 MWPhotoBrowser/Libraries/SDWebImage/UIButton+WebCache.m
  24. +76 −7 MWPhotoBrowser/Libraries/SDWebImage/UIImageView+WebCache.h
  25. +32 −0 MWPhotoBrowser/Libraries/SDWebImage/UIImageView+WebCache.m
  26. +15 −3 MWPhotoBrowser/MWPhotoBrowser.xcodeproj/project.pbxproj
  27. +5 −5 README.markdown
@@ -7,7 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
+ 0E76FFEF1573FE1A000EE5CA /* MWPhotoBrowser.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 0E76FFEE1573FE1A000EE5CA /* MWPhotoBrowser.bundle */; };
+ 0E76FFF21573FE25000EE5CA /* libMWPhotoBrowser.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E76FFED1573FE14000EE5CA /* libMWPhotoBrowser.a */; };
0E85B24C14C6F40500EA35BF /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0E85B24E14C6F40500EA35BF /* Localizable.strings */; };
+ 0EA380351573EA53003F4582 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EA380341573EA53003F4582 /* ImageIO.framework */; };
4C6F979214AF734900F8389A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C6F979114AF734900F8389A /* UIKit.framework */; };
4C6F979414AF734900F8389A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C6F979314AF734900F8389A /* Foundation.framework */; };
4C6F979614AF734900F8389A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C6F979514AF734900F8389A /* CoreGraphics.framework */; };
@@ -23,29 +26,30 @@
4C6F97D814AF760500F8389A /* photo3m.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 4C6F97D014AF760500F8389A /* photo3m.jpg */; };
4C6F97D914AF760500F8389A /* photo4l.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 4C6F97D114AF760500F8389A /* photo4l.jpg */; };
4C6F97DA14AF760500F8389A /* photo4m.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 4C6F97D214AF760500F8389A /* photo4m.jpg */; };
- 4CD92B1314B20FA2002200C1 /* MWPhotoBrowser.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 4CD92B1214B20FA2002200C1 /* MWPhotoBrowser.bundle */; };
- 4CD92B1614B20FB5002200C1 /* libMWPhotoBrowser.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CD92B1114B20F9B002200C1 /* libMWPhotoBrowser.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
- 4CD92B1014B20F9B002200C1 /* PBXContainerItemProxy */ = {
+ 0E76FFEC1573FE14000EE5CA /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
- containerPortal = 4CD92B0114B20F97002200C1 /* MWPhotoBrowser.xcodeproj */;
+ containerPortal = 0E76FFE51573FE13000EE5CA /* MWPhotoBrowser.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 4C6F96C414AF704100F8389A;
remoteInfo = MWPhotoBrowser;
};
- 4CD92B1414B20FAF002200C1 /* PBXContainerItemProxy */ = {
+ 0E76FFF01573FE21000EE5CA /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
- containerPortal = 4CD92B0114B20F97002200C1 /* MWPhotoBrowser.xcodeproj */;
+ containerPortal = 0E76FFE51573FE13000EE5CA /* MWPhotoBrowser.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 4C6F96C314AF704100F8389A;
remoteInfo = MWPhotoBrowser;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
+ 0E76FFE51573FE13000EE5CA /* MWPhotoBrowser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MWPhotoBrowser.xcodeproj; path = ../../MWPhotoBrowser/MWPhotoBrowser.xcodeproj; sourceTree = "<group>"; };
+ 0E76FFEE1573FE1A000EE5CA /* MWPhotoBrowser.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = MWPhotoBrowser.bundle; path = ../../MWPhotoBrowser/MWPhotoBrowser.bundle; sourceTree = "<group>"; };
0E85B24D14C6F40500EA35BF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
+ 0EA380341573EA53003F4582 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; };
4C6F978D14AF734900F8389A /* PhotoBrowserDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PhotoBrowserDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
4C6F979114AF734900F8389A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
4C6F979314AF734900F8389A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -66,16 +70,15 @@
4C6F97D014AF760500F8389A /* photo3m.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = photo3m.jpg; path = Photos/photo3m.jpg; sourceTree = "<group>"; };
4C6F97D114AF760500F8389A /* photo4l.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = photo4l.jpg; path = Photos/photo4l.jpg; sourceTree = "<group>"; };
4C6F97D214AF760500F8389A /* photo4m.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = photo4m.jpg; path = Photos/photo4m.jpg; sourceTree = "<group>"; };
- 4CD92B0114B20F97002200C1 /* MWPhotoBrowser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MWPhotoBrowser.xcodeproj; path = ../../MWPhotoBrowser/MWPhotoBrowser.xcodeproj; sourceTree = "<group>"; };
- 4CD92B1214B20FA2002200C1 /* MWPhotoBrowser.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = MWPhotoBrowser.bundle; path = ../../MWPhotoBrowser/MWPhotoBrowser.bundle; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4C6F978A14AF734800F8389A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 4CD92B1614B20FB5002200C1 /* libMWPhotoBrowser.a in Frameworks */,
+ 0E76FFF21573FE25000EE5CA /* libMWPhotoBrowser.a in Frameworks */,
+ 0EA380351573EA53003F4582 /* ImageIO.framework in Frameworks */,
4C6F97C914AF750400F8389A /* MessageUI.framework in Frameworks */,
4C6F979214AF734900F8389A /* UIKit.framework in Frameworks */,
4C6F979414AF734900F8389A /* Foundation.framework in Frameworks */,
@@ -86,6 +89,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ 0E76FFE61573FE13000EE5CA /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 0E76FFED1573FE14000EE5CA /* libMWPhotoBrowser.a */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
4C6F978214AF734800F8389A = {
isa = PBXGroup;
children = (
@@ -106,6 +117,7 @@
4C6F979014AF734900F8389A /* Frameworks */ = {
isa = PBXGroup;
children = (
+ 0EA380341573EA53003F4582 /* ImageIO.framework */,
4C6F97C814AF750400F8389A /* MessageUI.framework */,
4C6F979114AF734900F8389A /* UIKit.framework */,
4C6F979314AF734900F8389A /* Foundation.framework */,
@@ -157,20 +169,12 @@
4CB08BF314B1FF7300730E9F /* MWPhotoBrowser */ = {
isa = PBXGroup;
children = (
- 4CD92B1214B20FA2002200C1 /* MWPhotoBrowser.bundle */,
- 4CD92B0114B20F97002200C1 /* MWPhotoBrowser.xcodeproj */,
+ 0E76FFEE1573FE1A000EE5CA /* MWPhotoBrowser.bundle */,
+ 0E76FFE51573FE13000EE5CA /* MWPhotoBrowser.xcodeproj */,
);
name = MWPhotoBrowser;
sourceTree = "<group>";
};
- 4CD92B0D14B20F9B002200C1 /* Products */ = {
- isa = PBXGroup;
- children = (
- 4CD92B1114B20F9B002200C1 /* libMWPhotoBrowser.a */,
- );
- name = Products;
- sourceTree = "<group>";
- };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -185,7 +189,7 @@
buildRules = (
);
dependencies = (
- 4CD92B1514B20FAF002200C1 /* PBXTargetDependency */,
+ 0E76FFF11573FE21000EE5CA /* PBXTargetDependency */,
);
name = PhotoBrowserDemo;
productName = PhotoBrowserDemo;
@@ -213,8 +217,8 @@
projectDirPath = "";
projectReferences = (
{
- ProductGroup = 4CD92B0D14B20F9B002200C1 /* Products */;
- ProjectRef = 4CD92B0114B20F97002200C1 /* MWPhotoBrowser.xcodeproj */;
+ ProductGroup = 0E76FFE61573FE13000EE5CA /* Products */;
+ ProjectRef = 0E76FFE51573FE13000EE5CA /* MWPhotoBrowser.xcodeproj */;
},
);
projectRoot = "";
@@ -225,11 +229,11 @@
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
- 4CD92B1114B20F9B002200C1 /* libMWPhotoBrowser.a */ = {
+ 0E76FFED1573FE14000EE5CA /* libMWPhotoBrowser.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libMWPhotoBrowser.a;
- remoteRef = 4CD92B1014B20F9B002200C1 /* PBXContainerItemProxy */;
+ remoteRef = 0E76FFEC1573FE14000EE5CA /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
@@ -247,8 +251,8 @@
4C6F97D814AF760500F8389A /* photo3m.jpg in Resources */,
4C6F97D914AF760500F8389A /* photo4l.jpg in Resources */,
4C6F97DA14AF760500F8389A /* photo4m.jpg in Resources */,
- 4CD92B1314B20FA2002200C1 /* MWPhotoBrowser.bundle in Resources */,
0E85B24C14C6F40500EA35BF /* Localizable.strings in Resources */,
+ 0E76FFEF1573FE1A000EE5CA /* MWPhotoBrowser.bundle in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -268,10 +272,10 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
- 4CD92B1514B20FAF002200C1 /* PBXTargetDependency */ = {
+ 0E76FFF11573FE21000EE5CA /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = MWPhotoBrowser;
- targetProxy = 4CD92B1414B20FAF002200C1 /* PBXContainerItemProxy */;
+ targetProxy = 0E76FFF01573FE21000EE5CA /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
@@ -309,7 +313,6 @@
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
- USER_HEADER_SEARCH_PATHS = "../../../**";
};
name = Debug;
};
@@ -329,7 +332,6 @@
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
- USER_HEADER_SEARCH_PATHS = "../../../**";
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -345,7 +347,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PhotoBrowserDemo/PhotoBrowserDemo-Prefix.pch";
INFOPLIST_FILE = "PhotoBrowserDemo/PhotoBrowserDemo-Info.plist";
- LIBRARY_SEARCH_PATHS = "";
+ IPHONEOS_DEPLOYMENT_TARGET = 4.0;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "../**";
WRAPPER_EXTENSION = app;
@@ -363,7 +365,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PhotoBrowserDemo/PhotoBrowserDemo-Prefix.pch";
INFOPLIST_FILE = "PhotoBrowserDemo/PhotoBrowserDemo-Info.plist";
- LIBRARY_SEARCH_PATHS = "";
+ IPHONEOS_DEPLOYMENT_TARGET = 4.0;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "../**";
WRAPPER_EXTENSION = app;
@@ -106,15 +106,7 @@ - (void)loadUnderlyingImageAndNotify {
} else if (_photoURL) {
// Load async from web (using SDWebImage)
SDWebImageManager *manager = [SDWebImageManager sharedManager];
- UIImage *cachedImage = [manager imageWithURL:_photoURL];
- if (cachedImage) {
- // Use the cached image immediatly
- self.underlyingImage = cachedImage;
- [self imageDidFinishLoadingSoDecompress];
- } else {
- // Start an async download
- [manager downloadWithURL:_photoURL delegate:self];
- }
+ [manager downloadWithURL:_photoURL delegate:self];
} else {
// Failed - no source
self.underlyingImage = nil;
@@ -72,6 +72,7 @@ - (void)dealloc {
[_photoImageView release];
[_spinner release];
[_photo release];
+ [_captionView release];
[super dealloc];
}
@@ -1,2 +0,0 @@
-.DS_Store
-xcuserdata/
@@ -0,0 +1,93 @@
+//
+// MKAnnotationView+WebCache.h
+// SDWebImage
+//
+// Created by Olivier Poitrey on 14/03/12.
+// Copyright (c) 2012 Dailymotion. All rights reserved.
+//
+
+#import "MapKit/MapKit.h"
+#import "SDWebImageCompat.h"
+#import "SDWebImageManagerDelegate.h"
+#import "SDWebImageManager.h"
+
+/**
+ * Integrates SDWebImage async downloading and caching of remote images with MKAnnotationView.
+ */
+@interface MKAnnotationView (WebCache) <SDWebImageManagerDelegate>
+
+/**
+ * Set the imageView `image` with an `url`.
+ *
+ * The downloand is asynchronous and cached.
+ *
+ * @param url The url for the image.
+ */
+- (void)setImageWithURL:(NSURL *)url;
+
+/**
+ * Set the imageView `image` with an `url` and a placeholder.
+ *
+ * The downloand is asynchronous and cached.
+ *
+ * @param url The url for the image.
+ * @param placeholder The image to be set initially, until the image request finishes.
+ * @see setImageWithURL:placeholderImage:options:
+ */
+- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder;
+
+/**
+ * Set the imageView `image` with an `url`, placeholder and custom options.
+ *
+ * The downloand is asynchronous and cached.
+ *
+ * @param url The url for the image.
+ * @param placeholder The image to be set initially, until the image request finishes.
+ * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
+ */
+- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options;
+
+#if NS_BLOCKS_AVAILABLE
+/**
+ * Set the imageView `image` with an `url`.
+ *
+ * The downloand is asynchronous and cached.
+ *
+ * @param url The url for the image.
+ * @param success A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.
+ * @param failure A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).
+ */
+- (void)setImageWithURL:(NSURL *)url success:(void (^)(UIImage *image))success failure:(void (^)(NSError *error))failure;
+
+/**
+ * Set the imageView `image` with an `url`, placeholder.
+ *
+ * The downloand is asynchronous and cached.
+ *
+ * @param url The url for the image.
+ * @param placeholder The image to be set initially, until the image request finishes.
+ * @param success A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.
+ * @param failure A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).
+ */
+- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder success:(void (^)(UIImage *image))success failure:(void (^)(NSError *error))failure;
+
+/**
+ * Set the imageView `image` with an `url`, placeholder and custom options.
+ *
+ * The downloand is asynchronous and cached.
+ *
+ * @param url The url for the image.
+ * @param placeholder The image to be set initially, until the image request finishes.
+ * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
+ * @param success A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.
+ * @param failure A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).
+ */
+- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options success:(void (^)(UIImage *image))success failure:(void (^)(NSError *error))failure;
+#endif
+
+/**
+ * Cancel the current download
+ */
+- (void)cancelCurrentImageLoad;
+
+@end
Oops, something went wrong.

0 comments on commit be6791b

Please sign in to comment.