[iOS] replace AlamofireImage with custom web image impl

This commit is contained in:
Aleksey Belouosv 2018-12-19 16:12:22 +03:00 committed by Olesia Bolovintseva
parent 8df01649f4
commit 954406338a
48 changed files with 413 additions and 800 deletions

View file

@ -1,6 +1,4 @@
github "Alamofire/Alamofire"
github "Alamofire/AlamofireImage"
github "AppsFlyerSDK/AppsFlyerFramework"
github "facebook/Facebook-SDK-Swift"
github "Pushwoosh/pushwoosh-ios-sdk"
github "skywinder/ActionSheetPicker-3.0"
github "AppsFlyerSDK/AppsFlyerFramework" == 4.8.9
github "facebook/Facebook-SDK-Swift" == 0.4.0
github "Pushwoosh/pushwoosh-ios-sdk" == 5.9.0
github "skywinder/ActionSheetPicker-3.0" == 2.3.0

View file

@ -1,5 +1,3 @@
github "Alamofire/Alamofire" "4.7.3"
github "Alamofire/AlamofireImage" "3.4.1"
github "AppsFlyerSDK/AppsFlyerFramework" "4.8.9"
github "BoltsFramework/Bolts-ObjC" "1.9.0"
github "Pushwoosh/pushwoosh-ios-sdk" "5.9.0"

View file

@ -1,472 +0,0 @@
// Generated by Apple Swift version 4.2 effective-3.4 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgcc-compat"
#if !defined(__has_include)
# define __has_include(x) 0
#endif
#if !defined(__has_attribute)
# define __has_attribute(x) 0
#endif
#if !defined(__has_feature)
# define __has_feature(x) 0
#endif
#if !defined(__has_warning)
# define __has_warning(x) 0
#endif
#if __has_include(<swift/objc-prologue.h>)
# include <swift/objc-prologue.h>
#endif
#pragma clang diagnostic ignored "-Wauto-import"
#include <objc/NSObject.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#if !defined(SWIFT_TYPEDEFS)
# define SWIFT_TYPEDEFS 1
# if __has_include(<uchar.h>)
# include <uchar.h>
# elif !defined(__cplusplus)
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
# endif
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
#endif
#if !defined(SWIFT_PASTE)
# define SWIFT_PASTE_HELPER(x, y) x##y
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
#endif
#if !defined(SWIFT_METATYPE)
# define SWIFT_METATYPE(X) Class
#endif
#if !defined(SWIFT_CLASS_PROPERTY)
# if __has_feature(objc_class_property)
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
# else
# define SWIFT_CLASS_PROPERTY(...)
# endif
#endif
#if __has_attribute(objc_runtime_name)
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
#else
# define SWIFT_RUNTIME_NAME(X)
#endif
#if __has_attribute(swift_name)
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
#else
# define SWIFT_COMPILE_NAME(X)
#endif
#if __has_attribute(objc_method_family)
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
#else
# define SWIFT_METHOD_FAMILY(X)
#endif
#if __has_attribute(noescape)
# define SWIFT_NOESCAPE __attribute__((noescape))
#else
# define SWIFT_NOESCAPE
#endif
#if __has_attribute(warn_unused_result)
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else
# define SWIFT_WARN_UNUSED_RESULT
#endif
#if __has_attribute(noreturn)
# define SWIFT_NORETURN __attribute__((noreturn))
#else
# define SWIFT_NORETURN
#endif
#if !defined(SWIFT_CLASS_EXTRA)
# define SWIFT_CLASS_EXTRA
#endif
#if !defined(SWIFT_PROTOCOL_EXTRA)
# define SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_ENUM_EXTRA)
# define SWIFT_ENUM_EXTRA
#endif
#if !defined(SWIFT_CLASS)
# if __has_attribute(objc_subclassing_restricted)
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# else
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# endif
#endif
#if !defined(SWIFT_PROTOCOL)
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_EXTENSION)
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
#endif
#if !defined(OBJC_DESIGNATED_INITIALIZER)
# if __has_attribute(objc_designated_initializer)
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
# else
# define OBJC_DESIGNATED_INITIALIZER
# endif
#endif
#if !defined(SWIFT_ENUM_ATTR)
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
# else
# define SWIFT_ENUM_ATTR(_extensibility)
# endif
#endif
#if !defined(SWIFT_ENUM)
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
# if __has_feature(generalized_swift_name)
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
# else
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
# endif
#endif
#if !defined(SWIFT_UNAVAILABLE)
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
#endif
#if !defined(SWIFT_UNAVAILABLE_MSG)
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
#endif
#if !defined(SWIFT_AVAILABILITY)
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
#endif
#if !defined(SWIFT_DEPRECATED)
# define SWIFT_DEPRECATED __attribute__((deprecated))
#endif
#if !defined(SWIFT_DEPRECATED_MSG)
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
#endif
#if __has_feature(attribute_diagnose_if_objc)
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
#else
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
#endif
#if __has_feature(modules)
@import Foundation;
@import ObjectiveC;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
#if __has_warning("-Wpragma-clang-attribute")
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
#endif
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wnullability"
#if __has_attribute(external_source_symbol)
# pragma push_macro("any")
# undef any
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="Alamofire",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
# pragma pop_macro("any")
#endif
@class NSURLSession;
@class NSURLSessionTask;
@class NSHTTPURLResponse;
@class NSURLAuthenticationChallenge;
@class NSURLCredential;
@class NSInputStream;
/// The task delegate is responsible for handling all delegate callbacks for the underlying task as well as
/// executing all operations attached to the serial operation queue upon task completion.
SWIFT_CLASS("_TtC9Alamofire12TaskDelegate")
@interface TaskDelegate : NSObject
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task willPerformHTTPRedirection:(NSHTTPURLResponse * _Nonnull)response newRequest:(NSURLRequest * _Nonnull)request completionHandler:(void (^ _Nonnull)(NSURLRequest * _Nullable))completionHandler;
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task didReceiveChallenge:(NSURLAuthenticationChallenge * _Nonnull)challenge completionHandler:(void (^ _Nonnull)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler;
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task needNewBodyStream:(void (^ _Nonnull)(NSInputStream * _Nullable))completionHandler;
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task didCompleteWithError:(NSError * _Nullable)error;
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
+ (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable");
@end
@class NSURLSessionDataTask;
@class NSURLResponse;
@class NSURLSessionDownloadTask;
@class NSCachedURLResponse;
SWIFT_CLASS("_TtC9Alamofire16DataTaskDelegate")
@interface DataTaskDelegate : TaskDelegate <NSURLSessionDataDelegate>
- (void)URLSession:(NSURLSession * _Nonnull)session dataTask:(NSURLSessionDataTask * _Nonnull)dataTask didReceiveResponse:(NSURLResponse * _Nonnull)response completionHandler:(void (^ _Nonnull)(NSURLSessionResponseDisposition))completionHandler;
- (void)URLSession:(NSURLSession * _Nonnull)session dataTask:(NSURLSessionDataTask * _Nonnull)dataTask didBecomeDownloadTask:(NSURLSessionDownloadTask * _Nonnull)downloadTask;
- (void)URLSession:(NSURLSession * _Nonnull)session dataTask:(NSURLSessionDataTask * _Nonnull)dataTask didReceiveData:(NSData * _Nonnull)data;
- (void)URLSession:(NSURLSession * _Nonnull)session dataTask:(NSURLSessionDataTask * _Nonnull)dataTask willCacheResponse:(NSCachedURLResponse * _Nonnull)proposedResponse completionHandler:(void (^ _Nonnull)(NSCachedURLResponse * _Nullable))completionHandler;
@end
SWIFT_CLASS("_TtC9Alamofire20DownloadTaskDelegate")
@interface DownloadTaskDelegate : TaskDelegate <NSURLSessionDownloadDelegate>
- (void)URLSession:(NSURLSession * _Nonnull)session downloadTask:(NSURLSessionDownloadTask * _Nonnull)downloadTask didFinishDownloadingToURL:(NSURL * _Nonnull)location;
- (void)URLSession:(NSURLSession * _Nonnull)session downloadTask:(NSURLSessionDownloadTask * _Nonnull)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite;
- (void)URLSession:(NSURLSession * _Nonnull)session downloadTask:(NSURLSessionDownloadTask * _Nonnull)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes;
@end
/// Responsible for handling all delegate callbacks for the underlying session.
SWIFT_CLASS("_TtC9Alamofire15SessionDelegate")
@interface SessionDelegate : NSObject
/// Initializes the <code>SessionDelegate</code> instance.
///
/// returns:
/// The new <code>SessionDelegate</code> instance.
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
/// Returns a <code>Bool</code> indicating whether the <code>SessionDelegate</code> implements or inherits a method that can respond
/// to a specified message.
/// \param selector A selector that identifies a message.
///
///
/// returns:
/// <code>true</code> if the receiver implements or inherits a method that can respond to selector, otherwise <code>false</code>.
- (BOOL)respondsToSelector:(SEL _Nonnull)selector SWIFT_WARN_UNUSED_RESULT;
@end
@interface SessionDelegate (SWIFT_EXTENSION(Alamofire)) <NSURLSessionDownloadDelegate>
/// Tells the delegate that a download task has finished downloading.
/// \param session The session containing the download task that finished.
///
/// \param downloadTask The download task that finished.
///
/// \param location A file URL for the temporary file. Because the file is temporary, you must either
/// open the file for reading or move it to a permanent location in your apps sandbox
/// container directory before returning from this delegate method.
///
- (void)URLSession:(NSURLSession * _Nonnull)session downloadTask:(NSURLSessionDownloadTask * _Nonnull)downloadTask didFinishDownloadingToURL:(NSURL * _Nonnull)location;
/// Periodically informs the delegate about the downloads progress.
/// \param session The session containing the download task.
///
/// \param downloadTask The download task.
///
/// \param bytesWritten The number of bytes transferred since the last time this delegate
/// method was called.
///
/// \param totalBytesWritten The total number of bytes transferred so far.
///
/// \param totalBytesExpectedToWrite The expected length of the file, as provided by the Content-Length
/// header. If this header was not provided, the value is
/// <code>NSURLSessionTransferSizeUnknown</code>.
///
- (void)URLSession:(NSURLSession * _Nonnull)session downloadTask:(NSURLSessionDownloadTask * _Nonnull)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite;
/// Tells the delegate that the download task has resumed downloading.
/// \param session The session containing the download task that finished.
///
/// \param downloadTask The download task that resumed. See explanation in the discussion.
///
/// \param fileOffset If the files cache policy or last modified date prevents reuse of the
/// existing content, then this value is zero. Otherwise, this value is an
/// integer representing the number of bytes on disk that do not need to be
/// retrieved again.
///
/// \param expectedTotalBytes The expected length of the file, as provided by the Content-Length header.
/// If this header was not provided, the value is NSURLSessionTransferSizeUnknown.
///
- (void)URLSession:(NSURLSession * _Nonnull)session downloadTask:(NSURLSessionDownloadTask * _Nonnull)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes;
@end
@interface SessionDelegate (SWIFT_EXTENSION(Alamofire)) <NSURLSessionDelegate>
/// Tells the delegate that the session has been invalidated.
/// \param session The session object that was invalidated.
///
/// \param error The error that caused invalidation, or nil if the invalidation was explicit.
///
- (void)URLSession:(NSURLSession * _Nonnull)session didBecomeInvalidWithError:(NSError * _Nullable)error;
/// Requests credentials from the delegate in response to a session-level authentication request from the
/// remote server.
/// \param session The session containing the task that requested authentication.
///
/// \param challenge An object that contains the request for authentication.
///
/// \param completionHandler A handler that your delegate method must call providing the disposition
/// and credential.
///
- (void)URLSession:(NSURLSession * _Nonnull)session didReceiveChallenge:(NSURLAuthenticationChallenge * _Nonnull)challenge completionHandler:(void (^ _Nonnull)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler;
/// Tells the delegate that all messages enqueued for a session have been delivered.
/// \param session The session that no longer has any outstanding requests.
///
- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession * _Nonnull)session;
@end
@class NSURLSessionStreamTask;
@class NSOutputStream;
SWIFT_AVAILABILITY(tvos,introduced=9.0) SWIFT_AVAILABILITY(macos,introduced=10.11) SWIFT_AVAILABILITY(ios,introduced=9.0)
@interface SessionDelegate (SWIFT_EXTENSION(Alamofire)) <NSURLSessionStreamDelegate>
/// Tells the delegate that the read side of the connection has been closed.
/// \param session The session.
///
/// \param streamTask The stream task.
///
- (void)URLSession:(NSURLSession * _Nonnull)session readClosedForStreamTask:(NSURLSessionStreamTask * _Nonnull)streamTask;
/// Tells the delegate that the write side of the connection has been closed.
/// \param session The session.
///
/// \param streamTask The stream task.
///
- (void)URLSession:(NSURLSession * _Nonnull)session writeClosedForStreamTask:(NSURLSessionStreamTask * _Nonnull)streamTask;
/// Tells the delegate that the system has determined that a better route to the host is available.
/// \param session The session.
///
/// \param streamTask The stream task.
///
- (void)URLSession:(NSURLSession * _Nonnull)session betterRouteDiscoveredForStreamTask:(NSURLSessionStreamTask * _Nonnull)streamTask;
/// Tells the delegate that the stream task has been completed and provides the unopened stream objects.
/// \param session The session.
///
/// \param streamTask The stream task.
///
/// \param inputStream The new input stream.
///
/// \param outputStream The new output stream.
///
- (void)URLSession:(NSURLSession * _Nonnull)session streamTask:(NSURLSessionStreamTask * _Nonnull)streamTask didBecomeInputStream:(NSInputStream * _Nonnull)inputStream outputStream:(NSOutputStream * _Nonnull)outputStream;
@end
@interface SessionDelegate (SWIFT_EXTENSION(Alamofire)) <NSURLSessionDataDelegate>
/// Tells the delegate that the data task received the initial reply (headers) from the server.
/// \param session The session containing the data task that received an initial reply.
///
/// \param dataTask The data task that received an initial reply.
///
/// \param response A URL response object populated with headers.
///
/// \param completionHandler A completion handler that your code calls to continue the transfer, passing a
/// constant to indicate whether the transfer should continue as a data task or
/// should become a download task.
///
- (void)URLSession:(NSURLSession * _Nonnull)session dataTask:(NSURLSessionDataTask * _Nonnull)dataTask didReceiveResponse:(NSURLResponse * _Nonnull)response completionHandler:(void (^ _Nonnull)(NSURLSessionResponseDisposition))completionHandler;
/// Tells the delegate that the data task was changed to a download task.
/// \param session The session containing the task that was replaced by a download task.
///
/// \param dataTask The data task that was replaced by a download task.
///
/// \param downloadTask The new download task that replaced the data task.
///
- (void)URLSession:(NSURLSession * _Nonnull)session dataTask:(NSURLSessionDataTask * _Nonnull)dataTask didBecomeDownloadTask:(NSURLSessionDownloadTask * _Nonnull)downloadTask;
/// Tells the delegate that the data task has received some of the expected data.
/// \param session The session containing the data task that provided data.
///
/// \param dataTask The data task that provided data.
///
/// \param data A data object containing the transferred data.
///
- (void)URLSession:(NSURLSession * _Nonnull)session dataTask:(NSURLSessionDataTask * _Nonnull)dataTask didReceiveData:(NSData * _Nonnull)data;
/// Asks the delegate whether the data (or upload) task should store the response in the cache.
/// \param session The session containing the data (or upload) task.
///
/// \param dataTask The data (or upload) task.
///
/// \param proposedResponse The default caching behavior. This behavior is determined based on the current
/// caching policy and the values of certain received headers, such as the Pragma
/// and Cache-Control headers.
///
/// \param completionHandler A block that your handler must call, providing either the original proposed
/// response, a modified version of that response, or NULL to prevent caching the
/// response. If your delegate implements this method, it must call this completion
/// handler; otherwise, your app leaks memory.
///
- (void)URLSession:(NSURLSession * _Nonnull)session dataTask:(NSURLSessionDataTask * _Nonnull)dataTask willCacheResponse:(NSCachedURLResponse * _Nonnull)proposedResponse completionHandler:(void (^ _Nonnull)(NSCachedURLResponse * _Nullable))completionHandler;
@end
@class NSURLSessionTaskMetrics;
@interface SessionDelegate (SWIFT_EXTENSION(Alamofire)) <NSURLSessionTaskDelegate>
/// Tells the delegate that the remote server requested an HTTP redirect.
/// \param session The session containing the task whose request resulted in a redirect.
///
/// \param task The task whose request resulted in a redirect.
///
/// \param response An object containing the servers response to the original request.
///
/// \param request A URL request object filled out with the new location.
///
/// \param completionHandler A closure that your handler should call with either the value of the request
/// parameter, a modified URL request object, or NULL to refuse the redirect and
/// return the body of the redirect response.
///
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task willPerformHTTPRedirection:(NSHTTPURLResponse * _Nonnull)response newRequest:(NSURLRequest * _Nonnull)request completionHandler:(void (^ _Nonnull)(NSURLRequest * _Nullable))completionHandler;
/// Requests credentials from the delegate in response to an authentication request from the remote server.
/// \param session The session containing the task whose request requires authentication.
///
/// \param task The task whose request requires authentication.
///
/// \param challenge An object that contains the request for authentication.
///
/// \param completionHandler A handler that your delegate method must call providing the disposition
/// and credential.
///
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task didReceiveChallenge:(NSURLAuthenticationChallenge * _Nonnull)challenge completionHandler:(void (^ _Nonnull)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler;
/// Tells the delegate when a task requires a new request body stream to send to the remote server.
/// \param session The session containing the task that needs a new body stream.
///
/// \param task The task that needs a new body stream.
///
/// \param completionHandler A completion handler that your delegate method should call with the new body stream.
///
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task needNewBodyStream:(void (^ _Nonnull)(NSInputStream * _Nullable))completionHandler;
/// Periodically informs the delegate of the progress of sending body content to the server.
/// \param session The session containing the data task.
///
/// \param task The data task.
///
/// \param bytesSent The number of bytes sent since the last time this delegate method was called.
///
/// \param totalBytesSent The total number of bytes sent so far.
///
/// \param totalBytesExpectedToSend The expected length of the body data.
///
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task didSendBodyData:(int64_t)bytesSent totalBytesSent:(int64_t)totalBytesSent totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend;
/// Tells the delegate that the session finished collecting metrics for the task.
/// \param session The session collecting the metrics.
///
/// \param task The task whose metrics have been collected.
///
/// \param metrics The collected metrics.
///
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task didFinishCollectingMetrics:(NSURLSessionTaskMetrics * _Nonnull)metrics SWIFT_AVAILABILITY(tvos,introduced=10.0) SWIFT_AVAILABILITY(macos,introduced=10.12) SWIFT_AVAILABILITY(ios,introduced=10.0);
/// Tells the delegate that the task finished transferring data.
/// \param session The session containing the task whose request finished transferring data.
///
/// \param task The task whose request finished transferring data.
///
/// \param error If an error occurred, an error object indicating how the transfer failed, otherwise nil.
///
- (void)URLSession:(NSURLSession * _Nonnull)session task:(NSURLSessionTask * _Nonnull)task didCompleteWithError:(NSError * _Nullable)error;
@end
SWIFT_CLASS("_TtC9Alamofire18UploadTaskDelegate")
@interface UploadTaskDelegate : DataTaskDelegate
@end
#if __has_attribute(external_source_symbol)
# pragma clang attribute pop
#endif
#pragma clang diagnostic pop

View file

@ -1,28 +0,0 @@
//
// Alamofire.h
//
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
//
// 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 Foundation;
FOUNDATION_EXPORT double AlamofireVersionNumber;
FOUNDATION_EXPORT const unsigned char AlamofireVersionString[];

View file

@ -1,11 +0,0 @@
framework module Alamofire {
umbrella header "Alamofire.h"
export *
module * { export * }
}
module Alamofire.Swift {
header "Alamofire-Swift.h"
requires objc
}

View file

@ -1,203 +0,0 @@
// Generated by Apple Swift version 4.2 effective-3.4 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgcc-compat"
#if !defined(__has_include)
# define __has_include(x) 0
#endif
#if !defined(__has_attribute)
# define __has_attribute(x) 0
#endif
#if !defined(__has_feature)
# define __has_feature(x) 0
#endif
#if !defined(__has_warning)
# define __has_warning(x) 0
#endif
#if __has_include(<swift/objc-prologue.h>)
# include <swift/objc-prologue.h>
#endif
#pragma clang diagnostic ignored "-Wauto-import"
#include <objc/NSObject.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#if !defined(SWIFT_TYPEDEFS)
# define SWIFT_TYPEDEFS 1
# if __has_include(<uchar.h>)
# include <uchar.h>
# elif !defined(__cplusplus)
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
# endif
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
#endif
#if !defined(SWIFT_PASTE)
# define SWIFT_PASTE_HELPER(x, y) x##y
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
#endif
#if !defined(SWIFT_METATYPE)
# define SWIFT_METATYPE(X) Class
#endif
#if !defined(SWIFT_CLASS_PROPERTY)
# if __has_feature(objc_class_property)
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
# else
# define SWIFT_CLASS_PROPERTY(...)
# endif
#endif
#if __has_attribute(objc_runtime_name)
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
#else
# define SWIFT_RUNTIME_NAME(X)
#endif
#if __has_attribute(swift_name)
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
#else
# define SWIFT_COMPILE_NAME(X)
#endif
#if __has_attribute(objc_method_family)
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
#else
# define SWIFT_METHOD_FAMILY(X)
#endif
#if __has_attribute(noescape)
# define SWIFT_NOESCAPE __attribute__((noescape))
#else
# define SWIFT_NOESCAPE
#endif
#if __has_attribute(warn_unused_result)
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else
# define SWIFT_WARN_UNUSED_RESULT
#endif
#if __has_attribute(noreturn)
# define SWIFT_NORETURN __attribute__((noreturn))
#else
# define SWIFT_NORETURN
#endif
#if !defined(SWIFT_CLASS_EXTRA)
# define SWIFT_CLASS_EXTRA
#endif
#if !defined(SWIFT_PROTOCOL_EXTRA)
# define SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_ENUM_EXTRA)
# define SWIFT_ENUM_EXTRA
#endif
#if !defined(SWIFT_CLASS)
# if __has_attribute(objc_subclassing_restricted)
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# else
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# endif
#endif
#if !defined(SWIFT_PROTOCOL)
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_EXTENSION)
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
#endif
#if !defined(OBJC_DESIGNATED_INITIALIZER)
# if __has_attribute(objc_designated_initializer)
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
# else
# define OBJC_DESIGNATED_INITIALIZER
# endif
#endif
#if !defined(SWIFT_ENUM_ATTR)
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
# else
# define SWIFT_ENUM_ATTR(_extensibility)
# endif
#endif
#if !defined(SWIFT_ENUM)
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
# if __has_feature(generalized_swift_name)
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
# else
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
# endif
#endif
#if !defined(SWIFT_UNAVAILABLE)
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
#endif
#if !defined(SWIFT_UNAVAILABLE_MSG)
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
#endif
#if !defined(SWIFT_AVAILABILITY)
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
#endif
#if !defined(SWIFT_DEPRECATED)
# define SWIFT_DEPRECATED __attribute__((deprecated))
#endif
#if !defined(SWIFT_DEPRECATED_MSG)
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
#endif
#if __has_feature(attribute_diagnose_if_objc)
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
#else
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
#endif
#if __has_feature(modules)
@import UIKit;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
#if __has_warning("-Wpragma-clang-attribute")
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
#endif
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wnullability"
#if __has_attribute(external_source_symbol)
# pragma push_macro("any")
# undef any
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="AlamofireImage",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
# pragma pop_macro("any")
#endif
#if __has_attribute(external_source_symbol)
# pragma clang attribute pop
#endif
#pragma clang diagnostic pop

View file

@ -1,28 +0,0 @@
//
// AlamofireImage.h
//
// Copyright (c) 2015-2018 Alamofire Software Foundation (http://alamofire.org/)
//
// 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 Foundation;
FOUNDATION_EXPORT double AlamofireImageVersionNumber;
FOUNDATION_EXPORT const unsigned char AlamofireImageVersionString[];

View file

@ -1,11 +0,0 @@
framework module AlamofireImage {
umbrella header "AlamofireImage.h"
export *
module * { export * }
}
module AlamofireImage.Swift {
header "AlamofireImage-Swift.h"
requires objc
}

View file

@ -46,14 +46,7 @@ class PaidRouteViewController: MWMViewController {
routeTitleLabel.text = name
routeAuthorLabel.text = author
if let url = imageUrl {
previewImageView.af_setImage(withURL: url,
placeholderImage: nil,
filter: nil,
progress: nil,
progressQueue: DispatchQueue.main,
imageTransition: .crossDissolve(kDefaultAnimationDuration),
runImageTransitionIfCached: true,
completion: nil)
previewImageView.wi_setImage(with: url, transitionDuration: kDefaultAnimationDuration)
}
purchase.requestStoreProduct { [weak self] (product, error) in

View file

@ -74,6 +74,7 @@
#import "UIButton+RuntimeAttributes.h"
#import "UIColor+MapsMeColor.h"
#import "UIFont+MapsMeFonts.h"
#import "UIImageView+WebImage.h"
#import "UIViewController+Navigation.h"
#import "WebViewController.h"
#import "MWMCatalogCategory.h"

View file

@ -0,0 +1,14 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol IMWMImageCache
- (void)imageForKey:(NSString *)imageKey
completion:(void (^)(UIImage * _Nullable image, NSError * _Nullable error))completion;
- (void)setImage:(UIImage *)image forKey:(NSString *)imageKey;
- (void)cleanup;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,21 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol IMWMImageTask <NSObject>
- (void)cancel;
@end
typedef void (^MWMWebImageCompletion)(UIImage * _Nullable image, NSError * _Nullable error);
@protocol IMWMWebImage
- (id<IMWMImageTask>)imageWithUrl:(NSURL *)url
completion:(MWMWebImageCompletion)completion;
- (void)cleanup;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,9 @@
#import "IMWMImageCache.h"
NS_ASSUME_NONNULL_BEGIN
@interface MWMImageCache : NSObject <IMWMImageCache>
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,88 @@
#import "MWMImageCache.h"
#import "NSString+MD5.h"
static NSTimeInterval kCleanupTimeInterval = 30 * 24 * 60 * 60;
@interface MWMImageCache ()
@property (nonatomic, strong) NSCache<NSString *, UIImage *> *cache;
@property (nonatomic, copy) NSString *cacheDirPath;
@property (nonatomic, strong) dispatch_queue_t diskQueue;
@property (nonatomic, strong) NSFileManager *fileManager;
@end
@implementation MWMImageCache
- (instancetype)init {
self = [super init];
if (self) {
_cache = [[NSCache alloc] init];
_cacheDirPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"images"];
_diskQueue = dispatch_queue_create("mapsme.imageCache.disk", DISPATCH_QUEUE_SERIAL);
_fileManager = [NSFileManager defaultManager];
[_fileManager createDirectoryAtPath:_cacheDirPath
withIntermediateDirectories:YES
attributes:nil
error:nil];
}
return self;
}
- (void)imageForKey:(NSString *)imageKey completion:(void (^)(UIImage *image, NSError *error))completion {
UIImage *image = [self.cache objectForKey:imageKey];
if (image) {
completion(image, nil); // TODO: add error
} else {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *path = [self.cacheDirPath stringByAppendingPathComponent:imageKey.md5String];
__block NSData *imageData = nil;
dispatch_sync(self.diskQueue, ^{
imageData = [NSData dataWithContentsOfFile:path];
});
UIImage *image = nil;
if (imageData) {
image = [UIImage imageWithData:imageData];
if (image) {
[self.cache setObject:image forKey:imageKey];
}
}
dispatch_async(dispatch_get_main_queue(), ^{
completion(image, nil); // TODO: add error
});
});
}
}
- (void)setImage:(UIImage *)image forKey:(NSString *)imageKey {
[self.cache setObject:image forKey:imageKey];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *imageData = UIImageJPEGRepresentation(image, 0.9);
if (imageData) {
NSString *path = [self.cacheDirPath stringByAppendingPathComponent:imageKey.md5String];
dispatch_sync(self.diskQueue, ^{
[imageData writeToFile:path atomically:YES];
});
}
});
}
- (void)cleanup {
NSDirectoryEnumerator<NSString *> *enumerator = [self.fileManager enumeratorAtPath:self.cacheDirPath];
for (NSString *fileName in enumerator) {
NSString *path = [self.cacheDirPath stringByAppendingPathComponent:fileName];
NSError *error = nil;
NSDictionary *attributes = [self.fileManager attributesOfItemAtPath:path error:&error];
if (!error) {
NSDate *date = attributes[NSFileCreationDate];
if (fabs(date.timeIntervalSinceNow) > kCleanupTimeInterval) {
dispatch_sync(self.diskQueue, ^{
[self.fileManager removeItemAtPath:path error:nil];
});
}
}
}
}
@end

View file

@ -0,0 +1,20 @@
#import "IMWMWebImage.h"
#import "IMWMImageCache.h"
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface MWMWebImage : NSObject <IMWMWebImage>
+ (MWMWebImage *)defaultWebImage;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithImageCahce:(id<IMWMImageCache>)imageCache;
- (id<IMWMImageTask>)imageWithUrl:(NSURL *)url
completion:(MWMWebImageCompletion)completion;
- (void)cleanup;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,102 @@
#import "MWMWebImage.h"
#import "MWMImageCache.h"
@interface MWMWebImageTask : NSObject <IMWMImageTask>
@property (nonatomic) BOOL cancelled;
@property (nonatomic, strong) NSURLSessionTask *dataTask;
@end
@implementation MWMWebImageTask
- (void)cancel {
self.cancelled = YES;
[self.dataTask cancel];
}
@end
@interface MWMWebImage () <NSURLSessionDelegate>
@property (nonatomic, strong) NSURLSession *urlSession;
@property (nonatomic, strong) id<IMWMImageCache> imageCache;
@end
@implementation MWMWebImage
+ (MWMWebImage *)defaultWebImage {
static MWMWebImage *instanse;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instanse = [[self alloc] initWithImageCahce:[MWMImageCache new]];
});
return instanse;
}
- (instancetype)initWithImageCahce:(id<IMWMImageCache>)imageCache {
self = [super init];
if (self) {
_urlSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]
delegate:self
delegateQueue:nil];
_imageCache = imageCache;
}
return self;
}
- (id<IMWMImageTask>)imageWithUrl:(NSURL *)url
completion:(MWMWebImageCompletion)completion {
MWMWebImageTask *imageTask = [MWMWebImageTask new];
NSString *cacheKey = url.absoluteString;
[self.imageCache imageForKey:cacheKey completion:^(UIImage *image, NSError *error) {
if (imageTask.cancelled) {
return;
}
if (image) {
completion(image, nil);
} else {
NSURLSessionTask *dataTask = [self.urlSession dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
UIImage *image = nil;
if (data) {
image = [UIImage imageWithData:data];
if (image) {
[self.imageCache setImage:image forKey:cacheKey];
}
}
dispatch_async(dispatch_get_main_queue(), ^{
if (!imageTask.cancelled) {
completion(image, error); //TODO: replace error with generic error
}
});
}];
imageTask.dataTask = dataTask;
[dataTask resume];
}
}];
return imageTask;
}
- (void)cleanup {
[self.imageCache cleanup];
}
#pragma mark - NSURLSessionDelegate
#if DEBUG
- (void)URLSession:(NSURLSession *)session
didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition,
NSURLCredential *credential))completionHandler
{
NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
}
#endif
@end

View file

@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSString (MD5)
- (NSString * _Nullable)md5String;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,23 @@
#import "NSString+MD5.h"
#import <CommonCrypto/CommonDigest.h>
@implementation NSString (MD5)
- (NSString *)md5String {
NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
if (data.length == 0) {
return nil;
}
unsigned char buf[CC_MD5_DIGEST_LENGTH];
CC_MD5(data.bytes, (CC_LONG)data.length, buf);
NSMutableString *result = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for (NSInteger i = 0; i < CC_MD5_DIGEST_LENGTH; ++i) {
[result appendFormat:@"%02x", buf[i]];
}
return [result copy];
}
@end

View file

@ -0,0 +1,15 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIImageView (WebImage)
- (void)wi_setImageWithUrl:(NSURL *)url;
- (void)wi_setImageWithUrl:(NSURL *)url
transitionDuration:(NSTimeInterval)duration
completion:(void (^ _Nullable)(UIImage * _Nullable image, NSError * _Nullable error))completion;
- (void)wi_cancelImageRequest;
@end
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,49 @@
#import "UIImageView+WebImage.h"
#import "MWMWebImage.h"
#import <objc/runtime.h>
static char kAssociatedObjectKey;
@implementation UIImageView (WebImage)
- (void)wi_setImageWithUrl:(NSURL *)url {
[self wi_setImageWithUrl:url transitionDuration:0 completion:nil];
}
- (void)wi_setImageWithUrl:(NSURL *)url
transitionDuration:(NSTimeInterval)duration
completion:(void (^)(UIImage *, NSError *))completion {
id<IMWMImageTask> task = [[MWMWebImage defaultWebImage] imageWithUrl:url
completion:^(UIImage *image, NSError *error) {
objc_setAssociatedObject(self, &kAssociatedObjectKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
if (!image) {
if (completion) { completion(nil, error); }
return;
}
if (duration > 0) {
[UIView transitionWithView:self
duration:duration
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
self.image = image;
}
completion:^(BOOL finished) {
if (completion) { completion(image, nil); }
}];
} else {
self.image = image;
if (completion) { completion(image, nil); }
}
}];
objc_setAssociatedObject(self, &kAssociatedObjectKey, task, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (void)wi_cancelImageRequest {
id<IMWMImageTask> task = objc_getAssociatedObject(self, &kAssociatedObjectKey);
[task cancel];
objc_setAssociatedObject(self, &kAssociatedObjectKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end

View file

@ -318,8 +318,6 @@
34D3B04F1E38A20C004100F9 /* Bundle+Init.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D3B04D1E38A20C004100F9 /* Bundle+Init.swift */; };
34D4FA631E26572D003F53EF /* FirstLaunchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D4FA611E26572D003F53EF /* FirstLaunchController.swift */; };
34D4FA671E265749003F53EF /* WhatsNewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D4FA651E265749003F53EF /* WhatsNewController.swift */; };
34D8087B1E793606002F0584 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34D8087A1E793606002F0584 /* Alamofire.framework */; };
34D8087D1E79360D002F0584 /* AlamofireImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34D8087C1E79360D002F0584 /* AlamofireImage.framework */; };
34D808861E793F91002F0584 /* Pushwoosh.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34D808851E793F91002F0584 /* Pushwoosh.framework */; };
34E50DD81F6FCAB1008EED49 /* UGCSummaryRatingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34E50DD51F6FCAB1008EED49 /* UGCSummaryRatingCell.swift */; };
34E50DDB1F6FCAB1008EED49 /* UGCSummaryRatingCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34E50DD61F6FCAB1008EED49 /* UGCSummaryRatingCell.xib */; };
@ -409,6 +407,10 @@
47B06E0021BAAC270094CCAD /* GeoZoneTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47B06DFF21BAAC270094CCAD /* GeoZoneTracker.swift */; };
47B505542136B0C2009CBB55 /* DiscoveryTutorialBlur.xib in Resources */ = {isa = PBXBuildFile; fileRef = 47B505522136AB41009CBB55 /* DiscoveryTutorialBlur.xib */; };
47B505552136B0CF009CBB55 /* SearchTutorialBlur.xib in Resources */ = {isa = PBXBuildFile; fileRef = 47B505532136AD69009CBB55 /* SearchTutorialBlur.xib */; };
47B9065221C7FA400079C85E /* MWMWebImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 47B9064921C7FA3B0079C85E /* MWMWebImage.m */; };
47B9065321C7FA400079C85E /* MWMImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 47B9064A21C7FA3C0079C85E /* MWMImageCache.m */; };
47B9065421C7FA400079C85E /* UIImageView+WebImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 47B9064F21C7FA3E0079C85E /* UIImageView+WebImage.m */; };
47B9065521C7FA400079C85E /* NSString+MD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 47B9065021C7FA3F0079C85E /* NSString+MD5.m */; };
47C7F9732191E15A00C2760C /* InAppBilling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C7F9722191E15A00C2760C /* InAppBilling.swift */; };
47C7F97521930F5300C2760C /* IInAppBilling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C7F97421930F5300C2760C /* IInAppBilling.swift */; };
47D0026721999DA900F651A2 /* PendingTransactionsHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47D0026621999DA900F651A2 /* PendingTransactionsHandler.swift */; };
@ -1439,6 +1441,15 @@
47B06DFF21BAAC270094CCAD /* GeoZoneTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeoZoneTracker.swift; sourceTree = "<group>"; };
47B505522136AB41009CBB55 /* DiscoveryTutorialBlur.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoveryTutorialBlur.xib; sourceTree = "<group>"; };
47B505532136AD69009CBB55 /* SearchTutorialBlur.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SearchTutorialBlur.xib; sourceTree = "<group>"; };
47B9064921C7FA3B0079C85E /* MWMWebImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMWebImage.m; sourceTree = "<group>"; };
47B9064A21C7FA3C0079C85E /* MWMImageCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMImageCache.m; sourceTree = "<group>"; };
47B9064B21C7FA3C0079C85E /* NSString+MD5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MD5.h"; sourceTree = "<group>"; };
47B9064C21C7FA3D0079C85E /* MWMImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMImageCache.h; sourceTree = "<group>"; };
47B9064D21C7FA3D0079C85E /* MWMWebImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMWebImage.h; sourceTree = "<group>"; };
47B9064E21C7FA3E0079C85E /* UIImageView+WebImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+WebImage.h"; sourceTree = "<group>"; };
47B9064F21C7FA3E0079C85E /* UIImageView+WebImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+WebImage.m"; sourceTree = "<group>"; };
47B9065021C7FA3F0079C85E /* NSString+MD5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MD5.m"; sourceTree = "<group>"; };
47B9065121C7FA400079C85E /* IMWMImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IMWMImageCache.h; sourceTree = "<group>"; };
47C7F9722191E15A00C2760C /* InAppBilling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppBilling.swift; sourceTree = "<group>"; };
47C7F97421930F5300C2760C /* IInAppBilling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IInAppBilling.swift; sourceTree = "<group>"; };
47C7F976219310D800C2760C /* IMWMPurchaseValidation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMWMPurchaseValidation.h; sourceTree = "<group>"; };
@ -1456,6 +1467,7 @@
47E6CB092178BA3600EA102B /* SearchBannerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBannerCell.swift; sourceTree = "<group>"; };
47E6CB0A2178BA3600EA102B /* SearchBannerCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SearchBannerCell.xib; sourceTree = "<group>"; };
47EF05B221504D8F00EAC269 /* RemoveAdsPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveAdsPresentationController.swift; sourceTree = "<group>"; };
47F67D0F21CA8F800069754E /* IMWMWebImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMWMWebImage.h; sourceTree = "<group>"; };
47F86CFE20C936FC00FEE291 /* TabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabView.swift; sourceTree = "<group>"; };
47F86D0020C93D8D00FEE291 /* TabViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewController.swift; sourceTree = "<group>"; };
4A00DBDE1AB704C400113624 /* drules_proto_dark.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = drules_proto_dark.bin; path = ../../data/drules_proto_dark.bin; sourceTree = "<group>"; };
@ -1980,8 +1992,6 @@
671E78D31E6A423300B2859B /* librouting_common.a in Frameworks */,
34D808861E793F91002F0584 /* Pushwoosh.framework in Frameworks */,
474C9F5A213FF75800369009 /* StoreKit.framework in Frameworks */,
34D8087B1E793606002F0584 /* Alamofire.framework in Frameworks */,
34D8087D1E79360D002F0584 /* AlamofireImage.framework in Frameworks */,
67B78B551E42333C0018E590 /* AdSupport.framework in Frameworks */,
3466A2DA1FB1C83C005494D3 /* FacebookCore.framework in Frameworks */,
67B78B471E422E0A0018E590 /* MobileCoreServices.framework in Frameworks */,
@ -2347,6 +2357,7 @@
340475281E081A4600C92850 /* Core */ = {
isa = PBXGroup;
children = (
47B9064821C7FA100079C85E /* WebImage */,
473464A8218C688400D6AF5B /* Util */,
470F5A7B2189BA7200754295 /* InappPurchase */,
474C9F602141894300369009 /* Metrics */,
@ -3408,6 +3419,23 @@
path = Impl;
sourceTree = "<group>";
};
47B9064821C7FA100079C85E /* WebImage */ = {
isa = PBXGroup;
children = (
47F67D0F21CA8F800069754E /* IMWMWebImage.h */,
47B9065121C7FA400079C85E /* IMWMImageCache.h */,
47B9064C21C7FA3D0079C85E /* MWMImageCache.h */,
47B9064A21C7FA3C0079C85E /* MWMImageCache.m */,
47B9064D21C7FA3D0079C85E /* MWMWebImage.h */,
47B9064921C7FA3B0079C85E /* MWMWebImage.m */,
47B9064B21C7FA3C0079C85E /* NSString+MD5.h */,
47B9065021C7FA3F0079C85E /* NSString+MD5.m */,
47B9064E21C7FA3E0079C85E /* UIImageView+WebImage.h */,
47B9064F21C7FA3E0079C85E /* UIImageView+WebImage.m */,
);
path = WebImage;
sourceTree = "<group>";
};
47E3C7232111E2F8008B3B27 /* Modal */ = {
isa = PBXGroup;
children = (
@ -4760,8 +4788,6 @@
files = (
);
inputPaths = (
"$(SRCROOT)/3party/Carthage/Build/iOS/Alamofire.framework",
"$(SRCROOT)/3party/Carthage/Build/iOS/AlamofireImage.framework",
"$(SRCROOT)/3party/Carthage/Build/iOS/AppsFlyerTracker.framework",
"$(SRCROOT)/3party/Carthage/Build/iOS/Bolts.framework",
"$(SRCROOT)/3party/Carthage/Build/iOS/FacebookCore.framework",
@ -4778,7 +4804,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/usr/local/bin/carthage copy-frameworks";
shellScript = "/usr/local/bin/carthage copy-frameworks\n";
};
34F7422E1E08328300AC1FD6 /* Crashlytics */ = {
isa = PBXShellScriptBuildPhase;
@ -4959,6 +4985,7 @@
F6E2FECD1E097BA00083EBEC /* MWMSearchFilterTransitioningManager.mm in Sources */,
34D3B0181E389D05004100F9 /* EditorAdditionalNamePlaceholderTableViewCell.swift in Sources */,
346DB8281E5C4F6700E3123E /* GalleryCell.swift in Sources */,
47B9065521C7FA400079C85E /* NSString+MD5.m in Sources */,
33F8BA4121998BEB00ECA8EE /* MWMTag.m in Sources */,
F6EBB26F1FD7E33300B69B6A /* DiscoveryNoResultsCell.swift in Sources */,
47D0026721999DA900F651A2 /* PendingTransactionsHandler.swift in Sources */,
@ -4970,6 +4997,7 @@
F61757ED1FC73027000AD0D0 /* DiscoveryOnlineTemplateCell.swift in Sources */,
F6E2FD5F1E097BA00083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.mm in Sources */,
34F4073B1E9E1AFF00E57AC0 /* MopubBanner.swift in Sources */,
47B9065421C7FA400079C85E /* UIImageView+WebImage.m in Sources */,
F6E2FF481E097BA00083EBEC /* SettingsTableViewSelectableCell.swift in Sources */,
34BBD6581F826F810070CA50 /* AuthorizationTransitioningManager.swift in Sources */,
F6558DA21E642CC0002203AE /* MWMFacilitiesController.mm in Sources */,
@ -5070,6 +5098,7 @@
348A8DF81F66775A00D83026 /* RatingViewDelegate.swift in Sources */,
4716EABA21A325310029B886 /* IPaidRouteStatistics.swift in Sources */,
3490D2E11CE9DD2500D0B838 /* MWMSideButtonsView.mm in Sources */,
47B9065221C7FA400079C85E /* MWMWebImage.m in Sources */,
F6664C021E6459DA00E703C2 /* PPReviewHeaderCell.swift in Sources */,
F6E2FE7C1E097BA00083EBEC /* MWMPlacePageOpeningHoursCell.mm in Sources */,
340E1EFB1E2F614400CE49BF /* Storyboard.swift in Sources */,
@ -5233,6 +5262,7 @@
34AB66891FC5AA330078E451 /* NavigationControlView.swift in Sources */,
34AB661D1FC5AA330078E451 /* MWMTaxiPreviewDataSource.mm in Sources */,
F69CE8D61E5C49B4002B5881 /* PPHotelCarouselCell.swift in Sources */,
47B9065321C7FA400079C85E /* MWMImageCache.m in Sources */,
F6FEA82E1C58F108007223CC /* MWMButton.mm in Sources */,
3445324E1F714FD70059FBCC /* UGCAddReviewController.swift in Sources */,
34B924431DC8A29C0008D971 /* MWMMailViewController.mm in Sources */,

View file

@ -1,4 +1,3 @@
import AlamofireImage
import FBAudienceNetwork
@objc(MWMAdBannerState)
@ -111,7 +110,7 @@ final class AdBanner: UITableViewCell {
@objc weak var mpNativeAd: MPNativeAd?
override func prepareForReuse() {
adIconImageView.af_cancelImageRequest()
adIconImageView.wi_cancelImageRequest()
}
private var nativeAd: Banner? {
@ -248,7 +247,7 @@ final class AdBanner: UITableViewCell {
indent: adPrivacyImage.width + DAAImageWidth.constant)
adBodyLabel.text = ad.text
if let url = URL(string: ad.iconURL) {
adIconImageView.af_setImage(withURL: url)
adIconImageView.wi_setImage(with: url)
}
}

View file

@ -60,7 +60,8 @@ final class DiscoveryBookingCell: UICollectionViewCell {
private func setAvatar(_ avatarURL: String?) {
guard let avatarURL = avatarURL else { return }
if !avatarURL.isEmpty, let url = URL(string: avatarURL) {
avatar.af_setImage(withURL: url, placeholderImage: #imageLiteral(resourceName: "img_localsdefault"), imageTransition: .crossDissolve(kDefaultAnimationDuration))
avatar.image = #imageLiteral(resourceName: "img_localsdefault")
avatar.wi_setImage(with: url, transitionDuration: kDefaultAnimationDuration)
} else {
avatar.image = #imageLiteral(resourceName: "img_localsdefault")
}

View file

@ -38,7 +38,8 @@ final class DiscoveryLocalExpertCell: UICollectionViewCell {
currency: String,
tap: @escaping Tap) {
if avatarURL.count > 0, let url = URL(string: avatarURL) {
avatar.af_setImage(withURL: url, placeholderImage: #imageLiteral(resourceName: "img_localsdefault"), imageTransition: .crossDissolve(kDefaultAnimationDuration))
avatar.image = #imageLiteral(resourceName: "img_localsdefault")
avatar.wi_setImage(with: url, transitionDuration: kDefaultAnimationDuration)
} else {
avatar.image = #imageLiteral(resourceName: "img_localsdefault")
}

View file

@ -3,7 +3,7 @@ final class CarouselElement: UICollectionViewCell {
@IBOutlet private var dimMask: [UIView]!
func config(with url: URL, isLastCell: Bool) {
image.af_setImage(withURL: url, imageTransition: .crossDissolve(kDefaultAnimationDuration))
image.wi_setImage(with: url, transitionDuration: kDefaultAnimationDuration)
dimMask.forEach { $0.isHidden = !isLastCell }
}
}

View file

@ -1,5 +1,3 @@
import AlamofireImage
final class GalleryCell: UICollectionViewCell {
typealias Model = GalleryItemModel
@ -7,11 +5,11 @@ final class GalleryCell: UICollectionViewCell {
var model: Model! {
didSet {
imageView.af_setImage(withURL: model.imageURL, imageTransition: .crossDissolve(kDefaultAnimationDuration))
imageView.wi_setImage(with: model.imageURL, transitionDuration: kDefaultAnimationDuration)
}
}
override func prepareForReuse() {
imageView.af_cancelImageRequest()
imageView.wi_cancelImageRequest()
}
}

View file

@ -1,5 +1,3 @@
import AlamofireImage
@objc(MWMGalleryItemViewController)
final class GalleryItemViewController: MWMViewController {
typealias Model = GalleryItemModel
@ -28,8 +26,7 @@ final class GalleryItemViewController: MWMViewController {
imageView = UIImageView(frame: scrollView.bounds)
imageView.contentMode = .scaleAspectFit
scrollView.addSubview(imageView)
imageView.af_setImage(withURL: model.imageURL,
imageTransition: .crossDissolve(kDefaultAnimationDuration))
imageView.wi_setImage(with: model.imageURL, transitionDuration: kDefaultAnimationDuration)
}
override func viewDidLayoutSubviews() {

View file

@ -1,4 +1,3 @@
import AlamofireImage
import UIKit
final class PhotoScalingView: UIScrollView {
@ -56,15 +55,14 @@ final class PhotoScalingView: UIScrollView {
private func updateImage(_ photo: GalleryItemModel?) {
guard let photo = photo else { return }
imageView.transform = CGAffineTransform.identity
imageView.af_setImage(withURL: photo.imageURL,
imageTransition: .crossDissolve(kDefaultAnimationDuration),
completion: { [weak self] response in
guard let s = self else { return }
s.contentSize = response.value?.size ?? CGSize.zero
s.imageView.frame = CGRect(origin: CGPoint.zero, size: s.contentSize)
s.updateZoomScale()
s.centerScrollViewContents()
})
imageView.wi_setImage(with: photo.imageURL,
transitionDuration: kDefaultAnimationDuration) { [weak self] (image, error) in
guard let s = self else { return }
s.contentSize = image?.size ?? CGSize.zero
s.imageView.frame = CGRect(origin: CGPoint.zero, size: s.contentSize)
s.updateZoomScale()
s.centerScrollViewContents()
}
}
private func updateZoomScale() {