Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Coppercash #372

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions MKNetworkKit/Categories/UIImageView+MKNetworkKitAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,20 @@ -(MKNetworkOperation*) setImageFromURL:(NSURL*) url placeHolderImage:(UIImage*)
if(!imageCacheEngine) imageCacheEngine = DefaultEngine;

if(imageCacheEngine) {
__weak UIImageView *weakSelf = self;
self.imageFetchOperation = [imageCacheEngine imageAtURL:url
size:self.frame.size
completionHandler:^(UIImage *fetchedImage, NSURL *url, BOOL isInCache) {

if(animation) {
[UIView transitionWithView:self.superview
[UIView transitionWithView:weakSelf.superview
duration:isInCache?kFromCacheAnimationDuration:kFreshLoadAnimationDuration
options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction
animations:^{
self.image = fetchedImage;
weakSelf.image = fetchedImage;
} completion:nil];
} else {
self.image = fetchedImage;
weakSelf.image = fetchedImage;
}

} errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
Expand Down
28 changes: 20 additions & 8 deletions MKNetworkKit/MKNetworkOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ - (id)initWithURLString:(NSString *)aURLString

self.credentialPersistence = NSURLCredentialPersistenceForSession;

NSURL *finalURL = nil;

if(params)
self.fieldsToBePosted = [params mutableCopy];
Expand All @@ -642,14 +641,9 @@ - (id)initWithURLString:(NSString *)aURLString
if ([method isEqualToString:@"GET"])
self.cacheHeaders = [NSMutableDictionary dictionary];

if (([method isEqualToString:@"GET"] ||
[method isEqualToString:@"DELETE"]) && (params && [params count] > 0)) {

finalURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@?%@", aURLString,
[self.fieldsToBePosted urlEncodedKeyValueString]]];
} else {
finalURL = [NSURL URLWithString:aURLString];
}
NSURL *finalURL = [NSURL URLWithString:aURLString];


if(finalURL == nil) {

Expand Down Expand Up @@ -678,6 +672,14 @@ - (id)initWithURLString:(NSString *)aURLString
-(void) addParams:(NSDictionary*) paramsDictionary {

[self.fieldsToBePosted addEntriesFromDictionary:paramsDictionary];

if (([self.request.HTTPMethod isEqualToString:@"POST"] ||
[self.request.HTTPMethod isEqualToString:@"PUT"])
&& (self.fieldsToBePosted && [self.fieldsToBePosted count] > 0)) {

self.postDataEncoding = MKNKPostDataEncodingTypeURL;
}

}

-(void) addHeaders:(NSDictionary*) headersDictionary {
Expand Down Expand Up @@ -924,7 +926,17 @@ - (void) start
[self.request.HTTPMethod isEqualToString:@"PATCH"]) && !self.request.HTTPBodyStream) {

[self.request setHTTPBody:[self bodyData]];

}else
if (([self.request.HTTPMethod isEqualToString:@"GET"] ||
[self.request.HTTPMethod isEqualToString:@"DELETE"]) &&
(self.fieldsToBePosted && [self.fieldsToBePosted count] > 0)) {

NSString *link = [NSString stringWithFormat:@"%@?%@", self.request.URL.absoluteString, self.fieldsToBePosted.urlEncodedKeyValueString];
self.request.URL = [NSURL URLWithString:link];

}


dispatch_async(dispatch_get_main_queue(), ^{
self.connection = [[NSURLConnection alloc] initWithRequest:self.request
Expand Down