public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            fecthResultsControllerDelegate = new FecthResultsControllerDelegate()
            {
                TableView = TableView
            };

            var feedURLString        = new NSString("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.geojson");
            var earthquakeURLRequest = NSUrlRequest.FromUrl(new NSUrl(feedURLString));

            NSUrlConnection.SendAsynchronousRequest(earthquakeURLRequest, NSOperationQueue.MainQueue, RequestCompletionHandler);

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            parseQueue = new NSOperationQueue();
            parseQueue.AddObserver(this, new NSString("operationCount"), NSKeyValueObservingOptions.New, IntPtr.Zero);

            //HACK: Parsed strings to NSString
            NSNotificationCenter.DefaultCenter.AddObserver(this, new Selector("EarthquakesError:"), (NSString)APLParseOperation.EarthquakesErrorNotificationName, null);
            NSNotificationCenter.DefaultCenter.AddObserver(this, new Selector("LocaleChanged:"), (NSString)NSLocale.CurrentLocaleDidChangeNotification, null);

            var spinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);

            spinner.StartAnimating();
            activityIndicator = new UIBarButtonItem(spinner);
            NavigationItem.RightBarButtonItem = activityIndicator;
        }
Esempio n. 2
0
        // View life cycle

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationController.NavigationBar.Translucent = false;

            // Setup tool bar with custom buttons
            setupToolBar();

            Subject.Text = message.Title;
            Sender.Text  = "Expéditeur : " + message.From;

            // Category
            Category.Text            = (message.Category != null) ? message.Category : "";
            Category.BackgroundColor = InBoxTools.colorForCategory(message.Category);

            ReceiptDate.Text = "Reçu : " + InBoxTools.labelTextForDate(message.Date);

            Details.Text = message.Text;

            switch (content.Type)
            {
            case AccengageInboxMessageContentType.Text:
                Webview.Hidden = true;
                TextView.Text  = content.Body;
                break;

            case AccengageInboxMessageContentType.Web:
                TextView.Hidden = true;
                Loader.StartAnimating();
                Webview.Alpha = 0;
                Webview.ScrollView.Bounces = false;
                Webview.Delegate           = new WebviewDelegate(Webview, Loader);
                Webview.LoadRequest(new NSUrlRequest(new NSUrl(content.Body)));
                break;
            }

            if (message.IconUrl.Length > 0)
            {
                NSMutableUrlRequest request = new NSMutableUrlRequest(new NSUrl(message.IconUrl));
                NSUrlConnection.SendAsynchronousRequest(request, NSOperationQueue.MainQueue, (response, data, error) =>
                {
                    if (error == null)
                    {
                        IconMsg.Image = UIImage.LoadFromData(data);
                    }
                });
            }
            else
            {
                IconMsg.Hidden = true;
            }

            NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidChangeStatusBarOrientationNotification, deviceOrientationDidChangeNotification);

            updateForDeviceOrientation();
        }
Esempio n. 3
0
 public static void SendAsyncRequest(
     this NSUrlRequest This,
     NSUrlConnectionDataResponse completionHandler)
 {
     NSUrlConnection.SendAsynchronousRequest(
         This,
         NSOperationQueue.MainQueue,
         (response, data, error) =>
     {
         completionHandler?.Invoke(response, data, error);
     });
 }
Esempio n. 4
0
        public void setMessage(AccengageInboxMessage msg)
        {
            Subject.Text = msg.Title;
            Content.Text = msg.Text;
            Date.Text    = InBoxTools.labelTextForDate(msg.Date);

            string categorie = msg.Category;

            Category.Text            = (categorie != null) ? categorie : "";
            Category.BackgroundColor = InBoxTools.colorForCategory(Category.Text);

            if (msg.Read)
            {
                Subject.TextColor             = UIColor.FromWhiteAlpha(0.4f, 1.0f);
                Content.TextColor             = UIColor.FromWhiteAlpha(0.4f, 1.0f);
                StatusMessage.BackgroundColor = UIColor.White;
            }
            else
            {
                Subject.TextColor             = UIColor.Black;
                Content.TextColor             = UIColor.Black;
                StatusMessage.BackgroundColor = UIColor.FromRGB(0, 121, 255);
            }

            if (msg.Archived)
            {
                StatusMessage.BackgroundColor = UIColor.Red;
            }

            string iconUrl = msg.IconUrl;

            if (iconUrl.Length > 0)
            {
                IconMsg.Hidden = false;
                var request = NSUrlRequest.FromUrl(new NSUrl(iconUrl));
                NSUrlConnection.SendAsynchronousRequest(request, NSOperationQueue.MainQueue,
                                                        (response, data, error) =>
                {
                    if (error == null)
                    {
                        IconMsg.Image = UIImage.LoadFromData(data);
                    }
                });
            }
            else
            {
                IconMsg.Hidden = true;
            }
        }
Esempio n. 5
0
 public override UIImage GetUIImage()
 {
     if (this.image == null)
     {
         this.ImageLoadStatus = ImageStatus.Loading;
         if (!this.UriSource.IsAbsoluteUri)
         {
             this.image = UIImage.FromBundle(string.Format("iOS/{0}", this.UriSource.OriginalString));
             if (this.image == null)
             {
                 this.image = UIImage.FromBundle("Assets/" + this.UriSource.OriginalString);
             }
         }
         else if (this.UriSource.IsFile)
         {
             this.image = UIImage.FromBundle(this.UriSource.OriginalString);
         }
         else if (this.UriSource.Scheme == Uri.UriSchemeHttp || this.UriSource.Scheme == Uri.UriSchemeHttps)
         {
             NSUrlRequest     req   = new NSMutableUrlRequest(this.UriSource);
             NSOperationQueue queue = new NSOperationQueue();
             NSUrlConnection.SendAsynchronousRequest(req, queue, (pesponse, data, error) =>
             {
                 try
                 {
                     if (error == null && data != null && data.Length != 0)
                     {
                         Dispatcher.BeginInvoke(() =>
                         {
                             this.image = UIImage.LoadFromData(data);
                             if (this.ImageOpened != null)
                             {
                                 this.ImageOpened(this, new RoutedEventArgs());
                             }
                         });
                     }
                     else
                     {
                         Dispatcher.BeginInvoke(() =>
                         {
                             if (this.ImageFailed != null)
                             {
                                 this.ImageFailed(this, new ExceptionRoutedEventArgs());
                             }
                         });
                     }
                 }
                 catch (Exception e)
                 {
                     Dispatcher.BeginInvoke(() =>
                     {
                         this.image = UIImage.LoadFromData(data);
                         if (this.ImageFailed != null)
                         {
                             this.ImageFailed(this, new ExceptionRoutedEventArgs(e));
                         }
                     });
                 }
             });
             return(this.image);
         }
         if (this.image == null)
         {
             this.image = UIImage.FromFile(this.UriSource.OriginalString);
         }
     }
     return(this.image);
 }