Преглед изворни кода

ATV: add label to show that we didn't find a server

Felix Paul Kühne пре 9 година
родитељ
комит
00817bbf7c

BIN
Resources/en.lproj/Localizable.strings


+ 1 - 0
SharedSources/ServerBrowsing/VLCLocalServerDiscoveryController.h

@@ -27,6 +27,7 @@
 - (NSUInteger)numberOfSections;
 - (NSString *)titleForSection:(NSUInteger)section;
 - (NSUInteger)numberOfItemsInSection:(NSUInteger)section;
+- (BOOL)foundAnythingAtAll;
 
 - (id<VLCLocalNetworkService>)networkServiceForIndexPath:(NSIndexPath *)indexPath;
 

+ 12 - 0
SharedSources/ServerBrowsing/VLCLocalServerDiscoveryController.m

@@ -137,6 +137,18 @@
     return [browser networkServiceForIndex:row];
 }
 
+- (BOOL)foundAnythingAtAll
+{
+    NSUInteger serviceCount = _serviceBrowsers.count;
+    BOOL ret = NO;
+    for (NSUInteger i = 0; i < serviceCount; i++) {
+        ret = [_serviceBrowsers[i] numberOfItems] > 0;
+        if (ret)
+            break;
+    }
+    return ret;
+}
+
 #pragma mark - VLCLocalNetworkServiceBrowserDelegate
 - (void)localNetworkServiceBrowserDidUpdateServices:(id<VLCLocalNetworkServiceBrowser>)serviceBrowser {
     if ([self.delegate respondsToSelector:@selector(discoveryFoundSomethingNew)]) {

+ 33 - 2
VLC for Apple TV/VLCServerListTVTableViewController.m

@@ -22,7 +22,9 @@
 #import <SSKeychain/SSKeychain.h>
 
 @interface VLCServerListTVTableViewController ()
-
+{
+    UILabel *_nothingFoundLabel;
+}
 @end
 
 @implementation VLCServerListTVTableViewController
@@ -35,6 +37,32 @@
     UINib *nib = [UINib nibWithNibName:@"VLCLocalNetworkServerTVCell" bundle:nil];
     [self.tableView registerNib:nib forCellReuseIdentifier:VLCLocalServerTVCell];
     self.tableView.rowHeight = 150;
+
+    _nothingFoundLabel = [[UILabel alloc] init];
+    _nothingFoundLabel.text = NSLocalizedString(@"NO_SERVER_FOUND", nil);
+    _nothingFoundLabel.textAlignment = NSTextAlignmentCenter;
+    _nothingFoundLabel.textColor = [UIColor VLCLightTextColor];
+    _nothingFoundLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleTitle3];
+    [_nothingFoundLabel sizeToFit];
+    [_nothingFoundLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
+    [self.view addSubview:_nothingFoundLabel];
+
+    NSLayoutConstraint *yConstraint = [NSLayoutConstraint constraintWithItem:_nothingFoundLabel
+                                                                   attribute:NSLayoutAttributeCenterY
+                                                                   relatedBy:NSLayoutRelationEqual
+                                                                      toItem:self.view
+                                                                   attribute:NSLayoutAttributeCenterY
+                                                                  multiplier:1.0
+                                                                    constant:0.0];
+    [self.view addConstraint:yConstraint];
+    NSLayoutConstraint *xConstraint = [NSLayoutConstraint constraintWithItem:_nothingFoundLabel
+                                                                   attribute:NSLayoutAttributeCenterX
+                                                                   relatedBy:NSLayoutRelationEqual
+                                                                      toItem:self.view
+                                                                   attribute:NSLayoutAttributeCenterX
+                                                                  multiplier:1.0
+                                                                    constant:0.0];
+    [self.view addConstraint:xConstraint];
 }
 
 - (void)viewDidAppear:(BOOL)animated
@@ -211,9 +239,12 @@
 }
 
 #pragma mark - VLCLocalServerDiscoveryController
-- (void)discoveryFoundSomethingNew {
+- (void)discoveryFoundSomethingNew
+{
     [self.tableView reloadData];
     NSLog(@"%s",__PRETTY_FUNCTION__);
+
+    _nothingFoundLabel.hidden = self.discoveryController.foundAnythingAtAll;
 }
 
 @end