예제 #1
0
        private async Task UpdateVideos()
        {
            var indicator = new UIActivityIndicatorView(new CGRect(0, 0, 40, 40));

            indicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray;
            indicator.Center = View.Center;
            View.AddSubview(indicator);
            try
            {
                indicator.StartAnimating();
                var videos = (await YouTubeDataCollection.LoadVideosAsync("Xamarin iOS", "relevance", null, 50)).Item2;
                _source = new YouTubeTableViewSource(TableView)
                {
                    ItemsSource = videos
                };
                TableView.Source = _source;
            }
            catch
            {
                var alert = new UIAlertView("", Foundation.NSBundle.MainBundle.LocalizedString("InternetConnectionError", ""), null, "OK");
                alert.Show();
            }
            finally
            {
                indicator.StopAnimating();
            }
        }
        private async Task UpdateVideos()
        {
            var indicator = new ProgressBar(this);

            try
            {
                indicator.Activated = true;
                var videos = new ObservableCollection <YouTubeVideo>((await YouTubeDataCollection.LoadVideosAsync("Xamarin Android", "relevance", null, 50)).Item2);
                _dataCollection = new C1DataCollection <YouTubeVideo>(videos).AsPlain();
                await _dataCollection.GroupAsync("ChannelTitle");

                RecyclerView.SetLayoutManager(new LinearLayoutManager(this));
                RecyclerView.SetAdapter(new YouTubeAdapter(_dataCollection));
            }
            catch
            {
                var builder = new Android.App.AlertDialog.Builder(this);
                builder.SetMessage(Resources.GetString(Resource.String.InternetConnectionError));
                var alert = builder.Create();
                alert.Show();
            }
            finally
            {
                indicator.Activated = false;
            }
        }
예제 #3
0
        public async void LoadVideos()
        {
            var videos = await YouTubeDataCollection.LoadVideosAsync("WPF", "relevance", null, 50);

            var cv = new C1.WPF.DataCollection.C1CollectionView(new C1DataCollection <YouTubeVideo>(videos.Item2));

            //using (cv.DeferRefresh())
            //{
            //    cv.GroupDescriptions.Add(new System.Windows.Data.PropertyGroupDescription("ChannelTitle"));
            //    cv.GroupDescriptions.Add(new System.Windows.Data.PropertyGroupDescription("TitleIndex"));
            //}
            grid.ItemsSource = cv;
        }
예제 #4
0
 private async Task UpdateVideos()
 {
     try
     {
         message.IsVisible           = false;
         list.IsVisible              = false;
         activityIndicator.IsRunning = true;
         var _videos = new ObservableCollection <YouTubeVideo>((await YouTubeDataCollection.LoadVideosAsync("Xamarin Forms", "relevance", null, 50)).Item2);
         _dataCollection  = new C1DataCollection <YouTubeVideo>(_videos);
         list.ItemsSource = _dataCollection;
         list.IsVisible   = true;
     }
     catch
     {
         message.Text      = AppResources.InternetConnectionError;
         message.IsVisible = true;
     }
     finally
     {
         activityIndicator.IsRunning = false;
     }
 }