コード例 #1
0
        async void DoFetch(bool forceRefresh = false)
        {
            fetching = true;
            bool hadError = false;

            do
            {
                statusText.Visibility = hadError ? ViewStates.Visible : ViewStates.Invisible;
                var credentials = StoredCredentials;
                if (string.IsNullOrEmpty(credentials.Username) || string.IsNullOrEmpty(credentials.Password))
                {
                    SwitchLayoutPhase(LayoutPhase.Login);
                }
                if (currentLayoutPhase == LayoutPhase.Login)
                {
                    password.Text     = string.Empty;
                    StoredCredentials = credentials = await AcceptUserInputAsync();
                }
                rentals = new HubwayRentals(StoredCookies, credentials);
                SwitchLayoutPhase(LayoutPhase.Loading);
                hadError = !(await GetRentals(forceRefresh));
                if (hadError)
                {
                    StoredCredentials = new RentalCrendentials();
                }
            } while (hadError);
            fetching = false;
        }
コード例 #2
0
ファイル: RentalFragment.cs プロジェクト: vizzcaindra/Moyeu
        async void DoFetch(bool forceRefresh = false)
        {
            LoginDialogFragment dialog = null;
            bool hadError = false;

            do
            {
                if (dialog != null)
                {
                    dialog.AdvertiseLoginError();
                }
                var credentials = StoredCredentials;
                if (dialog == null &&
                    (string.IsNullOrEmpty(credentials.Username) ||
                     string.IsNullOrEmpty(credentials.Password)))
                {
                    dialog            = new LoginDialogFragment();
                    dialog.Dismissed += (sender, e) => {
                        if (string.IsNullOrEmpty(credentials.Username) ||
                            string.IsNullOrEmpty(credentials.Password) ||
                            hadError)
                        {
                            Finish();
                        }
                    };
                    dialog.Show(ChildFragmentManager, "loginDialog");
                }
                if (dialog != null)
                {
                    StoredCredentials = credentials = await dialog.GetCredentialsAsync();
                }
                rentals  = new HubwayRentals(StoredCookies, credentials);
                hadError = !(await GetRentals(forceRefresh));
                if (hadError)
                {
                    StoredCredentials = new RentalCrendentials();
                }
            } while (hadError);
            if (dialog != null)
            {
                dialog.Dismiss();
            }
            if (refreshLayout != null && refreshLayout.Refreshing)
            {
                refreshLayout.Refreshing = false;
            }
        }
コード例 #3
0
ファイル: RentalFragment.cs プロジェクト: adamgoodrich/Moyeu
		async void DoFetch (bool forceRefresh = false)
		{
			LoginDialogFragment dialog = null;
			bool hadError = false;
			do {
				if (dialog != null)
					dialog.AdvertiseLoginError ();
				var credentials = StoredCredentials;
				if (dialog == null &&
				    (string.IsNullOrEmpty (credentials.Username) ||
				    string.IsNullOrEmpty (credentials.Password))) {
					dialog = new LoginDialogFragment ();
					dialog.Dismissed += (sender, e) => {
						if (string.IsNullOrEmpty (credentials.Username)
						    || string.IsNullOrEmpty (credentials.Password)
						    || hadError)
							Finish ();
					};
					dialog.Show (ChildFragmentManager, "loginDialog");
				}
				if (dialog != null)
					StoredCredentials = credentials = await dialog.GetCredentialsAsync ();
				rentals = new HubwayRentals (StoredCookies, credentials);
				hadError = !(await GetRentals (forceRefresh));
				if (hadError)
					StoredCredentials = new RentalCrendentials ();
			} while (hadError);
			if (dialog != null)
				dialog.Dismiss ();
			if (refreshLayout != null && refreshLayout.Refreshing)
				refreshLayout.Refreshing = false;
		}
コード例 #4
0
		async void DoFetch (bool forceRefresh = false)
		{
			fetching = true;
			bool hadError = false;
			do {
				statusText.Visibility = hadError ? ViewStates.Visible : ViewStates.Invisible;
				var credentials = StoredCredentials;
				if (string.IsNullOrEmpty (credentials.Username) || string.IsNullOrEmpty (credentials.Password))
					SwitchLayoutPhase (LayoutPhase.Login);
				if (currentLayoutPhase == LayoutPhase.Login) {
					password.Text = string.Empty;
					StoredCredentials = credentials = await AcceptUserInputAsync ();
				}
				rentals = new HubwayRentals (StoredCookies, credentials);
				SwitchLayoutPhase (LayoutPhase.Loading);
				hadError = !(await GetRentals (forceRefresh));
				if (hadError)
					StoredCredentials = new RentalCrendentials ();
			} while (hadError);
			fetching = false;
		}