[vlc-commits] [Git][videolan/vlc][master] 5 commits: macosx: Split up reloading of table views and collection views into separate...

François Cartegnie (@fcartegnie) gitlab at videolan.org
Sat Dec 23 14:45:09 UTC 2023



François Cartegnie pushed to branch master at VideoLAN / VLC


Commits:
7623709c by Claudio Cambra at 2023-12-23T14:29:05+00:00
macosx: Split up reloading of table views and collection views into separate methods in VLCLibraryAudioGroupDataSource

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
4c68a3a4 by Claudio Cambra at 2023-12-23T14:29:05+00:00
macsox: Add observeValueForKeyPath for tableViews and collectionViews properties in VLCLibraryAudioGroupDataSource

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
3ee27028 by Claudio Cambra at 2023-12-23T14:29:05+00:00
macosx: Add observers for collectionViews and tableViews properties in VLCLibraryAudioGroupDataSource

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
654721cc by Claudio Cambra at 2023-12-23T14:29:05+00:00
macosx: Respond to VLCLibraryModel refreshing all audio items in VLCLibraryAudioGroupDataSource

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
1d6aab56 by Claudio Cambra at 2023-12-23T14:29:05+00:00
macosx: Handle media item albums when media library is not fully loaded and 0 albums available in VLCLibraryAudioGroupDataSource

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


1 changed file:

- modules/gui/macosx/library/audio-library/VLCLibraryAudioGroupDataSource.m


Changes:

=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioGroupDataSource.m
=====================================
@@ -61,23 +61,80 @@
                  withIdentifier:VLCLibraryAudioGroupHeaderViewIdentifier];
 }
 
-- (void)reloadViews
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        [self setup];
+    }
+    return self;
+}
+
+- (void)setup
+{
+    [self addObserver:self forKeyPath:@"collectionViews" options:NSKeyValueObservingOptionNew context:nil];
+    [self addObserver:self forKeyPath:@"tableViews" options:NSKeyValueObservingOptionNew context:nil];
+
+    NSNotificationCenter * const notificationCenter = NSNotificationCenter.defaultCenter;
+    [notificationCenter addObserver:self
+                           selector:@selector(libraryModelAudioMediaItemsReset:)
+                               name:VLCLibraryModelAudioMediaListReset
+                             object:nil];
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath
+                      ofObject:(id)object
+                        change:(NSDictionary *)change
+                       context:(void *)context
 {
-    for (NSTableView * const tableView in _tableViews) {
+    if (object != self) {
+        return;
+    }
+
+    if ([keyPath isEqualToString:@"collectionViews"]) {
+        [self reloadCollectionViews];
+    } else if ([keyPath isEqualToString:@"tableViews"]) {
+        [self reloadTableViews];
+    }
+}
+
+- (void)libraryModelAudioMediaItemsReset:(NSNotification *)notification
+{
+    [self updateRepresentedListOfAlbums];
+}
+
+- (void)reloadTableViews
+{
+    NSArray<NSTableView *> * const tableViews = self.tableViews;
+    for (NSTableView * const tableView in tableViews) {
         [tableView reloadData];
     }
+}
 
-    for (NSCollectionView * const collectionView in _collectionViews) {
+- (void)reloadCollectionViews
+{
+    NSArray<NSCollectionView *> * const collectionViews = self.collectionViews;
+    for (NSCollectionView * const collectionView in collectionViews) {
         [collectionView reloadData];
     }
 }
 
+- (void)reloadViews
+{
+    [self reloadTableViews];
+    [self reloadCollectionViews];
+}
+
 - (void)updateRepresentedListOfAlbums
 {
     dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
         VLCLibraryModel * const libraryModel = VLCMain.sharedInstance.libraryController.libraryModel;
-        if (self.representedAudioGroup == nil) {
+        if (self.representedAudioGroup == nil || self.currentParentType == VLCMediaLibraryParentGroupTypeUnknown) {
             self.representedListOfAlbums = libraryModel.listOfAlbums;
+        } else if (self.representedAudioGroup.albums.count == 0) {
+            dispatch_sync(dispatch_get_main_queue(), ^{
+                self.representedListOfAlbums = [libraryModel listAlbumsOfParentType:self.currentParentType forID:self.representedAudioGroup.libraryID];
+            });
         } else {
             self.representedListOfAlbums = self.representedAudioGroup.albums;
         }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/41a8d305444e949c396d5cb61cc06f0d7ba984c5...1d6aab565e9ed4b4748c70af18a0222a381771aa

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/41a8d305444e949c396d5cb61cc06f0d7ba984c5...1d6aab565e9ed4b4748c70af18a0222a381771aa
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list