Commit 15ef3e63 authored by Carola Nitz's avatar Carola Nitz

Services: make services properties nonoptional to only call Services() once...

Services: make services properties nonoptional to only call Services() once and use dependency injection
parent 5fb0f5b3
......@@ -14,7 +14,7 @@
public class MediaDataSourceAndDelegate: NSObject, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
private let cellPadding: CGFloat = 5.0
private var services: Services
private var services: Services!
public weak var delegate: UICollectionViewDelegate?
public convenience init(services: Services) {
......@@ -22,11 +22,6 @@ public class MediaDataSourceAndDelegate: NSObject, UICollectionViewDataSource, U
self.services = services
}
public override init() {
self.services = Services()
super.init()
}
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return Int(services.mediaDataSource.numberOfFiles())
}
......
......@@ -19,7 +19,7 @@ import Foundation
}
public class VLCMediaViewController: UICollectionViewController, UISearchResultsUpdating, UISearchControllerDelegate {
private var services: Services
private var services: Services!
private var mediaDatasourceAndDelegate: MediaDataSourceAndDelegate?
private var searchController: UISearchController?
private let searchDataSource = VLCLibrarySearchDisplayDataSource()
......@@ -47,7 +47,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
}
public override init(collectionViewLayout layout: UICollectionViewLayout) {
self.services = Services()
super.init(collectionViewLayout: layout)
}
......
......@@ -16,13 +16,13 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate {
private var childCoordinators: [NSObject] = []
private var tabBarController: UITabBarController
private var services: Services
private var services: Services!
private let displayController = VLCPlayerDisplayController()
public init(tabBarController: UITabBarController, services: Services) {
self.tabBarController = tabBarController
self.services = services
super.init()
self.services = services
NotificationCenter.default.addObserver(self, selector: #selector(updateTheme), name: .VLCThemeDidChangeNotification, object: nil)
}
......
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