ContactsViewAdapter RefreshAdapter() { AuthenticationService.LoggedUser.Contacts.Clear(); ContactsService contactsService = new ContactsService(); AuthenticationService.LoggedUser.Contacts = contactsService.GetAllByUserID(AuthenticationService.LoggedUser.ID).ToList(); ContactsViewAdapter contactNames = new ContactsViewAdapter(this, Resource.Layout.ViewModel, AuthenticationService.LoggedUser.Contacts); return(contactNames); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainScreen); ContactsService contactsService = new ContactsService(); AuthenticationService.LoggedUser.Contacts = contactsService.GetAllByUserID(AuthenticationService.LoggedUser.ID).ToList(); //AuthenticationService.LoggedUser.Contacts = AuthenticationService.LoggedUser.Contacts.OrderBy(c=>c.FirstName).ToList(); Button btnDelete = FindViewById <Button>(Resource.Id.btnDelete); Button btnAddContact = FindViewById <Button>(Resource.Id.btnAddContact); Button btnEditUser = FindViewById <Button>(Resource.Id.btnEditUser); TextView userLabel = FindViewById <TextView>(Resource.Id.textViewUser); ImageView userImage = FindViewById <ImageView>(Resource.Id.userImage); TextView userMail = FindViewById <TextView>(Resource.Id.textViewEmail); userLabel.Text = AuthenticationService.LoggedUser.FirstName + " " + AuthenticationService.LoggedUser.LastName; userMail.Text = "Email: " + AuthenticationService.LoggedUser.Email; if (AuthenticationService.LoggedUser.ImageURI != null) { Android.Net.Uri imageUri = Android.Net.Uri.Parse(AuthenticationService.LoggedUser.ImageURI); userImage.SetImageURI(imageUri); } ListView listViewContacts = FindViewById <ListView>(Resource.Id.listViewContacts); listViewContacts.ChoiceMode = ChoiceMode.Multiple; listViewContacts.Adapter = RefreshAdapter(); //trigers the ListViewContacts_ItemLongClick event listViewContacts.ItemLongClick += ListViewContacts_ItemLongClick; //trigers the ListViewContacts_ItemClick event listViewContacts.ItemClick += ListViewContacts_ItemClick; //creates an activity to add a new contact btnAddContact.Click += BtnAddContact_Click; //creates an activity to edit user btnEditUser.Click += BtnEditUser_Click; //creates an activity to delete contacts btnDelete.Click += BtnDelete_Click; //adds an image to the ImageView userImage.Click += UserImage_Click; }