File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import OSLog
77/// Shows the current graph for a goal
88/// Handles placeholders for loading and queued states, and automatically updates when the goal changes
99class GoalImageView : UIView {
10- private static let downloader = ImageDownloader ( imageCache : AutoPurgingImageCache ( ) )
10+ private static let downloader = ImageDownloadService . shared . downloader
1111 private let logger = Logger ( subsystem: " com.beeminder.com " , category: " GoalImageView " )
1212
1313 private let imageView = UIImageView ( )
Original file line number Diff line number Diff line change 1+ // Part of BeeSwift. Copyright Beeminder
2+
3+ import AlamofireImage
4+
5+ final class ImageDownloadService {
6+ static let shared = ImageDownloadService ( )
7+ let downloader : ImageDownloader
8+
9+ private init ( ) { downloader = ImageDownloader . default }
10+ }
Original file line number Diff line number Diff line change @@ -503,14 +503,13 @@ extension GalleryViewController: UICollectionViewDelegate {
503503 }
504504}
505505
506- // MARK: - Prefetching (using AlamofireImage's ImageDownloader)
507506extension GalleryViewController : UICollectionViewDataSourcePrefetching {
508507 func collectionView( _ collectionView: UICollectionView , prefetchItemsAt indexPaths: [ IndexPath ] ) {
509508 let urls = indexPaths. compactMap { indexPath -> URL ? in
510509 let goal = fetchedResultsController. object ( at: indexPath)
511510 return try ? goal. thumbUrl. asURL ( )
512511 }
513- let downloader = ImageDownloader . default
512+ let downloader = ImageDownloadService . shared . downloader
514513 urls. forEach { downloader. download ( URLRequest ( url: $0) , completion: { _ in } ) }
515514 }
516515}
You can’t perform that action at this time.
0 commit comments