コード例 #1
0
        private void LoadImages()
        {
            if (_state != State.Waiting)
            {
                return;
            }

            _state = State.Loading;
            var hud = new RedPlum.MBProgressHUD(View.Frame)
            {
                Mode      = RedPlum.MBProgressHUDMode.Indeterminate,
                TitleText = "Loading...",
                TitleFont = UIFont.BoldSystemFontOfSize(14f)
            };

            this.View.AddSubview(hud);
            hud.Show(false);

            //Do the loading
            ThreadPool.QueueUserWorkItem(delegate {
                try
                {
                    _icons        = RequestFactory.GetIcons();
                    _loadedImages = new List <Photo>();
                    _icons.ForEach(x => {
                        var photo = new Photo(new NSUrl(x.FullUrl))
                        {
                            Caption = x.App, Icon = true, CornerRadius = 512f * (10f / 57f)
                        };
                        _loadedImages.Add(photo);
                    });

                    BeginInvokeOnMainThread(() => {
                        _state = State.Loaded;
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                        CollectionView.ReloadData();
                    });
                }
                catch (Exception e)
                {
                    BeginInvokeOnMainThread(() => {
                        _state = State.Waiting;
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                        var alert = new UIAlertView {
                            Message = e.Message, Title = "Error"
                        };
                        alert.CancelButtonIndex = alert.AddButton("Ok");
                        alert.Show();
                    });
                }
            });
        }
コード例 #2
0
        private void Refresh()
        {
            var hud = new RedPlum.MBProgressHUD(View.Frame)
            {
                Mode = RedPlum.MBProgressHUDMode.Indeterminate
            };

            hud.TitleText = "Requesting Categories...";
            hud.TitleFont = UIFont.BoldSystemFontOfSize(14f);
            this.ParentViewController.View.AddSubview(hud);
            hud.Show(false);

            //Do the loading
            ThreadPool.QueueUserWorkItem(delegate {
                try
                {
                    var data    = Data.RequestFactory.GetCategories();
                    var section = new Section();

                    BeginInvokeOnMainThread(() => {
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                    });

                    data.ForEach(d => section.Add(new StyledElement(d.Name, () => NavigationController.PushViewController(new WebPatternsViewController(d)
                    {
                        Title = d.Name
                    }, true))));


                    BeginInvokeOnMainThread(() => {
                        var root = new RootElement(Title)
                        {
                            section
                        };
                        Root = root;
                    });
                }
                catch (Exception e)
                {
                    hud.Hide(true);
                    hud.RemoveFromSuperview();
                    var alert = new UIAlertView {
                        Message = e.Message, Title = "Error"
                    };
                    alert.CancelButtonIndex = alert.AddButton("Ok");
                    alert.Show();
                }

                BeginInvokeOnMainThread(ReloadComplete);
            });
        }
コード例 #3
0
        private void Refresh()
        {
            var hud = new RedPlum.MBProgressHUD(View.Frame)
            { Mode = RedPlum.MBProgressHUDMode.Indeterminate };
            hud.TitleText = "Requesting Categories...";
            hud.TitleFont = UIFont.BoldSystemFontOfSize(14f);
            this.ParentViewController.View.AddSubview(hud);
            hud.Show(false);

            //Do the loading
            ThreadPool.QueueUserWorkItem(delegate {
                try
                {
                    var data = Data.RequestFactory.GetCategories();
                    var section = new Section();

                    BeginInvokeOnMainThread(() => {
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                    });

                    data.ForEach(d => section.Add(new StyledElement(d.Name, () => NavigationController.PushViewController(new WebPatternsViewController(d) { Title = d.Name } , true))));

                    BeginInvokeOnMainThread(() => {
                        var root = new RootElement(Title) {section};
                        Root = root;
                    });
                }
                catch (Exception e)
                {
                    hud.Hide(true);
                    hud.RemoveFromSuperview();
                    var alert = new UIAlertView {Message = e.Message, Title = "Error"};
                    alert.CancelButtonIndex = alert.AddButton("Ok");
                    alert.Show();
                }

                BeginInvokeOnMainThread(ReloadComplete);
            });
        }
コード例 #4
0
        private void LoadImages()
        {
            if (_state != State.Waiting)
                return;

            _state = State.Loading;
            var hud = new RedPlum.MBProgressHUD(View.Frame)
            {
                Mode = RedPlum.MBProgressHUDMode.Indeterminate,
                TitleText = "Loading...",
                TitleFont = UIFont.BoldSystemFontOfSize(14f)
            };

            this.View.AddSubview(hud);
            hud.Show(false);

            //Do the loading
            ThreadPool.QueueUserWorkItem(delegate {
                try
                {
                    _screenshots = _source != null ? RequestFactory.GetScreenshots(_source.Id) : RequestFactory.GetRecentScreenshots();
                    _loadedImages = new List<Photo>();
                    _screenshots.ForEach(x => {
                        _loadedImages.Add(new Photo(new NSUrl(x.FullUrl)) { Caption = x.App });

                    });

                    BeginInvokeOnMainThread(() => {
                        _state = State.Loaded;
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                        CollectionView.ReloadData();
                    });
                }
                catch (Exception e)
                {
                    BeginInvokeOnMainThread(() =>  {
                        _state = State.Waiting;
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                        var alert = new UIAlertView {Message = e.Message, Title = "Error"};
                        alert.CancelButtonIndex = alert.AddButton("Ok");
                        alert.Show();
                    });
                }
            });
        }