VLCCloudStorageTVViewController.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*****************************************************************************
  2. * VLC for iOS
  3. *****************************************************************************
  4. * Copyright (c) 2015 VideoLAN. All rights reserved.
  5. * $Id$
  6. *
  7. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. #import "VLCCloudStorageTVViewController.h"
  12. #import "VLCCloudStorageCollectionViewCell.h"
  13. @interface VLCCloudStorageTVViewController ()
  14. @end
  15. @implementation VLCCloudStorageTVViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
  19. _activityIndicator.hidesWhenStopped = YES;
  20. _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
  21. [self.view addSubview:_activityIndicator];
  22. [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
  23. [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
  24. }
  25. - (void)mediaListUpdated
  26. {
  27. [_activityIndicator stopAnimating];
  28. [self.collectionView reloadData];
  29. }
  30. - (void)updateViewAfterSessionChange
  31. {
  32. if (![self.controller isAuthorized]) {
  33. [_activityIndicator stopAnimating];
  34. return;
  35. }
  36. //reload if we didn't come back from streaming
  37. if (self.currentPath == nil)
  38. self.currentPath = @"";
  39. if([self.controller.currentListFiles count] == 0)
  40. [self requestInformationForCurrentPath];
  41. }
  42. - (void)requestInformationForCurrentPath
  43. {
  44. [_activityIndicator startAnimating];
  45. [self.controller requestDirectoryListingAtPath:self.currentPath];
  46. [_activityIndicator stopAnimating];
  47. }
  48. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
  49. {
  50. return 1;
  51. }
  52. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  53. {
  54. return self.controller.currentListFiles.count;
  55. }
  56. @end