void ListViewItemClick(object sender, AdapterView.ItemClickEventArgs e) { var contact = viewModel.Contacts[e.Position]; var vm = new DetailsViewModel(contact); ContactDetailsActivity.ViewModel = vm; var intent = new Intent(Activity, typeof(ContactDetailsActivity)); StartActivity(intent); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); if (ViewModel == null) { ViewModel = new DetailsViewModel(); NavigationItem.RightBarButtonItem = save; } else { this.Title = ViewModel.FirstName; TextEmail.Text = ViewModel.Email; TextFirst.Text = ViewModel.FirstName; TextLast.Text = ViewModel.LastName; TextPhone.Text = ViewModel.Phone; ImagePhoto.SetImage( url: new NSUrl(Gravatar.GetURL(ViewModel.Contact.EmailAddresses[0].Address, 172)), placeholder: UIImage.FromBundle("missing.png") ); NavigationItem.RightBarButtonItem = null; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); email = FindViewById<EditText>(Resource.Id.email); phone = FindViewById<EditText>(Resource.Id.phone); firstName = FindViewById<EditText>(Resource.Id.first_name); lastName = FindViewById<EditText>(Resource.Id.last_name); photo = FindViewById<ImageView>(Resource.Id.photo2); email.TextChanged += (sender, args) => { Koush.UrlImageViewHelper.SetUrlDrawable(photo, Gravatar.GetURL(email.Text, 88), Resource.Drawable.missing); }; if (ViewModel == null) { ViewModel = new DetailsViewModel(); } else { SupportActionBar.Title = ViewModel.FirstName + " " + ViewModel.LastName; email.Text = ViewModel.Email; firstName.Text = ViewModel.FirstName; lastName.Text = ViewModel.LastName; phone.Text = ViewModel.Phone; } var bottomToolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar_bottom); bottomToolbar.InflateMenu(Resource.Menu.detail_bottom); bottomToolbar.MenuItemClick += (sender, args) => { switch (args.Item.ItemId) { case Resource.Id.calendar: App.NewEventViewModel.Email = ViewModel.Email; App.NewEventViewModel.FirstName = ViewModel.FirstName; App.NewEventViewModel.LastName = ViewModel.LastName; StartActivity(typeof(NewEventActivity)); //ViewModel.AddEvent(new[] { ViewModel.Email }, new[] { ViewModel.FirstName }); break; case Resource.Id.phone: var uri = Android.Net.Uri.Parse("tel:" + ViewModel.Phone); var intent = new Intent(Intent.ActionView, uri); StartActivity(intent); break; case Resource.Id.email: App.SendEmailViewModel.Email = ViewModel.Email; App.SendEmailViewModel.FirstName = ViewModel.FirstName; App.SendEmailViewModel.LastName = ViewModel.LastName; StartActivity(typeof(SendEmailActivity)); break; } }; }