mirror of
https://github.com/zhigang1992/FunctionalReactivePixels.git
synced 2026-01-12 17:22:42 +08:00
Use AFImageDownloader pod
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
5EBE2B16180B07D0007B6BF3 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EBE2AFA180B07D0007B6BF3 /* CoreData.framework */; };
|
||||
5EBE2B1E180B07D0007B6BF3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5EBE2B1C180B07D0007B6BF3 /* InfoPlist.strings */; };
|
||||
5EBE2B2B180B0AF1007B6BF3 /* FRPGalleryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EBE2B2A180B0AF1007B6BF3 /* FRPGalleryViewController.m */; };
|
||||
734185B618776A1500508616 /* NSData+AFDecompression.m in Sources */ = {isa = PBXBuildFile; fileRef = 734185B518776A1500508616 /* NSData+AFDecompression.m */; };
|
||||
F5C87C1873574C63889236C3 /* libPods-FRPTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E5F89E0211BE405E85BE5C5A /* libPods-FRPTests.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@@ -98,8 +97,6 @@
|
||||
5EBE2B1D180B07D0007B6BF3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
5EBE2B29180B0AF1007B6BF3 /* FRPGalleryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPGalleryViewController.h; sourceTree = "<group>"; };
|
||||
5EBE2B2A180B0AF1007B6BF3 /* FRPGalleryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPGalleryViewController.m; sourceTree = "<group>"; };
|
||||
734185B418776A1500508616 /* NSData+AFDecompression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+AFDecompression.h"; sourceTree = "<group>"; };
|
||||
734185B518776A1500508616 /* NSData+AFDecompression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+AFDecompression.m"; sourceTree = "<group>"; };
|
||||
772BE9E4C5824F1C8E5CDC45 /* libPods-FRP.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-FRP.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C5AC1B577BDC442AA756B515 /* Pods-FRPTests.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FRPTests.xcconfig"; path = "Pods/Pods-FRPTests.xcconfig"; sourceTree = "<group>"; };
|
||||
CF6C5FA73F5F4703A3C7C4C0 /* Pods-FRP.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FRP.xcconfig"; path = "Pods/Pods-FRP.xcconfig"; sourceTree = "<group>"; };
|
||||
@@ -259,8 +256,6 @@
|
||||
5EBE2AFC180B07D0007B6BF3 /* FRP */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
734185B418776A1500508616 /* NSData+AFDecompression.h */,
|
||||
734185B518776A1500508616 /* NSData+AFDecompression.m */,
|
||||
5EBE2B05180B07D0007B6BF3 /* FRPAppDelegate.h */,
|
||||
5EBE2B06180B07D0007B6BF3 /* FRPAppDelegate.m */,
|
||||
5EBC59A4180B2AA200B683A7 /* FRPPhotoImporter.h */,
|
||||
@@ -478,7 +473,6 @@
|
||||
5E59511A180E21E0002F44FA /* FRPPhotoDetailViewController.m in Sources */,
|
||||
5E595117180E0C33002F44FA /* FRPPhotoViewController.m in Sources */,
|
||||
5EBC59A6180B2AA200B683A7 /* FRPPhotoImporter.m in Sources */,
|
||||
734185B618776A1500508616 /* NSData+AFDecompression.m in Sources */,
|
||||
5EBE2B2B180B0AF1007B6BF3 /* FRPGalleryViewController.m in Sources */,
|
||||
5E730B141815FE97003FCB43 /* FRPFullSizePhotoViewModel.m in Sources */,
|
||||
5EAD1F5818173A3200C67860 /* FRPPhotoViewModel.m in Sources */,
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
//
|
||||
// NSData+AFDecompression.h
|
||||
// Performance Problems Example
|
||||
//
|
||||
// Created by Ash Furrow on 2012-12-28.
|
||||
// Copyright (c) 2012 Ash Furrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ReactiveCocoa/ReactiveCocoa.h"
|
||||
|
||||
typedef void (^AFJPEGWasDecompressedCallback)(UIImage *decompressedImage);
|
||||
|
||||
@interface NSData (AFDecompression)
|
||||
|
||||
// The callback block is executed on the main thread.
|
||||
-(void)af_decompressedImageFromJPEGDataWithCallback:(AFJPEGWasDecompressedCallback)callback;
|
||||
|
||||
@end
|
||||
@@ -1,96 +0,0 @@
|
||||
//
|
||||
// NSData+AFDecompression.m
|
||||
// Performance Problems Example
|
||||
//
|
||||
// Created by Ash Furrow on 2012-12-28.
|
||||
// Copyright (c) 2012 Ash Furrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSData+AFDecompression.h"
|
||||
|
||||
// Rounds numbers up to the specified multiple
|
||||
NSInteger roundUp(NSInteger numToRound, NSInteger multiple)
|
||||
{
|
||||
if(multiple == 0)
|
||||
{
|
||||
return numToRound;
|
||||
}
|
||||
|
||||
NSInteger remainder = numToRound % multiple;
|
||||
if (remainder == 0)
|
||||
{
|
||||
return numToRound;
|
||||
}
|
||||
|
||||
return numToRound + multiple - remainder;
|
||||
}
|
||||
|
||||
@implementation NSData (AFDecompression)
|
||||
|
||||
-(void)af_decompressedImageFromJPEGDataWithCallback:(AFJPEGWasDecompressedCallback)callback
|
||||
{
|
||||
uint8_t character = '\0';
|
||||
if (self.length > 0) {
|
||||
[self getBytes:&character length:1];
|
||||
}
|
||||
|
||||
if (character != 0xFF)
|
||||
{
|
||||
// This is not a valid JPEG.
|
||||
callback(nil);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Creates a data provider, referencing ourself as the data.
|
||||
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)self);
|
||||
|
||||
// Use the data provider to get a CGImage and release the data provider.
|
||||
CGImageRef image = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, NO, kCGRenderingIntentDefault);
|
||||
CGDataProviderRelease(dataProvider);
|
||||
|
||||
// Create a bitmap context of a suitable size to draw to, forcing decode
|
||||
size_t width = CGImageGetWidth(image);
|
||||
size_t height = CGImageGetHeight(image);
|
||||
size_t bytesPerRow = roundUp(width * 4, 16);
|
||||
size_t byteCount = roundUp(height * bytesPerRow, 16);
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
CGImageRelease(image);
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
callback(nil);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the colour space and an image buffer
|
||||
void *imageBuffer = malloc(byteCount);
|
||||
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
|
||||
|
||||
// Create the image context and release the colour space.
|
||||
CGContextRef imageContext = CGBitmapContextCreate(imageBuffer, width, height, 8, bytesPerRow, colourSpace, kCGImageAlphaNone | kCGImageAlphaNoneSkipLast);
|
||||
CGColorSpaceRelease(colourSpace);
|
||||
|
||||
// Draw the image to the context and release it.
|
||||
CGContextDrawImage(imageContext, CGRectMake(0, 0, width, height), image);
|
||||
CGImageRelease(image);
|
||||
|
||||
// Now get an image ref from the context.
|
||||
CGImageRef outputImage = CGBitmapContextCreateImage(imageContext);
|
||||
|
||||
// Clean up memory allocated by the colour space and image buffer.
|
||||
CGContextRelease(imageContext);
|
||||
free(imageBuffer);
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
UIImage *image = [UIImage imageWithCGImage:outputImage];
|
||||
callback(image);
|
||||
// Release the output image after the callback has been completed.
|
||||
CGImageRelease(outputImage);
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
3
Podfile
3
Podfile
@@ -7,7 +7,7 @@ pod 'ReactiveViewModel', '0.1.1'
|
||||
pod 'libextobjc', '0.3'
|
||||
pod '500px-iOS-api', '1.0.5'
|
||||
pod 'SVProgressHUD', '1.0'
|
||||
|
||||
pod 'AFImageDownloader', '1.0.0'
|
||||
end
|
||||
|
||||
target "FRPTests" do
|
||||
@@ -19,5 +19,6 @@ pod '500px-iOS-api', '1.0.5'
|
||||
pod 'Specta', '~> 0.2.1'
|
||||
pod 'Expecta', '~> 0.2'
|
||||
pod 'OCMock', '~> 2.2.2'
|
||||
pod 'AFImageDownloader', '1.0.0'
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
PODS:
|
||||
- 500px-iOS-api (1.0.5)
|
||||
- AFImageDownloader (1.0.0):
|
||||
- Kiwi (~> 1.1.1)
|
||||
- Expecta (0.2.3)
|
||||
- Kiwi (1.1.1)
|
||||
- libextobjc (0.3):
|
||||
- libextobjc/EXTADT
|
||||
- libextobjc/EXTAnnotation
|
||||
@@ -100,6 +103,7 @@ PODS:
|
||||
|
||||
DEPENDENCIES:
|
||||
- 500px-iOS-api (= 1.0.5)
|
||||
- AFImageDownloader (= 1.0.0)
|
||||
- Expecta (~> 0.2)
|
||||
- libextobjc (= 0.3)
|
||||
- OCMock (~> 2.2.2)
|
||||
@@ -110,7 +114,9 @@ DEPENDENCIES:
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
500px-iOS-api: b67f7b641d79737eb26478d4e07cc1610314521c
|
||||
AFImageDownloader: 4c385edcac3cea688c21b99d824ba6e73c190141
|
||||
Expecta: dbc4a27fabb853bdd2e907e33f11ee43a9a47d0c
|
||||
Kiwi: ab0fa8d13b97dca05915e31df9b2d888d74ab717
|
||||
libextobjc: 820a79dbbbc498611e04fffd07d2d52a5588e7ac
|
||||
libffi: 64ef39353e747bb2b25e1026afd96a157bf9231c
|
||||
OCMock: ffba68873fd32cfd35d885bddad23bfa816da4a3
|
||||
|
||||
Reference in New Issue
Block a user