Commit 6c1282ad authored by Soomin Lee's avatar Soomin Lee

VLCMediaCategoryViewController: Move delegate into VC

parent 5addb093
......@@ -27,15 +27,10 @@ class VLCAudioViewController: VLCMediaViewController {
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
let tracks = VLCMediaCategoryViewController<MLFile>(services: services, subcategory: VLCMediaSubcategories.tracks)
tracks.delegate = super.self()
let genres = VLCMediaCategoryViewController<String>(services: services, subcategory: VLCMediaSubcategories.genres)
genres.delegate = super.self()
let artists = VLCMediaCategoryViewController<String>(services: services, subcategory: VLCMediaSubcategories.artists)
artists.delegate = super.self()
let albums = VLCMediaCategoryViewController<MLAlbum>(services: services, subcategory: VLCMediaSubcategories.albums)
albums.delegate = super.self()
let playlists = VLCMediaCategoryViewController<MLLabel>(services: services, subcategory: VLCMediaSubcategories.audioPlaylists)
playlists.delegate = super.self()
return [tracks, genres, artists, albums, playlists]
}
}
......@@ -77,17 +77,3 @@ class VLCMediaViewController: VLCPagingViewController<VLCLabelCell> {
return PresentationTheme.current.colors.statusBarStyle
}
}
// MARK: - VLCMediaCategoryViewControllerDelegate
extension VLCMediaViewController: VLCMediaCategoryViewControllerDelegate {
func mediaViewControllerDidSelectMediaObject(_ viewcontroller: UIViewController, mediaObject: NSManagedObject) {
playMedia(media: mediaObject)
}
func playMedia(media: NSManagedObject) {
//that should go into a Coordinator itself
let vpc = VLCPlaybackController.sharedInstance()
vpc?.playMediaLibraryObject(media)
}
}
......@@ -27,11 +27,8 @@ class VLCVideoViewController: VLCMediaViewController {
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
let movies = VLCMediaCategoryViewController<MLFile>(services: services, subcategory: VLCMediaSubcategories.movies)
movies.delegate = super.self()
let episodes = VLCMediaCategoryViewController<MLShowEpisode>(services: services, subcategory: VLCMediaSubcategories.episodes)
episodes.delegate = super.self()
let playlists = VLCMediaCategoryViewController<MLLabel>(services: services, subcategory: VLCMediaSubcategories.videoPlaylists)
playlists.delegate = super.self()
return [movies, episodes, playlists]
}
}
......@@ -13,17 +13,12 @@
import Foundation
protocol VLCMediaCategoryViewControllerDelegate: class {
func mediaViewControllerDidSelectMediaObject(_ mediaViewController: UIViewController, mediaObject: NSManagedObject)
}
class VLCMediaCategoryViewController<T>: UICollectionViewController, UICollectionViewDelegateFlowLayout, UISearchResultsUpdating, UISearchControllerDelegate, IndicatorInfoProvider {
let cellPadding: CGFloat = 5.0
private var services: Services
private var searchController: UISearchController?
private let searchDataSource = VLCLibrarySearchDisplayDataSource()
var subcategory: VLCMediaSubcategoryModel<T>
weak var delegate: VLCMediaCategoryViewControllerDelegate?
@available(iOS 11.0, *)
lazy var dragAndDropManager: VLCDragAndDropManager = { () -> VLCDragAndDropManager<T> in
......@@ -176,7 +171,7 @@ class VLCMediaCategoryViewController<T>: UICollectionViewController, UICollectio
// MARK: - UICollectionViewDelegate
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let mediaObject = subcategory.files[indexPath.row] as? NSManagedObject {
delegate?.mediaViewControllerDidSelectMediaObject(self, mediaObject: mediaObject)
play(mediaObject: mediaObject)
}
}
......@@ -207,3 +202,11 @@ class VLCMediaCategoryViewController<T>: UICollectionViewController, UICollectio
return cellPadding
}
}
// MARK: - Player
extension VLCMediaCategoryViewController {
func play(mediaObject: NSManagedObject) {
VLCPlaybackController.sharedInstance().playMediaLibraryObject(mediaObject)
}
}
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