GenreModel.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*****************************************************************************
  2. * GenreModel.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 GenreModel: MediaLibraryBaseModel {
  12. typealias MLType = VLCMLGenre
  13. var updateView: (() -> Void)?
  14. var files = [VLCMLGenre]()
  15. var indicatorName: String = NSLocalizedString("GENRE", comment: "")
  16. required init(medialibrary: VLCMediaLibraryManager) {
  17. medialibrary.addObserver(self)
  18. // created too late so missed the callback asking if he has anything
  19. files = medialibrary.genre()
  20. }
  21. func isIncluded(_ item: VLCMLGenre) {
  22. }
  23. func append(_ item: VLCMLGenre) {
  24. // need to check more for duplicate and stuff
  25. files.append(item)
  26. }
  27. }
  28. extension GenreModel: MediaLibraryObserver {
  29. func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddGenre genre: [VLCMLGenre]) {
  30. genre.forEach({ append($0) })
  31. updateView?()
  32. }
  33. }