public static bool Login(Android.Content.Context ctx, string username, string password) { bool isSuccessful = false; User user = User.Login(ctx, username, password); if (user != null) { Common.CurrentDealerID = user.deal_id; isSuccessful = true; PreferencesUtil.Username = username; PreferencesUtil.Password = password; PreferencesUtil.SavePreferences(ctx); } return(isSuccessful); }
void ActionBarButtonClicked(int id) { switch (id) { case ControlIds.SETTINGS_MENU_BUTTON: { ((Main)this.Activity).ToggleMenu(); } break; case ControlIds.SETTINGS_BACK_BUTTON: if (Common.CurrentDealerID == 0) { if (this.Activity == null) { return; //? } this.Activity.SupportFragmentManager.PopBackStack(); /*if (Common.isTabletDevice(this.Activity)) * { * var ft = this.Activity.SupportFragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.detailInfo_fragment, new LoginFragment()); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * } * else * { * var intent = new Android.Content.Intent(); * intent.SetClass(this.Activity, typeof(LoginFragmentActivity)); * StartActivity(intent); * }*/ } break; case ControlIds.SETTINGS_SAVE_BUTTON: try { PreferencesUtil.IP = tbIP.Text; PreferencesUtil.Port = int.Parse(tbPort.Text); PreferencesUtil.SyncModel = tbSyncModel.Text; PreferencesUtil.SyncUser = tbSyncUser.Text; PreferencesUtil.SyncPass = tbSyncPass.Text; PreferencesUtil.SavePreferences(this.Activity); Toast.MakeText(this.Activity.ApplicationContext, "Saved", ToastLength.Short).Show(); if (Common.CurrentDealerID == 0) { /*var ft = this.Activity.SupportFragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.fragment1, new LoginFragment()); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); */ this.Activity.SupportFragmentManager.PopBackStack(); /*if (Common.isTabletDevice(this.Activity)) * { * var ft = this.Activity.SupportFragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.detailInfo_fragment, new LoginFragment()); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * } * else * { * var intent = new Android.Content.Intent(); * intent.SetClass(this.Activity, typeof(LoginFragmentActivity)); * StartActivity(intent); * }*/ } } catch (Exception ex) { Android.Util.Log.Error("ActionBarButtonClicked SAVE_BUTTON", ex.Message); } break; } }