Kaynağa Gözat

Add ShowEpisodeModel

Soomin Lee 7 yıl önce
ebeveyn
işleme
f7f2fbc7ba

+ 38 - 0
SharedSources/MediaLibraryModel/ShowEpisodeModel.swift

@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * 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.
+ *****************************************************************************/
+
+class ShowEpisodeModel: MediaLibraryBaseModel {
+    typealias MLType = VLCMLMedia
+
+    var files = [VLCMLMedia]()
+
+    var indicatorName: String = NSLocalizedString("EPISODES", comment: "")
+
+    var notificaitonName: Notification.Name = .VLCEpisodesDidChangeNotification
+
+    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) })
+        NotificationCenter.default.post(name: notificaitonName, object: nil)
+    }
+}

+ 2 - 2
Sources/MediaCategories/MediaCategory.swift

@@ -17,9 +17,9 @@ class VLCMovieCategoryViewController: VLCMediaCategoryViewController<VLCMLMedia,
     }
 }
 
-class VLCShowEpisodeCategoryViewController: VLCMediaCategoryViewController<MLShowEpisode, VideoModel> {
+class VLCShowEpisodeCategoryViewController: VLCMediaCategoryViewController<MLShowEpisode, ShowEpisodeModel> {
     init(_ services: Services) {
-        let model = VideoModel(medialibrary: services.medialibraryManager)
+        let model = ShowEpisodeModel(medialibrary: services.medialibraryManager)
         super.init(services: services, category: model)
     }
 }

+ 4 - 0
VLC.xcodeproj/project.pbxproj

@@ -258,6 +258,7 @@
 		8DE1879A21060DBE00A091D2 /* MediaCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1879921060DBE00A091D2 /* MediaCategory.swift */; };
 		8DE1887421089B3A00A091D2 /* MediaLibraryBaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1887321089B3A00A091D2 /* MediaLibraryBaseModel.swift */; };
 		8DE1887621089BB100A091D2 /* VideoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1887521089BB100A091D2 /* VideoModel.swift */; };
+		8DE1888C210B459000A091D2 /* ShowEpisodeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1888B210B459000A091D2 /* ShowEpisodeModel.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 */; };
@@ -947,6 +948,7 @@
 		8DE1879921060DBE00A091D2 /* MediaCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaCategory.swift; sourceTree = "<group>"; };
 		8DE1887321089B3A00A091D2 /* MediaLibraryBaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaLibraryBaseModel.swift; sourceTree = "<group>"; };
 		8DE1887521089BB100A091D2 /* VideoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoModel.swift; sourceTree = "<group>"; };
+		8DE1888B210B459000A091D2 /* ShowEpisodeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowEpisodeModel.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 @@
 			children = (
 				8DE1887321089B3A00A091D2 /* MediaLibraryBaseModel.swift */,
 				8DE1887521089BB100A091D2 /* VideoModel.swift */,
+				8DE1888B210B459000A091D2 /* ShowEpisodeModel.swift */,
 			);
 			path = MediaLibraryModel;
 			sourceTree = "<group>";
@@ -3244,6 +3247,7 @@
 				DDF908E41CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m in Sources */,
 				8D66A47320AC61B900FA5B92 /* VLCMediaLibraryManager.swift in Sources */,
 				7D378492183A98BF009EE944 /* VLCExternalDisplayController.m in Sources */,
+				8DE1888C210B459000A091D2 /* ShowEpisodeModel.swift in Sources */,
 				4170152C209A1D3600802E44 /* MediaViewController.swift in Sources */,
 				41F9BC7C1F4F20E400268461 /* VLCTrackSelectorView.m in Sources */,
 				41B0948520E6851200DE38AD /* VLCMediaSubcategory.swift in Sources */,