Browse Source

fix stale mini-players in hierachy

Tobias Conradi 10 years ago
parent
commit
1b9e26bd25
1 changed files with 18 additions and 14 deletions
  1. 18 14
      Sources/VLCPlaylistViewController.m

+ 18 - 14
Sources/VLCPlaylistViewController.m

@@ -440,26 +440,30 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
 {
 {
     VLCPlaybackController *playbackController = [VLCPlaybackController sharedInstance];
     VLCPlaybackController *playbackController = [VLCPlaybackController sharedInstance];
 
 
-    if (playbackController.activePlaybackSession) {
-        CGRect viewRect = self.view.frame;
-        _miniPlaybackView = [[VLCMiniPlaybackView alloc] initWithFrame:CGRectMake(0., viewRect.size.height - 60., viewRect.size.width, 60.)];
-        _miniPlaybackView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
+    const BOOL showMiniPlayer = playbackController.activePlaybackSession;
+    if (showMiniPlayer) {
+        const CGFloat miniPlayerHeight = 60.;
+        const CGRect viewRect = self.view.frame;
+        const CGRect miniPlayerFrame = CGRectMake(0., viewRect.size.height - miniPlayerHeight, viewRect.size.width, miniPlayerHeight);
+        if (!_miniPlaybackView) {
+            _miniPlaybackView = [[VLCMiniPlaybackView alloc] initWithFrame:miniPlayerFrame];
+            _miniPlaybackView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
+        }
         [_miniPlaybackView setupForWork];
         [_miniPlaybackView setupForWork];
+        _miniPlaybackView.frame = miniPlayerFrame;
         [self.view addSubview:_miniPlaybackView];
         [self.view addSubview:_miniPlaybackView];
-        CGRect listViewRect = viewRect;
-        listViewRect.size.height = listViewRect.size.height - _miniPlaybackView.frame.size.height;
-        if (_usingTableViewToShowData)
-            _tableView.frame = listViewRect;
-        else
-            _collectionView.frame = listViewRect;
     } else {
     } else {
         [_miniPlaybackView removeFromSuperview];
         [_miniPlaybackView removeFromSuperview];
         _miniPlaybackView = nil;
         _miniPlaybackView = nil;
-        if (_usingTableViewToShowData)
-            _tableView.frame = self.view.frame;
-        else
-            _collectionView.frame = self.view.frame;
     }
     }
+
+    const CGFloat bottomInset = showMiniPlayer ? CGRectGetHeight(_miniPlaybackView.frame) : 0.;
+    UIScrollView *playListDataView = _usingTableViewToShowData ? _tableView : _collectionView;
+    UIEdgeInsets inset = playListDataView.contentInset;
+    inset.bottom = bottomInset;
+    playListDataView.contentInset = inset;
+    playListDataView.scrollIndicatorInsets = inset;
+
 }
 }
 
 
 - (void)libraryUpgradeComplete
 - (void)libraryUpgradeComplete