Exemplo n.º 1
0
        private async void LoginButton_Click(object sender, EventArgs e)
        {
            loginButton.Enabled = false;
            try
            {
                await GlobalServices.XjtuSite.Account.LoginAsync(userNameView.Text, passwordView.Text);

                // ±£´æÉèÖá£
                using (var pref = GetPreferences(FileCreationMode.Private))
                {
                    var edit         = pref.Edit();
                    var savePassword = savePasswordCheckBox.Checked;
                    edit.PutString("userName", userNameView.Text);
                    edit.PutString("password", savePassword ? passwordView.Text : "");
                    edit.PutBoolean("savePassword", savePassword);
                    edit.Commit();
                }
                GlobalServices.SaveState();
                DroidUtility.ShowToast(this, "µÇ¼³É¹¦¡£");
            }
            catch (Exception ex)
            {
                DroidUtility.ReportException(this, ex);
            }
            finally
            {
                loginButton.Enabled = true;
            }
        }
Exemplo n.º 2
0
        private async Task Redirect()
        {
            offlineNotice.Visibility = ViewStates.Gone;
            if (GlobalServices.XjtuSite.Account.IsInvalidated)
            {
                try
                {
                    await GlobalServices.XjtuSite.Account.UpdateAsync();
                }
                catch (Exception ex) when(ex is WebException || ex is TaskCanceledException)
                {
                    offlineNotice.Visibility = ViewStates.Visible;
                    DroidUtility.ReportException(this, ex);
                    return;
                }
            }
            var intent = new Intent(this, GlobalServices.XjtuSite.Account.IsLoggedIn
                ? typeof(MainActivity)
                : typeof(LoginActivity));

            StartActivity(intent);
            this.Finish();
        }