Skip to content

Commit

Permalink
Merge pull request #78 from hansemannn/ios-2.0.0
Browse files Browse the repository at this point in the history
refactor: move SDWebImage to 5.4.1
  • Loading branch information
AndreaVitale authored Jan 2, 2020
2 parents 847d93f + 63adf30 commit 14e983c
Show file tree
Hide file tree
Showing 88 changed files with 5,084 additions and 1,239 deletions.
2 changes: 1 addition & 1 deletion ios/Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "SDWebImage/SDWebImage" ~> 4.4.6
github "SDWebImage/SDWebImage" ~> 5.4.1
10 changes: 6 additions & 4 deletions ios/Classes/AvImageviewImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* Copyright (c) 2009-2016 by Appcelerator, Inc. All Rights Reserved.
*/

#import "SDWebImage/FLAnimatedImageView+WebCache.h"
#import "SDWebImage/UIImageView+WebCache.h"
#import <SDWebImage/SDWebImage.h>
#import "TiUIView.h"

@interface AvImageviewImageView : TiUIView {
Expand All @@ -22,16 +21,19 @@
CGFloat autoHeight;
CGFloat autoWidth;

FLAnimatedImageView *imageView;
SDAnimatedImageView *imageView;
UIActivityIndicatorView *activityIndicator;

NSString *placeholderImagePath;
NSString *brokenLinkImagePath;

NSDictionary *requestHeader;
SDWebImageOptions handleCookies;
id imageObject;
BOOL configurationComplete;

// Options
BOOL useCookies;
BOOL avoidDecodeImage;
}

- (void)setWidth_:(id)width;
Expand Down
35 changes: 27 additions & 8 deletions ios/Classes/AvImageviewImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ - (void)initializeState {
[super initializeState];

if (self) {
imageView = [[FLAnimatedImageView alloc] initWithFrame:[self bounds]];
imageView = [[SDAnimatedImageView alloc] initWithFrame:[self bounds]];
imageView.clipsToBounds = YES;

activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
Expand Down Expand Up @@ -116,7 +116,7 @@ - (void)displayImage:(id)imageObj {
return;
}

[imageView sd_cancelCurrentAnimationImagesLoad];
[SDWebImagePrefetcher.sharedImagePrefetcher cancelPrefetching];

if ([imageObj isKindOfClass:[NSString class]]) {
//fix downloading the image if url contains spaces or none ASCII characters
Expand All @@ -135,6 +135,9 @@ - (void)displayImage:(id)imageObj {

[activityIndicator startAnimating];
}

// Set options
SDWebImageOptions imageOptions = [self configureImageOptions];

if ([imageUrl.scheme isEqualToString:@"http"] || [imageUrl.scheme isEqualToString:@"https"]) {
NSString *userAgent = [[TiApp app] userAgent];
Expand All @@ -148,7 +151,7 @@ - (void)displayImage:(id)imageObj {

[imageView sd_setImageWithURL:imageUrl
placeholderImage:placeholderImage
options:handleCookies
options:imageOptions
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *url) {
self->autoWidth = image.size.width;
self->autoHeight = image.size.height;
Expand Down Expand Up @@ -251,6 +254,21 @@ - (void)fadeImage:(SDImageCacheType)cacheType {
}
}

- (SDWebImageOptions)configureImageOptions
{
SDWebImageOptions imageOptions = 0;

if (useCookies) {
imageOptions |= SDWebImageHandleCookies;
}

if (avoidDecodeImage) {
imageOptions |= SDImageCacheAvoidDecodeImage;
}

return imageOptions;
}

#pragma mark Public setter methods

- (void)setWidth_:(id)width_ {
Expand Down Expand Up @@ -305,15 +323,16 @@ - (void)setRequestHeader_:(id)args {
}

- (void)setHandleCookies_:(id)args {
BOOL useCookies = [TiUtils boolValue:args];
if (useCookies) {
handleCookies = SDWebImageHandleCookies;
}
useCookies = [TiUtils boolValue:args];
}

- (void)setAvoidDecodeImage_:(id)args {
avoidDecodeImage = [TiUtils boolValue:args];
}

- (void)setTimeout_:(id)args {
NSTimeInterval timeout = [TiUtils doubleValue:args def:5000] / 1000;
[[SDWebImageDownloader sharedDownloader] setDownloadTimeout:timeout];
SDWebImageDownloaderConfig.defaultDownloaderConfig.downloadTimeout = timeout;
}

#pragma mark utility methodds
Expand Down
16 changes: 4 additions & 12 deletions ios/Classes/AvImageviewModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

#import "AvImageviewModule.h"
#import "SDWebImage/UIImageView+WebCache.h"
#import <SDWebImage/SDWebImage.h>
#import "TiBase.h"
#import "TiHost.h"
#import "TiUtils.h"
Expand All @@ -25,13 +25,6 @@ - (NSString *)moduleId {
return @"av.imageview";
}

#pragma mark Lifecycle

- (void)startup {
[super startup];
DebugLog(@"[DEBUG] %@ loaded", self);
}

#pragma Public APIs

- (void)setShouldCacheImagesInMemory:(id)shouldCacheImagesInMemory {
Expand All @@ -40,18 +33,17 @@ - (void)setShouldCacheImagesInMemory:(id)shouldCacheImagesInMemory {
}

- (void)setShouldDecompressImages:(id)shouldDecompressImages {
ENSURE_SINGLE_ARG(shouldDecompressImages, NSNumber);
[SDImageCache sharedImageCache].config.shouldDecompressImages = [TiUtils boolValue:shouldDecompressImages];
NSLog(@"[ERROR] The \"shouldDecompressImages\" property was removed in AV.ImageView iOS 2.0.0 in favor of the per-image option \"avoidDecodeImage\"!");
}

- (void)setMaxCacheSize:(id)maxCacheSize {
ENSURE_SINGLE_ARG(maxCacheSize, NSNumber);
[SDImageCache sharedImageCache].config.maxCacheSize = [TiUtils intValue:maxCacheSize];
[SDImageCache sharedImageCache].config.maxDiskSize = [TiUtils intValue:maxCacheSize];
}

- (void)setMaxCacheAge:(id)maxCacheAge {
ENSURE_SINGLE_ARG(maxCacheAge, NSNumber);
[SDImageCache sharedImageCache].config.maxCacheAge = [TiUtils intValue:maxCacheAge];
[SDImageCache sharedImageCache].config.maxDiskAge = [TiUtils intValue:maxCacheAge];
}

MAKE_SYSTEM_PROP(CONTENT_MODE_SCALE_TO_FIT, UIViewContentModeScaleToFill)
Expand Down
10 changes: 7 additions & 3 deletions ios/Classes/AvImageviewModuleAssets.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
*/
#import "AvImageviewModuleAssets.h"

extern NSData *filterDataInRange(NSData *thedata, NSRange range);
extern NSData* filterDataInRange(NSData* thedata, NSRange range);

@implementation AvImageviewModuleAssets

- (NSData *)moduleAsset {
- (NSData *)moduleAsset
{


return nil;
}

- (NSData *)resolveModuleAsset:(NSString *)path {
- (NSData *)resolveModuleAsset:(NSString *)path
{


return nil;
}
Expand Down
15 changes: 8 additions & 7 deletions ios/imageview-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,15 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1130;
};
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "imageview-ios" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
Base,
en,
);
mainGroup = 0867D691FE84028FC02AAC07 /* imageview-ios */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
Expand Down Expand Up @@ -237,6 +235,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand Down Expand Up @@ -287,6 +286,7 @@
baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
DSTROOT = /tmp/AvImageview.dst;
Expand Down Expand Up @@ -373,6 +373,7 @@
GCC_WARN_UNUSED_VALUE = NO;
GCC_WARN_UNUSED_VARIABLE = NO;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 8.0.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-DDEBUG",
Expand Down Expand Up @@ -434,7 +435,7 @@
GCC_WARN_UNUSED_VALUE = NO;
GCC_WARN_UNUSED_VARIABLE = NO;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0.0;
OTHER_CFLAGS = "-DTI_POST_1_2";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = AvImageview;
Expand Down
4 changes: 2 additions & 2 deletions ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.5.2
version: 2.0.0
apiversion: 2
architectures: armv7 arm64 i386 x86_64
description: andreavitale-imageview
Expand All @@ -15,4 +15,4 @@ name: andreavitale-imageview
moduleid: av.imageview
guid: ddffa9fa-4366-40f0-9031-d32000a82138
platform: iphone
minsdk: 5.2.0.GA
minsdk: 8.0.0
84 changes: 0 additions & 84 deletions ios/platform/SDWebImage.framework/Headers/FLAnimatedImage.h

This file was deleted.

Loading

0 comments on commit 14e983c

Please sign in to comment.