Exemplo n.º 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;
            }
        }
        private async void Load()
        {
            _dataCollection = new YouTubeDataCollection();
            var grouping = new C1GroupDataCollection <YouTubeVideo>(_dataCollection, true);
            await grouping.GroupAsync("PublishedDay");

            RecyclerView.SetLayoutManager(new LinearLayoutManager(this));
            RecyclerView.SetAdapter(new YouTubeAdapter(grouping));
        }
Exemplo n.º 4
0
        public OnDemand()
        {
            InitializeComponent();
            Title = AppResources.OnDemandTitle;
            search.Placeholder = AppResources.SearchPlaceholderText;
            _dataCollection    = new YouTubeDataCollection();
            list.ItemsSource   = _dataCollection;

            // start on demand loading
            list.LoadItemsOnDemand(_dataCollection);
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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;
     }
 }
Exemplo n.º 7
0
        private async void Load()
        {
            CollectionView.BackgroundColor = UIColor.White;
            SearchField.EditingChanged    += OnSearchEditingChanged;
            SearchField.ShouldReturn       = new UITextFieldCondition(tf => { tf.ResignFirstResponder(); return(true); });
            _collectionView          = new YouTubeDataCollection();
            _collectionView.PageSize = 50;
            var itemSize = 100;
            var grouping = new C1GroupDataCollection <YouTubeVideo>(_collectionView, false);
            await grouping.GroupAsync("PublishedDay");

            var source = new YouTubeCollectionViewSource(CollectionView);

            source.ItemsSource = grouping;
            source.EmptyMessageLabel.TextColor = UIColor.Black;
            source.EmptyMessageLabel.Text      = Foundation.NSBundle.MainBundle.GetLocalizedString("EmptyText", "");
            var layout = new C1CollectionViewFlowLayout();

            layout.SectionHeadersPinToVisibleBounds = true;
            layout.EstimatedItemSize    = new CGSize(itemSize, itemSize);
            layout.HeaderReferenceSize  = new CGSize(25, 25);
            source.CollectionViewLayout = layout;
            CollectionView.Source       = source;
        }