Skip to content

Commit 5e66fa1

Browse files
committed
use protocol rather the the real model. users can define which image downloader(sdwebimage or afnetworking) to use by them self.
1 parent 66ddd73 commit 5e66fa1

File tree

6 files changed

+29
-21
lines changed

6 files changed

+29
-21
lines changed

MWPhotoBrowser.podspec

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,33 @@ Pod::Spec.new do |s|
2727
:git => 'https://github.com/mwaterfall/MWPhotoBrowser.git',
2828
:tag => '2.1.2'
2929
}
30+
3031
s.platform = :ios, '7.0'
31-
s.source_files = 'Pod/Classes/**/*'
32-
s.resource_bundles = {
33-
'MWPhotoBrowser' => ['Pod/Assets/*.png']
34-
}
35-
s.requires_arc = true
32+
s.subspec 'core' do |core|
33+
core.source_files = 'Pod/Classes/**/*'
34+
core.exclude_files = 'Pod/Classes/MWPhoto.{h,m}'
35+
36+
core.resource_bundles = {
37+
'MWPhotoBrowser' => ['Pod/Assets/*.png']
38+
}
39+
core.requires_arc = true
40+
41+
core.frameworks = 'ImageIO', 'QuartzCore', 'AssetsLibrary', 'MediaPlayer'
42+
core.weak_frameworks = 'Photos'
3643

37-
s.frameworks = 'ImageIO', 'QuartzCore', 'AssetsLibrary', 'MediaPlayer'
38-
s.weak_frameworks = 'Photos'
44+
core.dependency 'MBProgressHUD'
45+
core.dependency 'DACircularProgress', '~> 2.3'
46+
end
3947

40-
s.dependency 'MBProgressHUD', '~> 0.9'
41-
s.dependency 'DACircularProgress', '~> 2.3'
48+
s.subspec 'SDWebImage' do |sdweb|
49+
sdweb.source_files = 'Pod/Classes/MWPhoto.{h,m}'
50+
sdweb.dependency 'MWPhotoBrowser/core'
51+
# SDWebImage
52+
# 3.7.2 contains bugs downloading local files
53+
# https://github.com/rs/SDWebImage/issues/1109
54+
sdweb.dependency 'SDWebImage', '~> 3.7', '!= 3.7.2'
55+
end
4256

43-
# SDWebImage
44-
# 3.7.2 contains bugs downloading local files
45-
# https://github.com/rs/SDWebImage/issues/1109
46-
s.dependency 'SDWebImage', '~> 3.7', '!= 3.7.2'
57+
s.default_subspec = 'SDWebImage'
4758

4859
end

Pod/Classes/MWCaptionView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#import "MWCommon.h"
1010
#import "MWCaptionView.h"
11-
#import "MWPhoto.h"
11+
#import "MWPhotoProtocol.h"
1212

1313
static const CGFloat labelPadding = 10;
1414

Pod/Classes/MWGridCell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
#import <UIKit/UIKit.h>
10-
#import "MWPhoto.h"
10+
#import "MWPhotoProtocol.h"
1111
#import "MWGridViewController.h"
1212

1313
@interface MWGridCell : UICollectionViewCell {}

Pod/Classes/MWPhotoBrowser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
#import <UIKit/UIKit.h>
10-
#import "MWPhoto.h"
1110
#import "MWPhotoProtocol.h"
1211
#import "MWCaptionView.h"
1312

Pod/Classes/MWPhotoBrowser.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#import "MWCommon.h"
1111
#import "MWPhotoBrowser.h"
1212
#import "MWPhotoBrowserPrivate.h"
13-
#import "SDImageCache.h"
1413
#import "UIImage+MWPhotoBrowser.h"
1514

1615
#define PADDING 10
@@ -96,7 +95,6 @@ - (void)dealloc {
9695
_pagingScrollView.delegate = nil;
9796
[[NSNotificationCenter defaultCenter] removeObserver:self];
9897
[self releaseAllUnderlyingPhotos:NO];
99-
[[SDImageCache sharedImageCache] clearMemory]; // clear memory
10098
}
10199

102100
- (void)releaseAllUnderlyingPhotos:(BOOL)preserveCurrent {
@@ -382,7 +380,7 @@ - (void)viewDidAppear:(BOOL)animated {
382380
// Autoplay if first is video
383381
if (!_viewHasAppearedInitially) {
384382
if (_autoPlayOnAppear) {
385-
MWPhoto *photo = [self photoAtIndex:_currentPageIndex];
383+
id<MWPhoto> photo = [self photoAtIndex:_currentPageIndex];
386384
if ([photo respondsToSelector:@selector(isVideo)] && photo.isVideo) {
387385
[self playVideoAtIndex:_currentPageIndex];
388386
}
@@ -1108,7 +1106,7 @@ - (void)updateNavigation {
11081106
_nextButton.enabled = (_currentPageIndex < numberOfPhotos - 1);
11091107

11101108
// Disable action button if there is no image or it's a video
1111-
MWPhoto *photo = [self photoAtIndex:_currentPageIndex];
1109+
id<MWPhoto> photo = [self photoAtIndex:_currentPageIndex];
11121110
if ([photo underlyingImage] == nil || ([photo respondsToSelector:@selector(isVideo)] && photo.isVideo)) {
11131111
_actionButton.enabled = NO;
11141112
_actionButton.tintColor = [UIColor clearColor]; // Tint to hide button

Pod/Classes/MWZoomingScrollView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "MWCommon.h"
1111
#import "MWZoomingScrollView.h"
1212
#import "MWPhotoBrowser.h"
13-
#import "MWPhoto.h"
13+
#import "MWPhotoProtocol.h"
1414
#import "MWPhotoBrowserPrivate.h"
1515
#import "UIImage+MWPhotoBrowser.h"
1616

0 commit comments

Comments
 (0)