Commit 961aacab authored by Soomin Lee's avatar Soomin Lee

Add GenreModel

parent 992f4832
/*****************************************************************************
* GenreModel.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.
*****************************************************************************/
class GenreModel: MediaLibraryBaseModel {
typealias MLType = VLCMLGenre
var files = [VLCMLGenre]()
var view: MediaLibraryModelView?
var indicatorName: String = NSLocalizedString("GENRE", comment: "")
required init(medialibrary: VLCMediaLibraryManager) {
medialibrary.addObserver(self)
// created too late so missed the callback asking if he has anything
files = medialibrary.genre()
}
func isIncluded(_ item: VLCMLGenre) {
}
func append(_ item: VLCMLGenre) {
// need to check more for duplicate and stuff
files.append(item)
}
}
extension GenreModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddGenre genre: [VLCMLGenre]) {
genre.forEach({ append($0) })
view?.dataChanged()
}
}
......@@ -32,6 +32,9 @@
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAlbum album: [VLCMLAlbum])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddGenre genre: [VLCMLGenre])
}
class VLCMediaLibraryManager: NSObject {
......@@ -114,6 +117,10 @@ class VLCMediaLibraryManager: NSObject {
func addMedia(withMrl mrl: URL) {
medialib.addMedia(withMrl: mrl)
}
func genre(sortingCriteria sort: VLCMLSortingCriteria = .default, desc: Bool = false) -> [VLCMLGenre] {
return medialib.genres(with: sort, desc: desc)
}
}
// MARK: - Observer
......
......@@ -38,9 +38,9 @@ class VLCTrackCategoryViewController: VLCMediaCategoryViewController<VLCMLMedia,
}
}
class VLCGenreCategoryViewController: VLCMediaCategoryViewController<String, VideoModel> {
class VLCGenreCategoryViewController: VLCMediaCategoryViewController<String, GenreModel> {
init(_ services: Services) {
let model = VideoModel(medialibrary: services.medialibraryManager)
let model = GenreModel(medialibrary: services.medialibraryManager)
super.init(services: services, category: model)
}
}
......
......@@ -261,6 +261,7 @@
8DE18890210B53E000A091D2 /* AudioModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1888F210B53E000A091D2 /* AudioModel.swift */; };
8DE18892210B5BAD00A091D2 /* ArtistModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE18891210B5BAD00A091D2 /* ArtistModel.swift */; };
8DE18894210B5F8200A091D2 /* AlbumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE18893210B5F8200A091D2 /* AlbumModel.swift */; };
8DE18898210F144B00A091D2 /* GenreModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE18897210F144B00A091D2 /* GenreModel.swift */; };
8F91EC79195CEC7900F5BCBA /* VLCOpenInActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F91EC78195CEC7900F5BCBA /* VLCOpenInActivity.m */; };
8F91EC7F195E1DAB00F5BCBA /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F91EC7E195E1DAB00F5BCBA /* AssetsLibrary.framework */; };
9B088308183D7BEC004B5C2A /* VLCCloudStorageTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B088307183D7BEC004B5C2A /* VLCCloudStorageTableViewController.m */; };
......@@ -953,6 +954,7 @@
8DE1888F210B53E000A091D2 /* AudioModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioModel.swift; sourceTree = "<group>"; };
8DE18891210B5BAD00A091D2 /* ArtistModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArtistModel.swift; sourceTree = "<group>"; };
8DE18893210B5F8200A091D2 /* AlbumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumModel.swift; sourceTree = "<group>"; };
8DE18897210F144B00A091D2 /* GenreModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenreModel.swift; sourceTree = "<group>"; };
8F91EC77195CEC7900F5BCBA /* VLCOpenInActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCOpenInActivity.h; path = Sources/VLCOpenInActivity.h; sourceTree = SOURCE_ROOT; };
8F91EC78195CEC7900F5BCBA /* VLCOpenInActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCOpenInActivity.m; path = Sources/VLCOpenInActivity.m; sourceTree = SOURCE_ROOT; };
8F91EC7E195E1DAB00F5BCBA /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
......@@ -2142,6 +2144,7 @@
8DE1888F210B53E000A091D2 /* AudioModel.swift */,
8DE18891210B5BAD00A091D2 /* ArtistModel.swift */,
8DE18893210B5F8200A091D2 /* AlbumModel.swift */,
8DE18897210F144B00A091D2 /* GenreModel.swift */,
);
path = MediaLibraryModel;
sourceTree = "<group>";
......@@ -3333,6 +3336,7 @@
414396C22023316C005E3FAF /* AppearanceManager.swift in Sources */,
7D30F3DC183AB2F900FFC021 /* VLCNetworkLoginViewController.m in Sources */,
8DE18890210B53E000A091D2 /* AudioModel.swift in Sources */,
8DE18898210F144B00A091D2 /* GenreModel.swift in Sources */,
419A2C661F37A4B70069D224 /* VLCStringsForLocalization.m in Sources */,
DDA1B9091CE902EE0076BC45 /* VLCNetworkServerLoginInformation+Keychain.m in Sources */,
8DE18892210B5BAD00A091D2 /* ArtistModel.swift in Sources */,
......
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