Пример #1
0
        // Perform authentication and quit to mainactivity if ok
        private void PerformAuthentication(ProgressDialog progressDialog)
        {
            // Check that filled values are valid
            GCStuffs gc = new GCStuffs();

            // Retrieve edittext for password & login
            EditText txtLogin    = FindViewById <EditText>(Resource.Id.editLogin);
            EditText txtPassword = FindViewById <EditText>(Resource.Id.editPassword);

            if (gc.CheckGCAccount(txtLogin.Text, txtPassword.Text, true, this))
            {
                Thread.Sleep(1000);

                // We have valid information
                // We save the configuration
                GCStuffs.ExportData(txtLogin.Text, txtPassword.Text);

                // Kill progressdialog (we are in UI thread already, good)
                RunOnUiThread(() => progressDialog.Hide());

                // All right!
                RunOnUiThread(() => Toast.MakeText(this, this.Resources.GetString(Resource.String.AccountGood) + " " + txtLogin.Text, ToastLength.Short).Show());

                // Go back in MainActivity and pass the valid login & password
                var intent = new Intent(this, typeof(MainActivity));
                SetResult(Result.Ok, intent);
                Finish();
            }
            else
            {
                // Kill progressdialog (we are in UI thread already, good)
                RunOnUiThread(() => progressDialog.Hide());

                // Invalid account information, throw a message
                RunOnUiThread(() => Toast.MakeText(this, this.Resources.GetString(Resource.String.AccountError), ToastLength.Short).Show());
            }
        }