Example #1
0
        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 ProntoRentals(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;
            }
        }
Example #2
0
		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 ProntoRentals (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;
		}