private void Btn_okSelRates_Click(object sender, EventArgs e) { var intentMainActivity = new Intent(this, typeof(MainActivity)); var listOfPairs = new List <ListForSharedPref>(); ListForSharedPref o; for (var i = 0; i < selectedCurrencies_Names.Count; i++) { o = new ListForSharedPref() { Name = selectedCurrencies_Names[i], Value = selectedCurrencies_Values[i] }; listOfPairs.Add(o); } string json = JsonConvert.SerializeObject(listOfPairs); string jsonElements = JsonConvert.SerializeObject(elements); ISharedPreferences pref = Application.Context.GetSharedPreferences("ListPref", FileCreationMode.Private); ISharedPreferencesEditor edit = pref.Edit(); edit.Clear(); var _date = date.ToString(); edit.PutString("dateOfUpdate", _date); edit.PutString("elementsList", jsonElements); edit.PutString("list", json); //przekazuje zaserializowany obiekt zeby elementy 2 list nie byly segregowane niezaleznie od siebie edit.Apply(); this.StartActivity(intentMainActivity); }
private async void Btn_ok_Click(object sender, EventArgs e) { var intent = new Intent(this, typeof(MainActivity)); serv_data = new Currencies(); this.StartActivity(intent); var list = new List <ListForSharedPref>(); ListForSharedPref o; for (var i = 0; i < listNames.Count; i++) { o = new ListForSharedPref() { Name = listNames[i], Value = listValues[i], OverOrUnder = switches[i].Checked }; list.Add(o); listOver[i] = switches[i].Checked; } if (listNames.Count >= 1) { serv_data.FirstCurrency = listNames[0]; serv_data.FirstCurrencyValue = listValues[0]; serv_data.FirstCurrencyOver = listOver[0]; } if (listNames.Count >= 2) { serv_data.SecondCurrency = listNames[1]; serv_data.SecondCurrencyValue = listValues[1]; serv_data.SecondCurrencyOver = listOver[1]; } if (listNames.Count >= 3) { serv_data.ThirdCurrency = listNames[2]; serv_data.ThirdCurrencyValue = listValues[2]; serv_data.ThirdCurrencyOver = listOver[2]; } if (listNames.Count >= 4) { serv_data.FourthCurrency = listNames[3]; serv_data.FourthCurrencyValue = listValues[3]; serv_data.FourthCurrencyOver = listOver[3]; } if (listNames.Count >= 5) { serv_data.FifthCurrency = listNames[4]; serv_data.FifthCurrencyValue = listValues[4]; serv_data.FifthCurrencyOver = listOver[4]; } ChangeObjectIfValuesChanges(); //zmiana wartosci jesli sie textboxy zmieniaja ISharedPreferences pref = Application.Context.GetSharedPreferences("ListPref", FileCreationMode.Private); ISharedPreferencesEditor edit = pref.Edit(); //edit.Clear(); var temp_ID = (RegiID._id == null) ? pref.GetString("regiID", string.Empty) : RegiID._id; edit.PutString("regiID", temp_ID); serv_data.UserID = temp_ID; var tags = new List <string> { serv_data.FirstCurrencyValue, serv_data.SecondCurrencyValue, serv_data.ThirdCurrencyValue, serv_data.FourthCurrencyValue, serv_data.FifthCurrencyValue }; string jsonListValues = JsonConvert.SerializeObject(listValues); edit.PutString("listValues", jsonListValues); string jsonTags = JsonConvert.SerializeObject(tags); edit.PutString("tagsList", jsonTags); string jsonListOver = JsonConvert.SerializeObject(listOver); edit.PutString("listOver", jsonListOver); var listUserValues = new List <string>() { tb1.Text, tb2.Text, tb3.Text, tb4.Text, tb5.Text }; var jsonUserValues = JsonConvert.SerializeObject(listUserValues); edit.PutString("userValues", jsonUserValues); string jsonList = JsonConvert.SerializeObject(list); edit.PutString("list", jsonList); edit.Apply(); try { await SyncAsync(); } catch (Exception ex) { var exception = ex.Message; } Log.Info("MainActivity", "Registering..."); GcmClient.Register(this, Constants.SenderID); //this.StartActivity(intent); }