Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support local gif image #220

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Classes/IDMPhoto.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@

#import "IDMPhoto.h"
#import "IDMPhotoBrowser.h"
#import "YLGIFImage.h"

// Private
@interface IDMPhoto () {
// Image Sources
NSString *_photoPath;

// Image
UIImage *_underlyingImage;
YLGIFImage *_underlyingImage;

// Other
NSString *_caption;
BOOL _loadingInProgress;
}

// Properties
@property (nonatomic, strong) UIImage *underlyingImage;
@property (nonatomic, strong) YLGIFImage *underlyingImage;

// Methods
- (void)imageLoadingComplete;
Expand Down Expand Up @@ -97,7 +98,7 @@ + (NSArray *)photosWithURLs:(NSArray *)urlsArray {

#pragma mark NSObject

- (id)initWithImage:(UIImage *)image {
- (id)initWithImage:(YLGIFImage *)image {
if ((self = [super init])) {
self.underlyingImage = image;
}
Expand Down Expand Up @@ -144,7 +145,7 @@ - (void)loadUnderlyingImageAndNotify {
}
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
self.underlyingImage = image;
self.underlyingImage = (YLGIFImage*)image;
[self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO];
}
}];
Expand Down Expand Up @@ -265,12 +266,13 @@ - (UIImage *)decodedImageWithImage:(UIImage *)image {
- (void)loadImageFromFileAsync {
@autoreleasepool {
@try {
self.underlyingImage = [UIImage imageWithContentsOfFile:_photoPath];
YLGIFImage *image = [[YLGIFImage alloc] initWithData:[NSData dataWithContentsOfFile:_photoPath]];
self.underlyingImage = image;
if (!_underlyingImage) {
//IDMLog(@"Error loading photo from path: %@", _photoPath);
}
} @finally {
self.underlyingImage = [self decodedImageWithImage: self.underlyingImage];
self.underlyingImage = (YLGIFImage*)[self decodedImageWithImage: self.underlyingImage];
[self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO];
}
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/IDMPhotoBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -1290,8 +1290,8 @@ - (void)actionButtonPressed:(id)sender {
if(!_actionButtonTitles)
{
// Activity view
NSMutableArray *activityItems = [NSMutableArray arrayWithObject:[photo underlyingImage]];
if (photo.caption) [activityItems addObject:photo.caption];
UIImage *image = (UIImage*)[photo underlyingImage];
NSArray *activityItems = [NSArray arrayWithObject:image];

self.activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

Expand Down
5 changes: 3 additions & 2 deletions Classes/IDMTapDetectingImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
//

#import <Foundation/Foundation.h>
#import "YLImageView.h"

@protocol IDMTapDetectingImageViewDelegate;

@interface IDMTapDetectingImageView : UIImageView {
@interface IDMTapDetectingImageView : YLImageView {
id <IDMTapDetectingImageViewDelegate> __weak tapDelegate;
}
@property (nonatomic, weak) id <IDMTapDetectingImageViewDelegate> tapDelegate;
Expand All @@ -24,4 +25,4 @@
- (void)imageView:(UIImageView *)imageView singleTapDetected:(UITouch *)touch;
- (void)imageView:(UIImageView *)imageView doubleTapDetected:(UITouch *)touch;
- (void)imageView:(UIImageView *)imageView tripleTapDetected:(UITouch *)touch;
@end
@end
20 changes: 20 additions & 0 deletions Demo/PhotoBrowserDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
5736E0DD544CC84515494E76 /* libPods-PhotoBrowserDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 64F5714840012BFE47F8331B /* libPods-PhotoBrowserDemo.a */; };
727988B1187B3B5400966C66 /* IDMPBLocalizations.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 727988B0187B3B5400966C66 /* IDMPBLocalizations.bundle */; };
727988B7187B3CF100966C66 /* IDMPhotoBrowser.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 727988B6187B3CF100966C66 /* IDMPhotoBrowser.podspec */; };
BB7D79E91DCD8B760074ED33 /* a.gif in Resources */ = {isa = PBXBuildFile; fileRef = BB7D79E81DCD8B760074ED33 /* a.gif */; };
D114BB411A32269C00E677FE /* Launch Screen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D114BB401A32269C00E677FE /* Launch Screen.xib */; };
D1574968178DB94900B0211A /* IDMCaptionView.m in Sources */ = {isa = PBXBuildFile; fileRef = D157494F178DB94900B0211A /* IDMCaptionView.m */; };
D1574969178DB94900B0211A /* IDMPhoto.m in Sources */ = {isa = PBXBuildFile; fileRef = D1574951178DB94900B0211A /* IDMPhoto.m */; };
Expand Down Expand Up @@ -79,6 +80,7 @@
64F5714840012BFE47F8331B /* libPods-PhotoBrowserDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PhotoBrowserDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
727988B0187B3B5400966C66 /* IDMPBLocalizations.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = IDMPBLocalizations.bundle; sourceTree = "<group>"; };
727988B6187B3CF100966C66 /* IDMPhotoBrowser.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = IDMPhotoBrowser.podspec; path = ../../IDMPhotoBrowser.podspec; sourceTree = "<group>"; };
BB7D79E81DCD8B760074ED33 /* a.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = a.gif; path = Photos/a.gif; sourceTree = "<group>"; };
D00FA320EEACA8C835D9D626 /* Pods-PhotoBrowserDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PhotoBrowserDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PhotoBrowserDemo/Pods-PhotoBrowserDemo.debug.xcconfig"; sourceTree = "<group>"; };
D11464B61802FFC4005B7BC3 /* IDMPBConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IDMPBConstants.h; sourceTree = "<group>"; };
D114BB401A32269C00E677FE /* Launch Screen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "Launch Screen.xib"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -211,6 +213,7 @@
4C6F97CA14AF75D300F8389A /* Photos */ = {
isa = PBXGroup;
children = (
BB7D79E81DCD8B760074ED33 /* a.gif */,
4C6F97CB14AF760500F8389A /* photo1l.jpg */,
4C6F97CC14AF760500F8389A /* photo1m.jpg */,
4C6F97CD14AF760500F8389A /* photo2l.jpg */,
Expand Down Expand Up @@ -305,6 +308,7 @@
4C6F978B14AF734800F8389A /* Resources */,
64D1E44DFBE2976FB9C75718 /* [CP] Embed Pods Frameworks */,
F88445D630091F1AA9A2F89A /* [CP] Copy Pods Resources */,
21ABD9274EA68622571550CF /* Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -371,13 +375,29 @@
D19D826717E8D40700A5859E /* [email protected] in Resources */,
727988B7187B3CF100966C66 /* IDMPhotoBrowser.podspec in Resources */,
D19D826817E8D40700A5859E /* IDMPhotoBrowser_customDoneButton.png in Resources */,
BB7D79E91DCD8B760074ED33 /* a.gif in Resources */,
D19D826917E8D40700A5859E /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
21ABD9274EA68622571550CF /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PhotoBrowserDemo/Pods-PhotoBrowserDemo-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
64D1E44DFBE2976FB9C75718 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
2 changes: 1 addition & 1 deletion Demo/PhotoBrowserDemo/Menu.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
photo.caption = @"Grotto of the Madonna";
[photos addObject:photo];

photo = [IDMPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]];
photo = [IDMPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"a" ofType:@"gif"]];
photo.caption = @"The London Eye is a giant Ferris wheel situated on the banks of the River Thames, in London, England.";
[photos addObject:photo];

Expand Down
Binary file added Demo/PhotoBrowserDemo/Photos/a.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Demo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ target "PhotoBrowserDemo" do
pod 'SDWebImage'
pod 'DACircularProgress'
pod 'pop'
pod 'YLGIFImage'

end
7 changes: 4 additions & 3 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ PODS:
- SDWebImage (3.8.2):
- SDWebImage/Core (= 3.8.2)
- SDWebImage/Core (3.8.2)
- YLGIFImage (0.11)

DEPENDENCIES:
- DACircularProgress
- pop
- SDWebImage
- YLGIFImage

SPEC CHECKSUMS:
DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71
pop: f667631a5108a2e60d9e8797c9b32ddaf2080bce
SDWebImage: 098e97e6176540799c27e804c96653ee0833d13c
YLGIFImage: c0ae132fe80e5282b2762a97d14e23ba71a748ae

PODFILE CHECKSUM: 7c9b8bb160246eb04b56feab0ec4a8fb149d5fa3

COCOAPODS: 1.0.1
COCOAPODS: 0.39.0
1 change: 1 addition & 0 deletions IDMPhotoBrowser.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ Pod::Spec.new do |s|
s.dependency 'SDWebImage'
s.dependency 'DACircularProgress'
s.dependency 'pop'
s.dependency 'YLGIFImage'
end