Commit fbd54512 by lee

u image cache

parent fcca7788
......@@ -354,6 +354,7 @@
DA4E369E1F188B400007E4D0 /* BUYClient+FilterSoldout.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E369D1F188B400007E4D0 /* BUYClient+FilterSoldout.m */; };
DA4E36A11F18A6CB0007E4D0 /* KWMPageResult.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E36A01F18A6CB0007E4D0 /* KWMPageResult.m */; };
DA7DF8E51F1DB01600D5239B /* NSString+Format.m in Sources */ = {isa = PBXBuildFile; fileRef = DA7DF8E41F1DB01600D5239B /* NSString+Format.m */; };
DA8B97801F58F816002FC38A /* SDImageCache+Resize.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8B977F1F58F816002FC38A /* SDImageCache+Resize.m */; };
DA8D64121F31C67F00B8F4A6 /* DeepLinkURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8D64111F31C67F00B8F4A6 /* DeepLinkURLProtocol.m */; };
DA8D64151F31CD2600B8F4A6 /* DPWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8D64141F31CD2600B8F4A6 /* DPWebViewController.m */; };
DAB6431A1F04CFE5002CD7FE /* AppDelegate+Deeplink.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */; };
......@@ -987,6 +988,8 @@
DA4E36A01F18A6CB0007E4D0 /* KWMPageResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMPageResult.m; sourceTree = "<group>"; };
DA7DF8E31F1DB01600D5239B /* NSString+Format.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Format.h"; sourceTree = "<group>"; };
DA7DF8E41F1DB01600D5239B /* NSString+Format.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Format.m"; sourceTree = "<group>"; };
DA8B977E1F58F816002FC38A /* SDImageCache+Resize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SDImageCache+Resize.h"; sourceTree = "<group>"; };
DA8B977F1F58F816002FC38A /* SDImageCache+Resize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SDImageCache+Resize.m"; sourceTree = "<group>"; };
DA8D64101F31C67F00B8F4A6 /* DeepLinkURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeepLinkURLProtocol.h; sourceTree = "<group>"; };
DA8D64111F31C67F00B8F4A6 /* DeepLinkURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeepLinkURLProtocol.m; sourceTree = "<group>"; };
DA8D64131F31CD2600B8F4A6 /* DPWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DPWebViewController.h; sourceTree = "<group>"; };
......@@ -1341,6 +1344,8 @@
DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */,
DA8D64101F31C67F00B8F4A6 /* DeepLinkURLProtocol.h */,
DA8D64111F31C67F00B8F4A6 /* DeepLinkURLProtocol.m */,
DA8B977E1F58F816002FC38A /* SDImageCache+Resize.h */,
DA8B977F1F58F816002FC38A /* SDImageCache+Resize.m */,
);
path = Class;
sourceTree = "<group>";
......@@ -2678,6 +2683,7 @@
C0DD534D1EE6AE06002D1E0C /* BaseCell.m in Sources */,
C0E8AE091D7D030B00C193DC /* KWMEditAddressVC.m in Sources */,
807AF4A51DC984950000A326 /* KWMCustomerResult.m in Sources */,
DA8B97801F58F816002FC38A /* SDImageCache+Resize.m in Sources */,
C066650F1D7675FC00F02EF4 /* KWMAboutUsVC.m in Sources */,
807AF4A31DC984950000A326 /* KWMBlogResult.m in Sources */,
C0CC14081D7823B0007B5986 /* KWMSizeCell.m in Sources */,
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ad_home_header_placeholder@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -46,7 +46,7 @@
// shopCartModel.price = [item[@"discounted_price"] floatValue] / 100;
shopCartModel.price = [[NSDecimalNumber decimalNumberWithString:[item[@"discounted_price"] stringValue]] decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithDecimal:@(100).decimalValue]];
shopCartModel.line_price = [[NSDecimalNumber decimalNumberWithString:[item[@"line_price"] stringValue]] decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithDecimal:@(100).decimalValue]];
shopCartModel.imageStr = [KWMImageUtil getProductImageUrlByOriginalUrl:item[@"image"] ImageSize:NormalImage];
shopCartModel.imageStr = [KWMImageUtil getProductImageUrlByOriginalUrl:item[@"image"] ImageSize:SmallImage];
shopCartModel.shopCartDict = item;
[datas addObject:shopCartModel];
}
......
//
// SDImageCache+Resize.h
// iCemarose
//
// Created by Sanchew on 2017/9/1.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <SDWebImage/SDImageCache.h>
@interface SDImageCache (Resize)
@end
//
// SDImageCache+Resize.m
// iCemarose
//
// Created by Sanchew on 2017/9/1.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "SDImageCache+Resize.h"
#import <Aspects/Aspects.h>
#import <RegexKitLite/RegexKitLite.h>
#import <SDWebImage/SDWebImageDownloader.h>
#import <AFNetworking/AFNetworking.h>
@implementation SDImageCache (Resize)
+ (void)load {
[self aspect_hookSelector:@selector(queryDiskCacheForKey:done:) withOptions:AspectPositionInstead usingBlock:^(id<AspectInfo> info){
SDWebImageQueryCompletedBlock real = info.arguments[1];
SDWebImageQueryCompletedBlock block = ^(UIImage *image, SDImageCacheType cacheType) {
NSString *reg = @"imageView2/2/w/(\\d+)/h/(\\d+)";
NSArray *sizeM = @[@"150",@"300",@"500",@"1000"];
NSString *imageUrl = info.arguments[0];
if (!image && [imageUrl isMatchedByRegex:reg]) {
NSArray *sizes = [imageUrl captureComponentsMatchedByRegex:reg];
NSUInteger si = [sizeM indexOfObject:sizes[1]];
if (sizeM.count > si + 1) {
NSString *cs = sizeM[si + 1];
NSString *niu = [imageUrl stringByReplacingOccurrencesOfRegex:reg withString:[NSString stringWithFormat:@"imageView2/2/w/%@/h/%@",cs,cs]];
[info.originalInvocation.target queryDiskCacheForKey:niu done:real];
return;
}
}
real(image,cacheType);
};
[info.originalInvocation setArgument:&block atIndex:3];
[info.originalInvocation invoke];
} error:nil];
}
@end
//@implementation SDWebImageDownloader (log)
////- (id <SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock
//
//+ (void)load {
// [self aspect_hookSelector:@selector(downloadImageWithURL:options:progress:completed:) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> info) {
// NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
// AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
// NSString *url = [NSString stringWithFormat:@"http://localhost:3001?c=%@",info.arguments[0]];
// NSURL *URL = [NSURL URLWithString:url];
// NSURLRequest *request = [NSURLRequest requestWithURL:URL];
//
// NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:nil];
// [dataTask resume];
// } error:nil];
//}
//
//@end
......@@ -65,12 +65,12 @@
_focusView = [[SDCycleScrollView alloc] init];
_focusView.delegate = self;
_focusView.translatesAutoresizingMaskIntoConstraints = NO;
_focusView.frame = CGRectMake(0, 0, 375, 190);
// _focusView.frame = CGRectMake(0, 0, UI_SCREEN_WIDTH, 304 * UI_SCREEN_WIDTH / 414);
_focusView.autoScrollTimeInterval = 3;
_focusView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
_focusView.pageDotImage = [UIImage imageNamed:@"ic_page_1"];
_focusView.currentPageDotImage = [UIImage imageNamed:@"ic_page_2"];
_focusView.placeholderImage = [UIImage imageNamed:@"ic_loading"];
_focusView.placeholderImage = [UIImage imageNamed:@"ad_home_header_placeholder"];
_focusView.backgroundColor = [UIColor whiteColor];
[self addSubview:_focusView];
NSDictionary *views = @{ @"v": _focusView };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment