Browse Source

Add CloudStorage CollectionVC based on the RemoteBrowsing VC

Felix Paul Kühne 9 years ago
parent
commit
00dcb286d3

+ 26 - 0
Apple-TV/VLCCloudStorageTVViewController.h

@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan.org>
+ *
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+
+#import "VLCRemoteBrowsingCollectionViewController.h"
+#import "VLCCloudStorageController.h"
+#import "VLCCloudStorageCollectionViewCell.h"
+
+@interface VLCCloudStorageTVViewController : VLCRemoteBrowsingCollectionViewController
+
+@property (nonatomic, strong) VLCCloudStorageController *controller;
+@property (nonatomic, strong) NSString *currentPath;
+@property (nonatomic) BOOL authorizationInProgress;
+@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
+
+- (void)updateViewAfterSessionChange;
+- (void)requestInformationForCurrentPath;
+
+@end

+ 73 - 0
Apple-TV/VLCCloudStorageTVViewController.m

@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan.org>
+ *
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+
+#import "VLCCloudStorageTVViewController.h"
+#import "VLCCloudStorageCollectionViewCell.h"
+
+@interface VLCCloudStorageTVViewController ()
+
+@end
+
+@implementation VLCCloudStorageTVViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+
+    _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
+    _activityIndicator.hidesWhenStopped = YES;
+    _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
+
+    [self.view addSubview:_activityIndicator];
+
+    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
+    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
+}
+
+- (void)mediaListUpdated
+{
+    [_activityIndicator stopAnimating];
+
+    [self.collectionView reloadData];
+}
+
+- (void)updateViewAfterSessionChange
+{
+    if (![self.controller isAuthorized]) {
+        [_activityIndicator stopAnimating];
+        return;
+    }
+
+    //reload if we didn't come back from streaming
+    if (self.currentPath == nil)
+        self.currentPath = @"";
+
+    if([self.controller.currentListFiles count] == 0)
+        [self requestInformationForCurrentPath];
+}
+
+- (void)requestInformationForCurrentPath
+{
+    [_activityIndicator startAnimating];
+    [self.controller requestDirectoryListingAtPath:self.currentPath];
+    [_activityIndicator stopAnimating];
+}
+
+- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
+{
+    return 1;
+}
+
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
+{
+    return self.controller.currentListFiles.count;
+}
+
+@end