コード例 #1
0
        private async Task Load()
        {
            Web.UserInteractionEnabled = false;
            Web.LoadHtmlString("", NSBundle.MainBundle.BundleUrl);

            _activityView.Alpha = 1;
            _activityView.StartAnimating();
            View.Add(_activityView);

            try
            {
                var productData = (await _inAppPurchaseService.RequestProductData(FeaturesService.ProEdition)).Products.FirstOrDefault();
                var enabled = _featuresService.IsProEnabled;
                var model = new UpgradeDetailsModel(productData != null ? productData.LocalizedPrice() : null, enabled);
                var content = new UpgradeDetailsRazorView {
                    Model = model
                }.GenerateString();
                LoadContent(content);
                Web.UserInteractionEnabled = true;
            }
            finally
            {
                UIView.Animate(0.2f, 0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseInOut,
                               () => _activityView.Alpha = 0, () =>
                {
                    _activityView.RemoveFromSuperview();
                    _activityView.StopAnimating();
                });
            }
        }
コード例 #2
0
        private async Task Load()
        {
            Web.UserInteractionEnabled = false;
            Web.LoadHtmlString("", NSBundle.MainBundle.BundleUrl);

            _activityView.Alpha = 1;
            _activityView.StartAnimating();
            View.Add(_activityView);

            try
            {
                var response = await _inAppPurchaseService
                               .RequestProductData(FeaturesService.ProEdition)
                               .WithTimeout(TimeSpan.FromSeconds(30));

                var productData = response.Products.FirstOrDefault();
                var enabled     = _featuresService.IsProEnabled;
                var model       = new UpgradeDetailsModel(productData?.LocalizedPrice(), enabled);
                var viewModel   = new UpgradeDetailsRazorView {
                    Model = model
                };
                LoadContent(viewModel.GenerateString());
            }
            catch (Exception e)
            {
                AlertDialogService.ShowAlert("Error Loading Upgrades", e.Message);
            }
            finally
            {
                Web.UserInteractionEnabled = true;

                UIView.Animate(0.2f, 0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseInOut,
                               () => _activityView.Alpha = 0, () =>
                {
                    _activityView.RemoveFromSuperview();
                    _activityView.StopAnimating();
                });
            }
        }