From c2d3f1b6c4b15f16c67e212568ff8b9b156864f5 Mon Sep 17 00:00:00 2001 From: Eugene Mozharovsky Date: Wed, 25 Jan 2017 00:33:09 +0300 Subject: [PATCH] Small refactoring #18 --- .../ATHImagePickerAssetsViewController.swift | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Examples/ATHImagePickerController/Storyboard/TestPicker/Pods/ATHKit/Source/ATHImagePickerAssetsViewController.swift b/Examples/ATHImagePickerController/Storyboard/TestPicker/Pods/ATHKit/Source/ATHImagePickerAssetsViewController.swift index 3d48562..f5d13cf 100644 --- a/Examples/ATHImagePickerController/Storyboard/TestPicker/Pods/ATHKit/Source/ATHImagePickerAssetsViewController.swift +++ b/Examples/ATHImagePickerController/Storyboard/TestPicker/Pods/ATHKit/Source/ATHImagePickerAssetsViewController.swift @@ -52,6 +52,15 @@ open class ATHImagePickerAssetsViewController: UIViewController, AssetsControlle return fetchResult }() + public lazy var fetchingOptions: PHImageRequestOptions = { + let options = PHImageRequestOptions() + options.deliveryMode = .highQualityFormat + options.isSynchronous = true + options.isNetworkAccessAllowed = true + + return options + }() + public lazy var cachingImageManager = PHCachingImageManager.default() as! PHCachingImageManager public var previousPreheatRect: CGRect = .zero @@ -213,16 +222,11 @@ extension ATHImagePickerAssetsViewController: UICollectionViewDataSource, UIColl let asset = fetchResult[fetchResult.count - indexPath.item - 1] - let options = PHImageRequestOptions() - options.deliveryMode = .highQualityFormat - options.isSynchronous = true - options.isNetworkAccessAllowed = true - cachingImageManager.requestImage( for: asset, targetSize: cellSize, contentMode: .aspectFill, - options: options) { result, info in + options: fetchingOptions) { result, info in DispatchQueue.main.async { cell.photoImageView.image = result } @@ -246,7 +250,7 @@ extension ATHImagePickerAssetsViewController: UICollectionViewDataSource, UIColl for: asset, targetSize: UIScreen.main.bounds.size, contentMode: .aspectFill, - options: nil) { result, info in + options: fetchingOptions) { result, info in if info!["PHImageFileURLKey"] != nil { if let previewController = self.holder.previewController, previewController.state == .folded { let floatingView = self.holder.floatingView