Bladeren bron

Add MediaLibraryBaseModel

Soomin Lee 7 jaren geleden
bovenliggende
commit
488184d913

+ 38 - 0
SharedSources/MediaLibraryModel/MediaLibraryBaseModel.swift

@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * MediaLibraryBaseModel.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.
+ *****************************************************************************/
+
+extension Notification.Name {
+    static let VLCMoviesDidChangeNotification = Notification.Name("MoviesDidChangeNotfication")
+    static let VLCEpisodesDidChangeNotification = Notification.Name("EpisodesDidChangeNotfication")
+    static let VLCArtistsDidChangeNotification = Notification.Name("ArtistsDidChangeNotfication")
+    static let VLCAlbumsDidChangeNotification = Notification.Name("AlbumsDidChangeNotfication")
+    static let VLCTracksDidChangeNotification = Notification.Name("TracksDidChangeNotfication")
+    static let VLCGenresDidChangeNotification = Notification.Name("GenresDidChangeNotfication")
+    static let VLCAudioPlaylistsDidChangeNotification = Notification.Name("AudioPlaylistsDidChangeNotfication")
+    static let VLCVideoPlaylistsDidChangeNotification = Notification.Name("VideoPlaylistsDidChangeNotfication")
+    static let VLCVideosDidChangeNotification = Notification.Name("VideosDidChangeNotfication")
+}
+
+protocol MediaLibraryBaseModel {
+    associatedtype MLType where MLType: VLCMLObject
+
+    var files: [MLType] { get set }
+
+    var indicatorName: String { get }
+    var notificaitonName: Notification.Name { get }
+
+    // mutating will depend if we need to handle struc/enum
+    func append(_ item: MLType)
+    func isIncluded(_ item: MLType)
+}
+
+// protocol can be extended to have the "generic methods" that
+// childs will share. No need an in-between class

+ 0 - 12
Sources/MediaSubcategory/VLCMediaSubcategory.swift

@@ -11,18 +11,6 @@
  *****************************************************************************/
 import Foundation
 
-extension Notification.Name {
-    static let VLCMoviesDidChangeNotification = Notification.Name("MoviesDidChangeNotfication")
-    static let VLCEpisodesDidChangeNotification = Notification.Name("EpisodesDidChangeNotfication")
-    static let VLCArtistsDidChangeNotification = Notification.Name("ArtistsDidChangeNotfication")
-    static let VLCAlbumsDidChangeNotification = Notification.Name("AlbumsDidChangeNotfication")
-    static let VLCTracksDidChangeNotification = Notification.Name("TracksDidChangeNotfication")
-    static let VLCGenresDidChangeNotification = Notification.Name("GenresDidChangeNotfication")
-    static let VLCAudioPlaylistsDidChangeNotification = Notification.Name("AudioPlaylistsDidChangeNotfication")
-    static let VLCVideoPlaylistsDidChangeNotification = Notification.Name("VideoPlaylistsDidChangeNotfication")
-    static let VLCVideosDidChangeNotification = Notification.Name("VideosDidChangeNotfication")
-}
-
 enum VLCDataUnit {
     case file(VLCMLMedia)
     case episode(MLShowEpisode)

+ 4 - 0
VLC.xcodeproj/project.pbxproj

@@ -256,6 +256,7 @@
 		8DE187812105DAB100A091D2 /* VideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE187802105DAB100A091D2 /* VideoViewController.swift */; };
 		8DE187832105DB2E00A091D2 /* AudioViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE187822105DB2E00A091D2 /* AudioViewController.swift */; };
 		8DE1879A21060DBE00A091D2 /* MediaCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1879921060DBE00A091D2 /* MediaCategory.swift */; };
+		8DE1887421089B3A00A091D2 /* MediaLibraryBaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1887321089B3A00A091D2 /* MediaLibraryBaseModel.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 */; };
@@ -943,6 +944,7 @@
 		8DE187802105DAB100A091D2 /* VideoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoViewController.swift; sourceTree = "<group>"; };
 		8DE187822105DB2E00A091D2 /* AudioViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioViewController.swift; sourceTree = "<group>"; };
 		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>"; };
 		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; };
@@ -2136,6 +2138,7 @@
 		8DE1887221089AF200A091D2 /* MediaLibraryModel */ = {
 			isa = PBXGroup;
 			children = (
+				8DE1887321089B3A00A091D2 /* MediaLibraryBaseModel.swift */,
 			);
 			path = MediaLibraryModel;
 			sourceTree = "<group>";
@@ -3268,6 +3271,7 @@
 				7DF9352F1958AB0600E60FD4 /* UIColor+Presets.m in Sources */,
 				41F5C0781F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.m in Sources */,
 				7DBBF182183AB3B80009A339 /* VLCAppDelegate.m in Sources */,
+				8DE1887421089B3A00A091D2 /* MediaLibraryBaseModel.swift in Sources */,
 				418B145020179CB9000447AA /* LayoutAnchorContainer.swift in Sources */,
 				7D3784C0183A9938009EE944 /* VLCLinearProgressIndicator.m in Sources */,
 				41CD695D1A29D72600E60BCE /* VLCBoxTableViewController.m in Sources */,