Ejemplo n.º 1
0
        private void OnButtonClick(ButtonClickEventArgs buttonClickEventArgs)
        {
            try
            {
                if (buttonClickEventArgs.ButtonClicked.Text == buttonClickEventArgs.Lst.First().CorrectAnswer)
                {
                    Toast.MakeText(Android.App.Application.Context, "Correct", ToastLength.Short).Show();
                    buttonClickEventArgs.Lst.RemoveAt(0);

                    TestFunction(buttonClickEventArgs.Lst);
                }
                else
                {
                    Toast.MakeText(Android.App.Application.Context, "Incorrect", ToastLength.Short).Show();
                    buttonClickEventArgs.Lst.RemoveAt(0);

                    TestFunction(buttonClickEventArgs.Lst);
                }
            }
            catch
            {
                //TODO: Email address is empty
                FragmentManager.PopBackStack();
                Android.Support.V4.App.Fragment fragment = new HomeFragment(EmailAddress, Token);
                FragmentManager.BeginTransaction().Replace(Resource.Id.fragment_container, fragment).Commit();

                return;
            }
        }
Ejemplo n.º 2
0
        private void CheckSession()
        {
            string androidID = Android.Provider.Settings.Secure.GetString(Android.App.Application.Context.ContentResolver,
                                                                          Android.Provider.Settings.Secure.AndroidId);

            try
            {
                Session item = session.GetSession(androidID).ConfigureAwait(false).GetAwaiter().GetResult();
                Android.Support.V4.App.Fragment homeFragment = new HomeFragment(item.Email, item.Token);
                FragmentManager.BeginTransaction().Replace(Resource.Id.parent_fragment, homeFragment).Commit();
            }
            catch { }
        }
Ejemplo n.º 3
0
        private async void OnLogin_Click(object sender, EventArgs e)
        {
            if (verify.CheckInternetConnection() == false)
            {
                alertWindow.Alert("", "No internet connection!", Activity);
            }
            else
            {
                //Preventing from multiple click
                btnLogin.Enabled = false;
                try
                {
                    //Getting id
                    var androidID = Android.Provider.Settings.Secure.GetString(Android.App.Application.Context.ContentResolver,
                                                                               Android.Provider.Settings.Secure.AndroidId);
                    Login login = firebaseHelper.GetLogin(etEmail.Text).ConfigureAwait(false).GetAwaiter().GetResult();
                    if (encryption.DecodePassword(login.Password) == etPassword.Text)
                    {
                        //Successful login
                        await session.AddSession(androidID, login.Email, login.Token);

                        Android.Support.V4.App.Fragment homeFragment = new HomeFragment(login.Email, login.Token);
                        FragmentManager.BeginTransaction().Replace(Resource.Id.parent_fragment, homeFragment).Commit();
                    }
                    else
                    {
                        alertWindow.Alert("Error!", "Incorrect email or password!", Activity);
                        btnLogin.Enabled = true;
                    }
                }
                catch
                {
                    alertWindow.Alert("Error!", "Incorrect email or password!", Activity);
                    btnLogin.Enabled = true;
                }
            }
        }
 public HomeFragment(HomeFragment fragment) : this(fragment.EmailAddress, fragment.Token)
 {
 }
 public TestsRecyclerView(HomeFragment fragment) : this(fragment.EmailAddress, fragment.Token)
 {
 }