void MainPage_Loaded(object sender, RoutedEventArgs e) { if (viewModel.Contacts.Count > 0) { return; } viewModel.GetContactsAsync(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var root = inflater.Inflate(Resource.Layout.fragment_contacts, container, false); refresher = root.FindViewById <SwipeRefreshLayout>(Resource.Id.refresher); refresher.SetColorScheme(Resource.Color.blue); refresher.Refresh += async delegate { if (viewModel.IsBusy) { return; } await viewModel.GetContactsAsync(); Activity.RunOnUiThread(() => { ((BaseAdapter)listView.Adapter).NotifyDataSetChanged(); }); }; viewModel.PropertyChanged += PropertyChanged; listView = root.FindViewById <ListView>(Resource.Id.list); listView.Adapter = new ContactAdapter(Activity, viewModel); listView.ItemLongClick += ListViewItemLongClick; listView.ItemClick += ListViewItemClick; var fab = root.FindViewById <FloatingActionButton>(Resource.Id.fab); fab.AttachToListView(listView); fab.Click += (sender, args) => { ContactDetailsActivity.ViewModel = null; var intent = new Intent(Activity, typeof(ContactDetailsActivity)); StartActivity(intent); }; return(root); }