Selaa lähdekoodia

MediaLibraryModel: Create AudioCollectionModel protocol

Edgar Fouillet 5 vuotta sitten
vanhempi
commit
c4845ae988

+ 1 - 5
SharedSources/MediaLibraryModel/AlbumModel.swift

@@ -9,7 +9,7 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
-class AlbumModel: MLBaseModel {
+class AlbumModel: AudioCollectionModel {
     typealias MLType = VLCMLAlbum
 
     var sortModel = SortModel([.alpha, .duration, .releaseDate, .trackNumber])
@@ -33,10 +33,6 @@ class AlbumModel: MLBaseModel {
     func append(_ item: VLCMLAlbum) {
         files.append(item)
     }
-
-    func delete(_ items: [VLCMLObject]) {
-        preconditionFailure("AlbumModel: Albums can not be deleted, they disappear when their last title got deleted")
-    }
 }
 
 // MARK: - Sort

+ 1 - 5
SharedSources/MediaLibraryModel/ArtistModel.swift

@@ -9,7 +9,7 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
-class ArtistModel: MLBaseModel {
+class ArtistModel: AudioCollectionModel {
     typealias MLType = VLCMLArtist
 
     var sortModel = SortModel([.alpha])
@@ -33,10 +33,6 @@ class ArtistModel: MLBaseModel {
     func append(_ item: VLCMLArtist) {
         files.append(item)
     }
-
-    func delete(_ items: [VLCMLObject]) {
-        preconditionFailure("ArtistModel: Artists can not be deleted, they disappear when their last title got deleted")
-    }
 }
 
 // MARK: - Sort

+ 20 - 0
SharedSources/MediaLibraryModel/AudioCollectionModel.swift

@@ -0,0 +1,20 @@
+/*****************************************************************************
+* AudioCollectionModel.swift
+*
+* Copyright © 2019 VLC authors and VideoLAN
+*
+* Authors: Edgar Fouillet <vlc # edgar.fouillet.eu>
+*
+* Refer to the COPYING file of the official project for license.
+*****************************************************************************/
+
+import Foundation
+
+protocol AudioCollectionModel: MLBaseModel { }
+
+extension AudioCollectionModel {
+
+    func delete(_ items: [VLCMLObject]) {
+        preconditionFailure("AudioCollectionModel: Audio collections can not be deleted, they disappear when their last title got deleted")
+    }
+}

+ 1 - 5
SharedSources/MediaLibraryModel/GenreModel.swift

@@ -9,7 +9,7 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
-class GenreModel: MLBaseModel {
+class GenreModel: AudioCollectionModel {
     typealias MLType = VLCMLGenre
 
     var sortModel = SortModel([.alpha])
@@ -33,10 +33,6 @@ class GenreModel: MLBaseModel {
     func append(_ item: VLCMLGenre) {
         files.append(item)
     }
-
-    func delete(_ items: [VLCMLObject]) {
-        preconditionFailure("GenreModel: Genres can not be deleted, they disappear when their last title got deleted")
-    }
 }
 
 // MARK: - MediaLibraryObserver

+ 4 - 0
VLC.xcodeproj/project.pbxproj

@@ -86,6 +86,7 @@
 		41FCD2F820B565B600660AAB /* VLCAlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41FCD2F720B565B500660AAB /* VLCAlertViewController.swift */; };
 		6B4E33D11BF2A39400A35255 /* playerControl.css in Resources */ = {isa = PBXBuildFile; fileRef = 6B4E33CF1BF2A39400A35255 /* playerControl.css */; };
 		6B4E33D21BF2A39400A35255 /* playerControl.js in Resources */ = {isa = PBXBuildFile; fileRef = 6B4E33D01BF2A39400A35255 /* playerControl.js */; };
+		6D8E642A234CBF2200EBC8FC /* AudioCollectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D8E6429234CBF2200EBC8FC /* AudioCollectionModel.swift */; };
 		7AC8629D1765DC560011611A /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = 7AC8629B1765DC560011611A /* style.css */; };
 		7AC862A61765E9510011611A /* jquery-1.10.1.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 7AC8629E1765E90C0011611A /* jquery-1.10.1.min.js */; };
 		7AC862A71765E9510011611A /* jquery.fileupload.js in Resources */ = {isa = PBXBuildFile; fileRef = 7AC8629F1765E90C0011611A /* jquery.fileupload.js */; };
@@ -565,6 +566,7 @@
 		65EC8984D840047F50AA00A1 /* libPods-VLC-iOSUITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-VLC-iOSUITests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
 		6B4E33CF1BF2A39400A35255 /* playerControl.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = playerControl.css; path = Resources/web/playerControl.css; sourceTree = SOURCE_ROOT; };
 		6B4E33D01BF2A39400A35255 /* playerControl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = playerControl.js; path = Resources/web/playerControl.js; sourceTree = SOURCE_ROOT; };
+		6D8E6429234CBF2200EBC8FC /* AudioCollectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioCollectionModel.swift; sourceTree = "<group>"; };
 		703A80CCC005093CCDFBECBF /* Pods-VLC-iOS-Screenshots.distribution.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-iOS-Screenshots.distribution.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-iOS-Screenshots/Pods-VLC-iOS-Screenshots.distribution.xcconfig"; sourceTree = "<group>"; };
 		7AC8629B1765DC560011611A /* style.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = style.css; sourceTree = "<group>"; };
 		7AC8629E1765E90C0011611A /* jquery-1.10.1.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "jquery-1.10.1.min.js"; sourceTree = "<group>"; };
@@ -1947,6 +1949,7 @@
 		8DE1887221089AF200A091D2 /* MediaLibraryModel */ = {
 			isa = PBXGroup;
 			children = (
+				6D8E6429234CBF2200EBC8FC /* AudioCollectionModel.swift */,
 				8DE1887321089B3A00A091D2 /* MediaLibraryBaseModel.swift */,
 				8DE1887521089BB100A091D2 /* VideoModel.swift */,
 				8DE1888B210B459000A091D2 /* ShowEpisodeModel.swift */,
@@ -2974,6 +2977,7 @@
 				8D144D6322298E8E00984C46 /* AudioMiniPlayer.swift in Sources */,
 				8D4F9B472141630000E478BE /* MediaModel.swift in Sources */,
 				8DF966EF211C643D00D0FCD6 /* PlaylistModel.swift in Sources */,
+				6D8E642A234CBF2200EBC8FC /* AudioCollectionModel.swift in Sources */,
 				9BADAF45185FBD9D00108BD8 /* VLCFrostedGlasView.m in Sources */,
 				41EC28E32136D905004BCF0F /* BaseCollectionViewCell.swift in Sources */,
 				412086362231FE43006A6630 /* UIViewController+VLCAlert.m in Sources */,