Skip to content

Commit

Permalink
Refactor api, setup dataSources
Browse files Browse the repository at this point in the history
  • Loading branch information
xhzengAIB committed Feb 23, 2014
1 parent ee47018 commit 80880ae
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 10 deletions.
3 changes: 1 addition & 2 deletions Project/InstagramThumbnail/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
InstagramCollectionViewController *instagramCollectionViewController = [InstagramPictureCollectionViewController sharedInstagramPictureCollectionViewController];
instagramCollectionViewController.showThumbnail = NO;
InstagramCollectionViewController *instagramCollectionViewController = [InstagramPictureCollectionViewController sharedInstagramCollectionViewController];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:instagramCollectionViewController];
[self.window makeKeyAndVisible];
return YES;
Expand Down
80 changes: 80 additions & 0 deletions Project/InstagramThumbnail/InstagramDataSource.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -17,6 +21,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -25,6 +33,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -33,6 +45,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -41,6 +57,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -49,6 +69,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -57,6 +81,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -65,6 +93,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -73,6 +105,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -81,6 +117,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -89,6 +129,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -97,6 +141,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -105,6 +153,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -113,6 +165,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -121,6 +177,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -129,6 +189,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -137,6 +201,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -145,6 +213,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -153,6 +225,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
<dict>
<key>url</key>
Expand All @@ -161,6 +237,10 @@
<integer>150</integer>
<key>height</key>
<integer>150</integer>
<key>userName</key>
<string>xhzengAIB</string>
<key>caption</key>
<string>InstagramThumbnail is a display thumbnail grid view, based on Instagram App.</string>
</dict>
</array>
</plist>
2 changes: 1 addition & 1 deletion Source/InstagramCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)setEntity:(InstagramMediaModel *)entity andIndexPath:(NSIndexPath *)inde
self.pictureCaptionLabel.text = self.entity.caption;
[self.contentView addSubview:self.pictureCaptionLabel];

[self.userProfileImageView setImage:[UIImage imageNamed:@"InstagramLoading.png"]];
[self.userProfileImageView setImage:[UIImage imageNamed:@"placeholder"]];
[self.contentView addSubview:self.userProfileImageView];

[_entity downloadImageWithBlock:^(UIImage *image, NSError *error) {
Expand Down
2 changes: 2 additions & 0 deletions Source/InstagramCollectionViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static NSString * const kXHInstagramCell = @"InstagramCell";
@property (nonatomic, assign) BOOL hideFooter;
@property (nonatomic, assign) BOOL showThumbnail;

+ (instancetype)sharedInstagramCollectionViewController;

- (void)downloadDataSource;

@end
4 changes: 4 additions & 0 deletions Source/InstagramCollectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ - (id)initWithCollectionViewLayout:(UICollectionViewLayout *)layout{
return self;
}

+ (instancetype)sharedInstagramCollectionViewController {
return nil;
}

- (id)init {
self = [super init];
if (self) {
Expand Down
2 changes: 1 addition & 1 deletion Source/InstagramPictureCollectionViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
#import "InstagramCollectionViewController.h"

@interface InstagramPictureCollectionViewController : InstagramCollectionViewController
+ (instancetype)sharedInstagramPictureCollectionViewController;

@end
6 changes: 4 additions & 2 deletions Source/InstagramPictureCollectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ - (void)_setup {

}

+ (instancetype)sharedInstagramPictureCollectionViewController {
return [[InstagramPictureCollectionViewController alloc] initWithCollectionViewLayout:[UICollectionViewFlowLayout new]];
+ (instancetype)sharedInstagramCollectionViewController {
InstagramPictureCollectionViewController *instagramPictureCollectionViewController = [[InstagramPictureCollectionViewController alloc] initWithCollectionViewLayout:[UICollectionViewFlowLayout new]];
instagramPictureCollectionViewController.showThumbnail = NO;
return instagramPictureCollectionViewController;
}

- (id)init {
Expand Down
2 changes: 1 addition & 1 deletion Source/InstagramThumbnailCollectionViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
#import "InstagramCollectionViewController.h"

@interface InstagramThumbnailCollectionViewController : InstagramCollectionViewController
+ (instancetype)sharedInstagramThumbnailCollectionViewController;

@end
6 changes: 4 additions & 2 deletions Source/InstagramThumbnailCollectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ - (void)_setup {

}

+ (instancetype)sharedInstagramThumbnailCollectionViewController {
return [[InstagramThumbnailCollectionViewController alloc] initWithCollectionViewLayout:[UICollectionViewFlowLayout new]];
+ (instancetype)sharedInstagramCollectionViewController {
InstagramThumbnailCollectionViewController *instagramThumbnailCollectionViewController = [[InstagramThumbnailCollectionViewController alloc] initWithCollectionViewLayout:[UICollectionViewFlowLayout new]];
instagramThumbnailCollectionViewController.showThumbnail = YES;
return instagramThumbnailCollectionViewController;
}

- (id)init {
Expand Down
2 changes: 1 addition & 1 deletion Source/XHInstagramStoreManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (void)mediaWithPage:(NSInteger)page localDownloadDataSourceCompled:(DownloadDa
[mediaArray addObject:[InstagramMediaModel entityWithDictionary:mediaDictionary]];
}
}
NSLog(@"%@", mediaArray);

dispatch_async(dispatch_get_main_queue(), ^{
if (downloadDataSourceCompled) {
downloadDataSourceCompled(mediaArray, nil);
Expand Down

0 comments on commit 80880ae

Please sign in to comment.