ソースを参照

plex: add activity indicator on VLCPlexConnectServerViewController

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Pierre SAGASPE 10 年 前
コミット
a3f6ffa1fd
1 ファイル変更15 行追加0 行削除
  1. 15 0
      Sources/VLCPlexConnectServerViewController.m

+ 15 - 0
Sources/VLCPlexConnectServerViewController.m

@@ -20,6 +20,8 @@
 {
     NSMutableArray *_bookmarkServer;
     NSMutableArray *_bookmarkPort;
+
+    UIActivityIndicatorView *_activityIndicator;
 }
 @end
 
@@ -61,6 +63,12 @@
 
         self.edgesForExtendedLayout = UIRectEdgeNone;
     }
+
+    _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
+    _activityIndicator.center = self.view.center;
+    _activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
+    _activityIndicator.hidesWhenStopped = YES;
+    [self.view addSubview:_activityIndicator];
 }
 
 - (void)viewWillAppear:(BOOL)animated
@@ -93,6 +101,12 @@
 
 - (IBAction)connectToServer:(id)sender
 {
+    [_activityIndicator startAnimating];
+    [self performSelector:@selector(connectToPlexMediaServer) withObject:nil afterDelay:0.1];
+}
+
+- (void)connectToPlexMediaServer
+{
     NSString *server = [NSString stringWithFormat:@"%@", self.serverAddressField.text];
     NSString *port = [NSString stringWithFormat:@"%@", self.portField.text];
 
@@ -116,6 +130,7 @@
         if (![self isValidPort:port])
             self.portField.text = kPlexMediaServerPortDefault;
     }
+    [_activityIndicator stopAnimating];
 }
 
 - (IBAction)savePlexServer:(id)sender