public override async void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            try
            {
                // Clear credentials (if any) from previous sample runs
                foreach (Credential cred in AuthenticationManager.Current.Credentials)
                {
                    AuthenticationManager.Current.RemoveCredential(cred);
                }

                var sample = _visibleSamples[indexPath.Row];

                if (sample.OfflineDataItems != null)
                {
                    // Show progress overlay
                    var bounds = UIScreen.MainScreen.Bounds;

                    _loadPopup = new LoadingOverlay(bounds);
                    _parentViewController.ParentViewController.View.Add(_loadPopup);

                    // Ensure data present
                    await DataManager.EnsureSampleDataPresent(sample);

                    // Hide progress overlay
                    _loadPopup.Hide();
                }

                var control = (UIViewController)SampleManager.Current.SampleToControl(sample);
                _parentViewController.NavigationController.PushViewController(control, true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
            public override async void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                try
                {
                    // Call a function to clear existing credentials
                    ClearCredentials();

                    var sample = _data[indexPath.Row];

                    if (sample.OfflineDataItems != null)
                    {
                        // Show progress overlay
                        var bounds = UIScreen.MainScreen.Bounds;

                        _loadPopup = new LoadingOverlay(bounds);
                        _controller.ParentViewController.View.Add(_loadPopup);

                        // Ensure data present
                        await DataManager.EnsureSampleDataPresent(sample);

                        // Hide progress overlay
                        _loadPopup.Hide();
                    }

                    var control = (UIViewController)SampleManager.Current.SampleToControl(sample);
                    _controller.NavigationController.PushViewController(control, true);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemple #3
0
        public override async void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            try
            {
                // Call a function to clear existing credentials
                ClearCredentials();

                var sample = _visibleSamples[indexPath.Row];

                if (sample.OfflineDataItems != null)
                {
                    // Create a cancellation token source.
                    var cancellationTokenSource = new CancellationTokenSource();

                    // Show progress overlay
                    var bounds = UIScreen.MainScreen.Bounds;

                    _loadPopup = new LoadingOverlay(bounds, cancellationTokenSource);
                    _parentViewController.ParentViewController.View.Add(_loadPopup);

                    // Ensure data present
                    await DataManager.EnsureSampleDataPresent(sample, cancellationTokenSource.Token);

                    // Hide progress overlay
                    _loadPopup.Hide();
                }

                var control = (UIViewController)SampleManager.Current.SampleToControl(sample);
                control.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("InfoIcon"), UIBarButtonItemStyle.Plain, (s, e) => ViewSampleReadme(sample, control));
                _parentViewController.NavigationController.PushViewController(control, true);
            }
            catch (OperationCanceledException)
            {
                _loadPopup.Hide();
                TableView.DeselectRow(indexPath, true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }