public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Pro Upgrade"; _activityView = new UIActivityIndicatorView { Color = Theme.PrimaryNavigationBarColor, AutoresizingMask = UIViewAutoresizing.FlexibleWidth, }; _activityView.Frame = new CoreGraphics.CGRect(0, 44, View.Frame.Width, 88f); _web = new UIWebView { ScalesPageToFit = true, AutoresizingMask = UIViewAutoresizing.All }; _web.LoadFinished += (sender, e) => _networkActivityService.PopNetworkActive(); _web.LoadStarted += (sender, e) => _networkActivityService.PushNetworkActive(); _web.LoadError += (sender, e) => _networkActivityService.PopNetworkActive(); _web.ShouldStartLoad = (w, r, n) => ShouldStartLoad(r, n); _web.Frame = new CoreGraphics.CGRect(0, 0, View.Frame.Width, View.Frame.Height); Add(_web); Load().ToBackground(); }
protected virtual void OnLoadError(object sender, UIWebErrorArgs e) { NetworkActivityService.PopNetworkActive(); if (RefreshButton != null) { RefreshButton.Enabled = true; } }
public LoginViewModel(INetworkActivityService networkActivity) { LoginCommand = ReactiveCommand.CreateAsyncTask(async t => { var account = new Account(); var connection = new Octokit.Connection(new Octokit.ProductHeaderValue("RepoStumble")); var client = new Octokit.OauthClient(connection); var token = await client.CreateAccessToken(new Octokit.OauthTokenRequest(ClientId, ClientSecret, LoginCode)); connection.Credentials = new Octokit.Credentials(token.AccessToken); var githubClient = new Octokit.GitHubClient(connection); var info = await githubClient.User.Current(); account.AvatarUrl = info.AvatarUrl; account.Username = info.Login; account.Fullname = info.Name; account.OAuth = token.AccessToken; account.Save(); DismissCommand.ExecuteIfCan(); }); LoginCommand.IsExecuting.Skip(1).Where(x => x).Subscribe(x => networkActivity.PushNetworkActive()); LoginCommand.IsExecuting.Skip(1).Where(x => !x).Subscribe(x => networkActivity.PopNetworkActive()); }
public static IDisposable TriggerNetworkActivity(this IReactiveCommand @this, INetworkActivityService networkActivity) { return @this.IsExecuting.Skip(1).Subscribe(x => { if (x) networkActivity.PushNetworkActive(); else networkActivity.PopNetworkActive(); }); }
public UpgradeView(INetworkActivityService networkActivityService) { _featuresService = Locator.Current.GetService<IFeaturesService>(); _inAppPurchaseService = Locator.Current.GetService<IInAppPurchaseService>(); _web = new UIWebView { ScalesPageToFit = true, AutoresizingMask = UIViewAutoresizing.All }; _web.LoadFinished += (sender, e) => networkActivityService.PopNetworkActive(); _web.LoadStarted += (sender, e) => networkActivityService.PushNetworkActive(); _web.LoadError += (sender, e) => networkActivityService.PopNetworkActive(); _web.ShouldStartLoad = (w, r, n) => ShouldStartLoad(r, n); _activityView = new UIActivityIndicatorView { Color = Theme.PrimaryNavigationBarColor, AutoresizingMask = UIViewAutoresizing.FlexibleWidth, }; }
public RepositoriesExploreViewModel(IApplicationService applicationService, INetworkActivityService networkActivityService) { ShowRepositoryDescription = applicationService.Account.ShowRepositoryDescriptionInList; Title = "Explore"; var gotoRepository = new Action <RepositoryItemViewModel>(x => { var vm = CreateViewModel <RepositoryViewModel>(); vm.RepositoryOwner = x.Owner; vm.RepositoryName = x.Name; ShowViewModel(vm); }); var repositories = new ReactiveList <Octokit.Repository>(); Repositories = repositories.CreateDerivedCollection(x => new RepositoryItemViewModel(x.Name, x.Owner.Login, x.Owner.AvatarUrl, x.Description, x.StargazersCount, x.ForksCount, true, gotoRepository)); SearchCommand = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.SearchText).Select(x => !string.IsNullOrEmpty(x)), async t => { repositories.Clear(); try { var request = new Octokit.SearchRepositoriesRequest(SearchText); var response = await applicationService.GitHubClient.Search.SearchRepo(request); repositories.Reset(response.Items); } catch (Exception e) { throw new Exception("Unable to search for repositories. Please try again.", e); } }); SearchCommand.IsExecuting.Skip(1).Subscribe(x => { if (x) { networkActivityService.PushNetworkActive(); } else { networkActivityService.PopNetworkActive(); } }); }
public static IDisposable TriggerNetworkActivity(this IReactiveCommand @this, INetworkActivityService networkActivity) { return(@this.IsExecuting.Skip(1).Subscribe(x => { if (x) { networkActivity.PushNetworkActive(); } else { networkActivity.PopNetworkActive(); } })); }
public RepositoriesExploreViewModel(IApplicationService applicationService, INetworkActivityService networkActivityService) { _applicationService = applicationService; var gotoRepository = new Action <RepositoryItemViewModel>(x => { var vm = CreateViewModel <RepositoryViewModel>(); vm.RepositoryOwner = x.Owner; vm.RepositoryName = x.Name; ShowViewModel(vm); }); var repositories = new ReactiveList <RepositorySearchModel.RepositoryModel>(); Repositories = repositories.CreateDerivedCollection(x => new RepositoryItemViewModel(x.Name, x.Owner.Login, x.Owner.AvatarUrl, x.Description, x.StargazersCount, x.ForksCount, true, gotoRepository)); SearchCommand = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.SearchText).Select(x => !string.IsNullOrEmpty(x)), async t => { try { var request = applicationService.Client.Repositories.SearchRepositories(new[] { SearchText }, new string[] { }); request.UseCache = false; var response = await applicationService.Client.ExecuteAsync(request); repositories.Reset(response.Data.Items); } catch (Exception e) { throw new Exception("Unable to search for repositories. Please try again.", e); } }); SearchCommand.IsExecuting.Skip(1).Subscribe(x => { if (x) { networkActivityService.PushNetworkActive(); } else { networkActivityService.PopNetworkActive(); } }); }
public RepositoriesExploreViewModel(IApplicationService applicationService, INetworkActivityService networkActivityService) { _applicationService = applicationService; var gotoRepository = new Action<RepositoryItemViewModel>(x => { var vm = CreateViewModel<RepositoryViewModel>(); vm.RepositoryOwner = x.Owner; vm.RepositoryName = x.Name; ShowViewModel(vm); }); var repositories = new ReactiveList<RepositorySearchModel.RepositoryModel>(); Repositories = repositories.CreateDerivedCollection(x => new RepositoryItemViewModel(x.Name, x.Owner.Login, x.Owner.AvatarUrl, x.Description, x.StargazersCount, x.ForksCount, true, gotoRepository)); SearchCommand = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.SearchText).Select(x => !string.IsNullOrEmpty(x)), async t => { try { var request = applicationService.Client.Repositories.SearchRepositories(new[] { SearchText }, new string[] { }); request.UseCache = false; var response = await applicationService.Client.ExecuteAsync(request); repositories.Reset(response.Data.Items); } catch (Exception e) { throw new Exception("Unable to search for repositories. Please try again.", e); } }); SearchCommand.IsExecuting.Skip(1).Subscribe(x => { if (x) networkActivityService.PushNetworkActive(); else networkActivityService.PopNetworkActive(); }); }
public RepositoriesExploreViewModel(IApplicationService applicationService, INetworkActivityService networkActivityService) { _applicationService = applicationService; Repositories = new ReactiveCollection<RepositorySearchModel.RepositoryModel>(); SearchCommand = new ReactiveCommand(this.WhenAnyValue(x => x.SearchText, x => !string.IsNullOrEmpty(x))); SearchCommand.IsExecuting.Skip(1).Subscribe(x => { if (x) networkActivityService.PushNetworkActive(); else networkActivityService.PopNetworkActive(); }); SearchCommand.RegisterAsyncTask(async t => { try { var request = applicationService.Client.Repositories.SearchRepositories(new[] { SearchText }, new string[] { }); request.UseCache = false; var response = await applicationService.Client.ExecuteAsync(request); Repositories.Reset(response.Data.Items); } catch (Exception e) { throw new Exception("Unable to search for repositories. Please try again.", e); } }); GoToRepositoryCommand = new ReactiveCommand(); GoToRepositoryCommand.OfType<RepositorySearchModel.RepositoryModel>().Subscribe(x => { var vm = CreateViewModel<RepositoryViewModel>(); vm.RepositoryOwner = x.Owner.Login; vm.RepositoryName = x.Name; ShowViewModel(vm); }); }
protected virtual void OnLoadError(object sender, UIWebErrorArgs e) { _networkActivityService.PopNetworkActive(); }