Esempio n. 1
0
 private void SignOutButtonOnClick(object sender, EventArgs e)
 {
     new Thread(new ThreadStart(() =>
     {
         XUserMethod methods = new XUserMethod();
         methods.Logout();
         RunOnUiThread(() => Finish());
     })).Start();
 }
Esempio n. 2
0
        private void SignInButtonOnClick(object sender, EventArgs e)
        {
            new Thread(new ThreadStart(() =>
            {
                XUserMethod methods     = new XUserMethod();
                ProgressDialog progress = null;

                RunOnUiThread(() =>
                {
                    progress = ProgressDialog.Show(
                        this,
                        Resources.GetString(Resource.String.please_wait),
                        Resources.GetString(Resource.String.please_wait),
                        true,
                        true,
                        delegate { Finish(); }
                        );
                });

                if (Utility.IsNetworkAvailable(this))
                {
                    try
                    {
                        methods.Login(emailAddressEditText.Text.Trim(), passwordEditText.Text);
                    }
                    catch (WebApiClientException)
                    {
                        // Do nothing
                    }
                }

                RunOnUiThread(() =>
                {
                    progress.Hide();
                    if (methods.IsLoginSuccessful)
                    {
                        new AlertDialog.Builder(this)
                        .SetTitle(Resource.String.message)
                        .SetMessage(Resource.String.login_successful)
                        .SetPositiveButton(Resource.String.confirm_dialog_ok, delegate { Finish(); })
                        .Create().Show();
                    }
                    else
                    {
                        new AlertDialog.Builder(this)
                        .SetTitle(Resource.String.error)
                        .SetMessage(Resource.String.login_failed)
                        .SetPositiveButton(Resource.String.confirm_dialog_ok, delegate { })
                        .Create().Show();
                    }
                });
            })).Start();
        }
Esempio n. 3
0
        private void SignUpButtonOnClick(object sender, EventArgs args)
        {
            new Thread(new ThreadStart(() =>
            {
                XUserMethod userMethod  = new XUserMethod();
                ProgressDialog progress = null;

                RunOnUiThread(() =>
                {
                    progress = ProgressDialog.Show(
                        this,
                        Resources.GetString(Resource.String.please_wait),
                        Resources.GetString(Resource.String.please_wait),
                        true,
                        false
                        );
                });

                string username       = FindViewById <EditText>(Resource.Id.edit_text_email_address).Text;
                string password       = FindViewById <EditText>(Resource.Id.edit_text_password).Text;
                string passwordRetype = FindViewById <EditText>(Resource.Id.edit_text_repeat_password).Text;

                if (username.Length == 0 || password.Length == 0)
                {
                    new AlertDialog.Builder(this)
                    .SetTitle(Resource.String.error)
                    .SetMessage(Resource.String.fill_all_fields)
                    .SetPositiveButton(Resource.String.confirm_dialog_ok, delegate { })
                    .Show();
                    return;
                }

                if (password.Length < 6)
                {
                    new AlertDialog.Builder(this)
                    .SetTitle(Resource.String.error)
                    .SetMessage(Resource.String.password_too_short)
                    .SetPositiveButton(Resource.String.confirm_dialog_ok, delegate { })
                    .Show();
                    return;
                }

                if (password != passwordRetype)
                {
                    new AlertDialog.Builder(this)
                    .SetTitle(Resource.String.error)
                    .SetMessage(Resource.String.passwords_dont_match)
                    .SetPositiveButton(Resource.String.confirm_dialog_ok, delegate { })
                    .Show();
                    return;
                }

                userMethod.Register(username, password);

                RunOnUiThread(() =>
                {
                    progress.Hide();
                    if (!userMethod.IsRegisterSuccessful)
                    {
                        new AlertDialog.Builder(this)
                        .SetTitle(Resource.String.error)
                        .SetMessage(Resource.String.register_failed)
                        .SetPositiveButton(Resource.String.confirm_dialog_ok, delegate { })
                        .Show();
                    }
                    else
                    {
                        new AlertDialog.Builder(this)
                        .SetTitle(Resource.String.message)
                        .SetMessage(Resource.String.register_successful)
                        .SetPositiveButton(Resource.String.confirm_dialog_ok, delegate { Finish(); })
                        .SetCancelable(false)
                        .Show();
                    }
                });
            })).Start();
        }