protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Window.RequestFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.SplashScreenLayout); mProgressBar = FindViewById <ProgressBar>(Resource.Id.progressBarSplashScreen); mProgressBar.Visibility = Android.Views.ViewStates.Invisible; db.CreateDatabase(); ListSource = db.SelectTable(); if (ListSource.Count == 0) { UserInfoLocal userInfoLocal = new UserInfoLocal() { IsLogin = 0, UserInfoId = "", }; SplashScreenActivity.db.InsertIntoTable(userInfoLocal); var intent = new Intent(this, typeof(LoginPageActivity)); UpgradeProgress(); RunOnUiThread(() => mProgressBar.Visibility = Android.Views.ViewStates.Invisible); this.StartActivity(intent); } else { var intent = new Intent(); if (ListSource[0].Id == 1 && ListSource[0].IsLogin == 1) { LoginPageActivity.StaticUserClass.ID = Guid.Parse(ListSource[0].UserInfoId); intent = new Intent(this, typeof(MainActivity)); LoadData(); UpgradeProgress(); RunOnUiThread(() => mProgressBar.Visibility = Android.Views.ViewStates.Invisible); this.StartActivity(intent); } else if (ListSource[0].Id == 1 && ListSource[0].IsLogin == 0) { intent = new Intent(this, typeof(LoginPageActivity)); UpgradeProgress(); RunOnUiThread(() => mProgressBar.Visibility = Android.Views.ViewStates.Invisible); this.StartActivity(intent); } } }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alert = new AlertDialog.Builder(Activity); alert.SetTitle("Logout"); alert.SetMessage("Are you sure want to logout?"); alert.SetPositiveButton("Logout", (senderAlert, args) => { UserInfoLocal userInfoLocal = new UserInfoLocal() { Id = 1, IsLogin = 0, UserInfoId = "", }; SplashScreenActivity.db.UpdateTable(userInfoLocal); var intent = new Intent(this.Activity, typeof(LoginPageActivity)); this.StartActivity(intent); }); alert.SetNegativeButton("Cancel", (senderAlert, args) => { Toast.MakeText(Activity, "Cancelled!", ToastLength.Short).Show(); }); return(alert.Create()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Window.RequestFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.LoginPageStart); // Create your application here mBtnLogIn = FindViewById <Button>(Resource.Id.buttonLoginPageLogin); mBtnSignUp = FindViewById <Button>(Resource.Id.buttonLoginPageSignUp); mEmail = FindViewById <EditText>(Resource.Id.textInputEditTextLoginPageEmail); mPassword = FindViewById <EditText>(Resource.Id.editTextLoginPagePassword); mProgressBar = FindViewById <ProgressBar>(Resource.Id.progressBar1); mPassword.Text = "Ganteng@123"; mEmail.Text = "*****@*****.**"; DateTime test = System.DateTime.Now; // Button Function mBtnLogIn.Click += (object sender, EventArgs e) => { mProgressBar.Visibility = Android.Views.ViewStates.Visible; new Thread(new ThreadStart(async delegate { var intent = new Intent(this, typeof(MainActivity)); var user = mEmail.Text; var pass = mPassword.Text; var isLogin = await mAccountDataService.Login(user, pass); var UserInfo = await mAccountDataService.GetUserInfo(); var temp = UserInfo.ID; StaticUserClass.ID = Guid.Parse(temp); StaticUserClass.Username = UserInfo.Email; LoadData(); //intent.PutExtra("AuthorizedUserId", UserInfo.ID.ToString()); UpgradeProgress(); if (isLogin) { UserInfoLocal userInfoLocal = new UserInfoLocal() { Id = 1, IsLogin = 1, UserInfoId = StaticUserClass.ID.ToString(), }; SplashScreenActivity.db.UpdateTable(userInfoLocal); RunOnUiThread(() => mProgressBar.Visibility = Android.Views.ViewStates.Invisible); this.StartActivity(intent); } else { RunOnUiThread(() => Toast.MakeText(this, "Failed to login", ToastLength.Long).Show()); } })).Start(); }; mBtnSignUp.Click += (object sender, EventArgs e) => { //var intent = new Intent(this, typeof(SignupPageActivity)); //this.StartActivity(intent); }; }