Commit 41c8154d authored by Felix Paul Kühne's avatar Felix Paul Kühne

server browsing: fix runtime exception

parent 03211b34
...@@ -36,34 +36,39 @@ ...@@ -36,34 +36,39 @@
_browsingController = [[VLCServerBrowsingController alloc] initWithViewController:self serverBrowser:serverBrowser]; _browsingController = [[VLCServerBrowsingController alloc] initWithViewController:self serverBrowser:serverBrowser];
self.title = serverBrowser.title; self.title = serverBrowser.title;
self.nothingFoundLabel.text = NSLocalizedString(@"FOLDER_EMPTY", nil);
[self.nothingFoundLabel sizeToFit];
UIView *nothingFoundView = self.nothingFoundView;
[nothingFoundView sizeToFit];
[nothingFoundView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:nothingFoundView];
NSLayoutConstraint *yConstraint = [NSLayoutConstraint constraintWithItem:nothingFoundView
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeCenterY
multiplier:1.0
constant:0.0];
[self.view addConstraint:yConstraint];
NSLayoutConstraint *xConstraint = [NSLayoutConstraint constraintWithItem:nothingFoundView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0.0];
[self.view addConstraint:xConstraint];
} }
return self; return self;
} }
- (void)viewDidLoad
{
[super viewDidLoad];
self.nothingFoundLabel.text = NSLocalizedString(@"FOLDER_EMPTY", nil);
[self.nothingFoundLabel sizeToFit];
UIView *nothingFoundView = self.nothingFoundView;
[nothingFoundView sizeToFit];
[nothingFoundView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:nothingFoundView];
NSLayoutConstraint *yConstraint = [NSLayoutConstraint constraintWithItem:nothingFoundView
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeCenterY
multiplier:1.0
constant:0.0];
[self.view addConstraint:yConstraint];
NSLayoutConstraint *xConstraint = [NSLayoutConstraint constraintWithItem:nothingFoundView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0.0];
[self.view addConstraint:xConstraint];
}
- (void)viewDidAppear:(BOOL)animated - (void)viewDidAppear:(BOOL)animated
{ {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
...@@ -116,12 +121,14 @@ ...@@ -116,12 +121,14 @@
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{ {
return [self.serverBrowser items].count; NSInteger count = [self.serverBrowser items].count;
self.nothingFoundView.hidden = count > 0;
return count;
} }
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{ {
id<VLCNetworkServerBrowserItem> item = self.serverBrowser.items[indexPath.row]; id<VLCNetworkServerBrowserItem> item = self.serverBrowser.items[indexPath.row];
if ([cell conformsToProtocol:@protocol(VLCRemoteBrowsingCell)]) { if ([cell conformsToProtocol:@protocol(VLCRemoteBrowsingCell)]) {
[self.browsingController configureCell:(id<VLCRemoteBrowsingCell>)cell withItem:item]; [self.browsingController configureCell:(id<VLCRemoteBrowsingCell>)cell withItem:item];
......
...@@ -113,7 +113,9 @@ ...@@ -113,7 +113,9 @@
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{ {
return self.indexPaths.count; NSInteger count = self.indexPaths.count;
self.nothingFoundView.hidden = count > 0;
return count;
} }
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment