Skip to content

Commit

Permalink
added mattt animated gif serializer and uicollectionview to example
Browse files Browse the repository at this point in the history
  • Loading branch information
heyalexchoi committed Aug 19, 2014
1 parent 5ae2079 commit 8196fa0
Show file tree
Hide file tree
Showing 36 changed files with 5,152 additions and 4,774 deletions.
1,885 changes: 597 additions & 1,288 deletions Example/AXCGiphy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Example/AXCGiphy/AXCCollectionViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AXCCollectionViewCell.h
// AXCGiphy
//
// Created by alexchoi on 8/19/14.
// Copyright (c) 2014 Alex Choi. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AXCCollectionViewCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView * imageView;
@end
37 changes: 37 additions & 0 deletions Example/AXCGiphy/AXCCollectionViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// AXCCollectionViewCell.m
// AXCGiphy
//
// Created by alexchoi on 8/19/14.
// Copyright (c) 2014 Alex Choi. All rights reserved.
//

#import "AXCCollectionViewCell.h"

@implementation AXCCollectionViewCell

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}

- (void) prepareForReuse
{
[super prepareForReuse];
self.imageView.image = nil;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/

@end
38 changes: 36 additions & 2 deletions Example/AXCGiphy/AXCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

#import "AXCViewController.h"
#import <AXCGiphy/AXCGiphy.h>
#import "AXCCollectionViewCell.h"
#import <AnimatedGIFImageSerialization/AnimatedGIFImageSerialization.h>

@interface AXCViewController ()

NSString * const kCollectionViewCellIdentifier = @"cellReuseIdentifier";
@interface AXCViewController () <UICollectionViewDataSource, UICollectionViewDelegate>
@property (strong, nonatomic) NSArray * searchResults;
@property (weak, nonatomic) IBOutlet UICollectionView * collectionView;
@end

@implementation AXCViewController
Expand All @@ -21,6 +25,12 @@ - (void)viewDidLoad
// Do any additional setup after loading the view, typically from a nib.
[AXCGiphy setGiphyAPIKey:kGiphyPublicAPIKey];

[AXCGiphy searchGiphyWithTerm:@"ponies" limit:10 offset:0 completion:^(NSArray *results, NSError *error) {
self.searchResults = results;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.collectionView reloadData];
}];
}];

}

Expand All @@ -30,4 +40,28 @@ - (void)didReceiveMemoryWarning
// Dispose of any resources that can be recreated.
}

#pragma mark UICollectionViewDataSource
- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.searchResults.count;
}
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
AXCCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCollectionViewCellIdentifier forIndexPath:indexPath];
AXCGiphy * gif = self.searchResults[indexPath.item];

NSURLRequest * request = [NSURLRequest requestWithURL:gif.originalImage.url];
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
UIImage * image = [UIImage imageWithData:data];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
cell.imageView.image = image;
}];
}] resume];

return cell;
}
@end
43 changes: 41 additions & 2 deletions Example/AXCGiphy/Base.lproj/Main_iPhone.storyboard
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5023" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--class Prefix:identifier View Controller-->
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="AXCViewController" sceneMemberID="viewController">
Expand All @@ -15,8 +15,47 @@
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<collectionView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" minimumZoomScale="0.0" maximumZoomScale="0.0" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="5Kh-XB-gIj">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="bRL-7c-b1o">
<size key="itemSize" width="320" height="320"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cellReuseIdentifier" id="qMY-ce-nO8" customClass="AXCCollectionViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="320"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="320" height="320"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wx4-zn-6xW">
<rect key="frame" x="0.0" y="0.0" width="320" height="320"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="imageView" destination="wx4-zn-6xW" id="F0I-D6-rbU"/>
</connections>
</collectionViewCell>
</cells>
<connections>
<outlet property="dataSource" destination="vXZ-lx-hvc" id="bGP-H6-9Ae"/>
<outlet property="delegate" destination="vXZ-lx-hvc" id="eWP-Di-rgf"/>
</connections>
</collectionView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="collectionView" destination="5Kh-XB-gIj" id="hxh-tp-h8M"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
Expand Down
Binary file added Example/AXCGiphy/kermit.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 Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
target 'AXCGiphy', :exclusive => true do
pod "AXCGiphy", :path => "../"
pod 'AFNetworking/Serialization', '~> 2.3.1'
pod 'AnimatedGIFImageSerialization', '~> 0.2.0'
end

target 'Tests', :exclusive => true do
Expand Down
3 changes: 3 additions & 0 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PODS:
- AFNetworking/Serialization (2.3.1)
- AnimatedGIFImageSerialization (0.2.0)
- AXCGiphy (0.1.0)
- Expecta (0.3.1)
- Expecta+Snapshots (1.2.1):
Expand All @@ -10,6 +11,7 @@ PODS:

DEPENDENCIES:
- AFNetworking/Serialization (~> 2.3.1)
- AnimatedGIFImageSerialization (~> 0.2.0)
- AXCGiphy (from `../`)
- Expecta
- Expecta+Snapshots
Expand All @@ -22,6 +24,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
AFNetworking: 6d7b76aa5d04c8c37daad3eef4b7e3f2a7620da3
AnimatedGIFImageSerialization: ee2b8f04ec1143dd196cac160a7b119753891825
AXCGiphy: 5e29723820213fb0f53d6627dd44a22ec3cc1e3e
Expecta: 03aabd0a89d8dea843baecb19a7fd7466a69a31d
Expecta+Snapshots: 30c28e3d8104665ee70e32df1cfc030bb37a8a6c
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8196fa0

Please sign in to comment.