ShowEpisodeModel.swift 1.03 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 19
    var files = [VLCMLMedia]()


20
    var indicatorName: String = NSLocalizedString("EPISODES", comment: "")
Soomin Lee's avatar
Soomin Lee committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

    required init(medialibrary: VLCMediaLibraryManager) {
        medialibrary.addObserver(self)
    }

    func isIncluded(_ item: VLCMLMedia) {
    }

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

extension ShowEpisodeModel: MediaLibraryObserver {
    func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddShowEpisode showEpisode: [VLCMLMedia]) {
        showEpisode.forEach({ append($0) })
37
        updateView?()
Soomin Lee's avatar
Soomin Lee committed
38 39
    }
}