private void Spin_language_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { Spinner spinner = (Spinner)sender; string selectedItem = spinner.GetItemAtPosition(e.Position).ToString(); if (!selectedItem.Equals(mSharedPreferencesManager.GetString(ConstantsDroid.APP_LANG_PREFERENCE, ""))) { mSharedPreferencesManager.PutString(ConstantsDroid.APP_LANG_PREFERENCE, selectedItem); HelpMe.SetLocale(selectedItem, mActivity); ((TextView)spinner.GetChildAt(0)).SetTextColor(Color.White); StartActivity(typeof(LoginActivity)); OverridePendingTransition(Resource.Animation.animation_enter, Resource.Animation.animation_leave); Finish(); } }
private void InitializeListeners() { radio_group.CheckedChange += Radio_group_CheckedChange; // User Spinner spin_language.ItemSelected += (sender, args) => { _selectedLanguageItem = _languageSpinnerItemModelList[args.Position]; _languageSpinnerItemModelList[args.Position].STATE = true; // update spinner item list state for (int i = 0; i < _languageSpinnerItemModelList.Count; i++) { if (i == args.Position) { _languageSpinnerItemModelList[i].STATE = true; } else { _languageSpinnerItemModelList[i].STATE = false; } } _languageSpinnerAdapter.NotifyDataSetChanged(); string selectedItem = _selectedLanguageItem.TEXT.ToString(); if (!selectedItem.Equals(mSharedPreferencesManager.GetString(ConstantsDroid.APP_LANG_PREFERENCE, ""))) { mSharedPreferencesManager.PutString(ConstantsDroid.APP_LANG_PREFERENCE, selectedItem); HelpMe.SetLocale(selectedItem, mActivity); StartActivity(typeof(LoginActivity)); OverridePendingTransition(Resource.Animation.animation_enter, Resource.Animation.animation_leave); Finish(); } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Window.RequestFeature(WindowFeatures.NoTitle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_login); mActivity = this; /// Shared Preference manager mSharedPreferencesManager = UtilityDroid.GetInstance(). GetSharedPreferenceManagerWithEncriptionEnabled(mActivity.ApplicationContext); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.btn_login); button.Click += Button_Click; CheckBox chk_show_pwd = FindViewById <CheckBox>(Resource.Id.chk_show_pwd); chk_show_pwd.CheckedChange += Chk_show_pwd_CheckedChange; edt_username = FindViewById <EditText>(Resource.Id.edt_username); edt_password = FindViewById <EditText>(Resource.Id.edt_password); txt_database_name = FindViewById <TextView>(Resource.Id.txt_database_name); chk_remember_me = FindViewById <CheckBox>(Resource.Id.chk_remember_me); radio_group = FindViewById <RadioGroup>(Resource.Id.radio_group); radio_btn_db_demo = FindViewById <RadioButton>(Resource.Id.radio_btn_db_demo); radio_btn_db_saas = FindViewById <RadioButton>(Resource.Id.radio_btn_db_saas); radio_btn_db_hq = FindViewById <RadioButton>(Resource.Id.radio_btn_db_hq); radio_btn_db_lucid = FindViewById <RadioButton>(Resource.Id.radio_btn_db_lucid); radio_btn_db_demo.Checked = true; txt_database_name.Text = GetString(Resource.String.db_demo); username = mSharedPreferencesManager.GetString(ConstantsDroid.USERNAME_PREFERENCE, ""); password = mSharedPreferencesManager.GetString(ConstantsDroid.PASSWORD_PREFERENCE, ""); string databaseName = mSharedPreferencesManager.GetString(ConstantsDroid.DATABASE_PREFERENCE, GetString(Resource.String.db_demo_connection)); if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { chk_remember_me.Checked = true; edt_username.Text = username; edt_password.Text = password; if (databaseName.Equals(GetString(Resource.String.db_saas_connection))) { radio_btn_db_saas.Checked = true; WebserviceConstants.CONNECTION_NAME = GetString(Resource.String.db_saas_connection); txt_database_name.Text = "(" + GetString(Resource.String.db_saas) + ")"; } else if (databaseName.Equals(GetString(Resource.String.db_demo_connection))) { radio_btn_db_demo.Checked = true; WebserviceConstants.CONNECTION_NAME = GetString(Resource.String.db_demo_connection); txt_database_name.Text = "(" + GetString(Resource.String.db_demo) + ")"; } else if (databaseName.Equals(GetString(Resource.String.db_hq_connection))) { radio_btn_db_hq.Checked = true; WebserviceConstants.CONNECTION_NAME = GetString(Resource.String.db_hq_connection); txt_database_name.Text = "(" + GetString(Resource.String.db_hq) + ")"; } else { radio_btn_db_lucid.Checked = true; WebserviceConstants.CONNECTION_NAME = GetString(Resource.String.db_lucid_connection); txt_database_name.Text = "(" + GetString(Resource.String.db_lucid) + ")"; } } spin_language = FindViewById <Spinner>(Resource.Id.spin_language); // Set Language in spinner InitLanguageSpinnerValues(); SetLanguageSpinnerAdapter(); // Initialize listener for spinner InitializeListeners(); string preferenceLang = mSharedPreferencesManager.GetString(ConstantsDroid.APP_LANG_PREFERENCE, ConstantsDroid.LANG_ENGLISH_CODE); spin_language.SetSelection((preferenceLang.Equals(ConstantsDroid.LANG_ENGLISH_CODE)) ? 0 : 1); HelpMe.SetLocale(preferenceLang, mActivity); }