Skip to content

Commit

Permalink
Merge pull request #2 from atone/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Naitong Yu committed Jul 6, 2015
2 parents 48bf550 + 4a8fd2b commit 6630cf4
Show file tree
Hide file tree
Showing 23 changed files with 726 additions and 31 deletions.
1 change: 1 addition & 0 deletions ZSMTH/Frameworks/JTSImageViewController/JTSAnimatedGIFUtility.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@interface JTSAnimatedGIFUtility : NSObject

+ (BOOL)imageURLIsAGIF:(NSString *)imageURL;

+ (BOOL)imageDataIsAGIF:(NSData *)imageData;

/*
Expand Down
Empty file modified ZSMTH/Frameworks/JTSImageViewController/JTSAnimatedGIFUtility.m
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion ZSMTH/Frameworks/JTSImageViewController/JTSImageInfo.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright (c) 2014 Nice Boy LLC. All rights reserved.
//

@import Foundation;
@import UIKit;

@interface JTSImageInfo : NSObject
Expand Down
Empty file modified ZSMTH/Frameworks/JTSImageViewController/JTSImageInfo.m
100755 → 100644
Empty file.
Empty file.
11 changes: 10 additions & 1 deletion ZSMTH/Frameworks/JTSImageViewController/JTSImageViewController.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
#import "UIImage+JTSImageEffects.h"
#import "UIApplication+JTSImageViewController.h"

CG_INLINE CGFLOAT_TYPE JTSImageFloatAbs(CGFLOAT_TYPE aFloat) {
#if CGFLOAT_IS_DOUBLE
return fabs(aFloat);
#else
return fabsf(aFloat);
#endif
}

///--------------------------------------------------------------------------------------------------------------------
/// Definitions
///--------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -547,6 +555,7 @@ - (void)setupImageModeGestureRecognizers {
[self.view addGestureRecognizer:self.longPresserPhoto];

self.panRecognizer = [[UIPanGestureRecognizer alloc] init];
self.panRecognizer.maximumNumberOfTouches = 1;
[self.panRecognizer addTarget:self action:@selector(dismissingPanGestureRecognizerPanned:)];
self.panRecognizer.delegate = self;
[self.scrollView addGestureRecognizer:self.panRecognizer];
Expand Down Expand Up @@ -1594,7 +1603,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
}

CGPoint velocity = [scrollView.panGestureRecognizer velocityInView:scrollView.panGestureRecognizer.view];
if (scrollView.zoomScale == 1 && (fabs(velocity.x) > 1600 || fabs(velocity.y) > 1600 ) ) {
if (scrollView.zoomScale == 1 && (JTSImageFloatAbs(velocity.x) > 1600 || JTSImageFloatAbs(velocity.y) > 1600 ) ) {
[self dismiss:YES];
}
}
Expand Down
1 change: 0 additions & 1 deletion ZSMTH/Frameworks/JTSImageViewController/JTSSimpleImageDownloader.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright (c) 2014 Nice Boy LLC. All rights reserved.
//

@import Foundation;
@import UIKit;

@interface JTSSimpleImageDownloader : NSObject
Expand Down
8 changes: 1 addition & 7 deletions ZSMTH/Frameworks/JTSImageViewController/JTSSimpleImageDownloader.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ + (UIImage *)imageFromData:(NSData *)data forURL:(NSURL *)imageURL canonicalURL:

if (data) {
NSString *referenceURL = (canonicalURL.absoluteString.length) ? canonicalURL.absoluteString : imageURL.absoluteString;
if ([JTSAnimatedGIFUtility imageURLIsAGIF:referenceURL]) {
if ([JTSAnimatedGIFUtility imageURLIsAGIF:referenceURL] || [JTSAnimatedGIFUtility imageDataIsAGIF:data]) {
image = [JTSAnimatedGIFUtility animatedImageWithAnimatedGIFData:data];
}
else if ([JTSAnimatedGIFUtility imageDataIsAGIF:data]) {
image = [JTSAnimatedGIFUtility animatedImageWithAnimatedGIFData:data];
}

if (image == nil) {
image = [[UIImage alloc] initWithData:data];
}
Expand All @@ -74,8 +70,6 @@ + (UIImage *)imageFromData:(NSData *)data forURL:(NSURL *)imageURL canonicalURL:
return image;
}



@end


Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2016 forkingdog ( https://github.com/forkingdog )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#import <UIKit/UIKit.h>

@interface UITableView (FDTemplateLayoutCell)

/// Returns height of cell of type specifed by a reuse identifier and configured
/// by the configuration block.
///
/// The cell would be layed out on a fixed-width, vertically expanding basis with
/// respect to its dynamic content, using auto layout. Thus, it is imperative that
/// the cell was set up to be self-satisfied, i.e. its content always determines
/// its height given the width is equal to the tableview's.
///
/// @param identifier A string identifier for retrieving and maintaining template
/// cells with system's "-dequeueReusableCellWithIdentifier:" call.
/// @param configuration An optional block for configuring and providing content
/// to the template cell. The configuration should be minimal for scrolling
/// performance yet sufficient for calculating cell's height.
///
- (CGFloat)fd_heightForCellWithIdentifier:(NSString *)identifier configuration:(void (^)(id cell))configuration;

/// This method does what "-fd_heightForCellWithIdentifier:configuration" does, and
/// calculated height will be cached by its index path, returns a cached height
/// when needed. Therefore lots of extra height calculations could be saved.
///
/// No need to worry about invalidating cached heights when data source changes, it
/// will be done automatically when you call "-reloadData" or any method that triggers
/// UITableView's reloading.
///
/// @param indexPath where this cell's height cache belongs.
///
- (CGFloat)fd_heightForCellWithIdentifier:(NSString *)identifier cacheByIndexPath:(NSIndexPath *)indexPath configuration:(void (^)(id cell))configuration;

/// Helps to debug or inspect what is this "FDTemplateLayoutCell" extention doing,
/// turning on to print logs when "creating", "calculating", "precaching" or "hitting cache".
///
/// Default to "NO", log by "NSLog".
///
@property (nonatomic, assign) BOOL fd_debugLogEnabled;

@end

@interface UITableViewCell (FDTemplateLayoutCell)

/// Indicate this is a template layout cell for calculation only.
/// You may need this when there are non-UI side effects when configure a cell.
/// Like:
/// - (void)configureCell:(FooCell *)cell atIndexPath:(NSIndexPath *)indexPath {
/// cell.entity = [self entityAtIndexPath:indexPath];
/// if (!cell.fd_isTemplateLayoutCell) {
/// [self notifySomething]; // non-UI side effects
/// }
/// }
///
@property (nonatomic, assign) BOOL fd_isTemplateLayoutCell;

/// Enable to enforce this template layout cell to use "frame layout" rather than "auto layout",
/// and will ask cell's height by calling "-sizeThatFits:", so you must override this method.
/// Note:
/// If no layout constraints have been added to cell's content view, it will automatically
/// switch to "frame layout" mode. Use this property only when you want to manually control
/// this template layout cell's height calculation mode. Default to NO.
///
@property (nonatomic, assign) BOOL fd_enforceFrameLayout;

@end
Loading

0 comments on commit 6630cf4

Please sign in to comment.