ShowEpisodeModel.swift 1.07 KB
Newer Older
Soomin Lee's avatar
Soomin Lee committed
1 2 3 4 5 6 7 8 9 10 11
/*****************************************************************************
 * ShowEpisodeModel.swift
 *
 * Copyright © 2018 VLC authors and VideoLAN
 * Copyright © 2018 Videolabs
 *
 * Authors: Soomin Lee <bubu@mikan.io>
 *
 * Refer to the COPYING file of the official project for license.
 *****************************************************************************/

12
class ShowEpisodeModel: MLBaseModel {
Soomin Lee's avatar
Soomin Lee committed
13 14
    typealias MLType = VLCMLMedia

15 16
    var updateView: (() -> Void)?

Soomin Lee's avatar
Soomin Lee committed
17 18
    var files = [VLCMLMedia]()

19
    var medialibrary: VLCMediaLibraryManager
Soomin Lee's avatar
Soomin Lee committed
20

21
    var indicatorName: String = NSLocalizedString("EPISODES", comment: "")
Soomin Lee's avatar
Soomin Lee committed
22 23

    required init(medialibrary: VLCMediaLibraryManager) {
24
        self.medialibrary = medialibrary
Soomin Lee's avatar
Soomin Lee committed
25 26 27 28 29 30 31 32 33
        medialibrary.addObserver(self)
    }

    func append(_ item: VLCMLMedia) {
        files.append(item)
    }
}

extension ShowEpisodeModel: MediaLibraryObserver {
34 35
    func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddShowEpisodes showEpisodes: [VLCMLMedia]) {
        showEpisodes.forEach({ append($0) })
36
        updateView?()
Soomin Lee's avatar
Soomin Lee committed
37 38
    }
}