private void List_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { Console.WriteLine(e.Position); SetContentView(Resource.Layout.Messenger); SendButton = FindViewById <ImageButton>(Resource.Id.SendButton); SendButton.Click += SendButton_Click; BackButton = FindViewById <ImageButton>(Resource.Id.BackButton); BackButton.Click += SwitchToContacts_Button; ListView messageListView = FindViewById <ListView>(Resource.Id.messageListView); TextView contactTitle = FindViewById <TextView>(Resource.Id.contactNameHeader); contactTitle.Text = LoggedUser.ContactList[e.Position].Username; if (LoggedUser.ContactList[e.Position].messageList == null) { LoggedUser.ContactList[e.Position].messageList = new List <MessageObject>(); } LoggedUser.ContactList[e.Position].ListPosition = e.Position; MessageAdapter adapter = new MessageAdapter(this, LoggedUser.ContactList[e.Position].messageList); messageListView.Adapter = adapter; messageListView.SetSelection(adapter.Count - 1); DbContact newContact = new DbContact(); newContact.Username = LoggedUser.ContactList[e.Position].Username; newContact.Id = LoggedUser.ContactList[e.Position].Id; currentContact = LoggedUser.ContactList[e.Position]; currentContactPosition = e.Position; RefreshButton = FindViewById <ImageButton>(Resource.Id.RefreshButton); RefreshButton.Click += RefreshButton_Click; MessengerLoader = FindViewById <ProgressBar>(Resource.Id.MessengerLoader); }
private void AddNewContact(object sender, EventArgs e) { AddNewContactButton.Enabled = false; string contact = ContactInput.Text; if (contact != "") { NameValueCollection parameters = new NameValueCollection(); parameters.Add("Username", LoggedUser.Username); parameters.Add("Password", LoggedUser.Password); parameters.Add("Request", "FriendRequest"); DbContact newContact = new DbContact(); newContact.Username = contact; newContact.Id = "0"; parameters.Add("Contact", JsonConvert.SerializeObject(newContact)); mClient.UploadValuesAsync(mUri, parameters); mClient.UploadValuesCompleted += FriendRequestSent; } else { Toast.MakeText(this, "Please enter a contact name!", ToastLength.Long).Show();; } }