Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            cm = (ConnectivityManager)this.GetSystemService(Context.ConnectivityService);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Login);
            // Get our button from the layout resource,
            // and attach an event to it

            Button   LoginBtn      = FindViewById <Button> (Resource.Id.loginButton);
            EditText emailInput    = FindViewById <EditText> (Resource.Id.emailInput);
            EditText passwordInput = FindViewById <EditText> (Resource.Id.passwordInput);

            LoginBtn.Click += delegate {
                if (checkNetwork())
                {
                    if (emailInput.Text != "" && passwordInput.Text != "")
                    {
                        string email = RemoveSpecialCharacters(emailInput.Text);
//				string password = RemoveSpecialCharactersPassword (passwordInput.Text);
                        string password = passwordInput.Text;
                        NetworkCalls.getURL();
                        //Console.WriteLine("URL print"+DataController.url);
                        bool success = NetworkCalls.Login(email, password, "");
                        //Console.WriteLine("Username " + email);
                        //Console.WriteLine("Password " + password);

                        if (success)
                        {
                            //load next window
                            //Console.WriteLine("Login Successful");
                            DataController.userEmail = email;
                            StartActivity(typeof(HomeView));
                        }
                        else
                        {
                            Toast loginFailed = new Toast(this);
                            loginFailed = Toast.MakeText(Application.Context, "Login Failed, Please check details and try again.", ToastLength.Short);
                            loginFailed.Show();
                        }
                    }
                    else
                    {
                        Toast invalidDetails = new Toast(this);
                        invalidDetails = Toast.MakeText(Application.Context, "Login Failed, Username/Password cannot be empty.", ToastLength.Short);
                        invalidDetails.Show();
                    }
                }
                else
                {
                    showNetworkError();
                }
            };
        }