ShowEpisodeModel.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*****************************************************************************
  2. * ShowEpisodeModel.swift
  3. *
  4. * Copyright © 2018 VLC authors and VideoLAN
  5. * Copyright © 2018 Videolabs
  6. *
  7. * Authors: Soomin Lee <bubu@mikan.io>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. class ShowEpisodeModel: MLBaseModel {
  12. typealias MLType = VLCMLMedia
  13. var updateView: (() -> Void)?
  14. var files = [VLCMLMedia]()
  15. var cellType: BaseCollectionViewCell.Type { return MovieCollectionViewCell.self }
  16. var medialibrary: VLCMediaLibraryManager
  17. var indicatorName: String = NSLocalizedString("EPISODES", comment: "")
  18. required init(medialibrary: VLCMediaLibraryManager) {
  19. self.medialibrary = medialibrary
  20. medialibrary.addObserver(self)
  21. }
  22. func append(_ item: VLCMLMedia) {
  23. files.append(item)
  24. }
  25. func delete(_ items: [VLCMLObject]) {
  26. preconditionFailure("ShowEpisodeModel: Cannot delete showEpisode")
  27. }
  28. }
  29. extension ShowEpisodeModel: MediaLibraryObserver {
  30. func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddShowEpisodes showEpisodes: [VLCMLMedia]) {
  31. showEpisodes.forEach({ append($0) })
  32. updateView?()
  33. }
  34. }