async void Refresher_Refresh(object sender, EventArgs e) { await ViewModel.ExecuteBuildingsCommand(facilityId); recyclerView.SetAdapter(adapter = new BrowseBuildingsAdapter(this, ViewModel)); refresher.Refreshing = false; refresher.Refresh += Refresher_Refresh; adapter.ItemClick += Adapter_ItemClick; }
protected async override void OnStart() { base.OnStart(); if (ViewModel.Buildings.Count == 0) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); await ViewModel.ExecuteBuildingsCommand(facilityId); recyclerView.HasFixedSize = true; recyclerView.SetAdapter(adapter = new BrowseBuildingsAdapter(this, ViewModel)); messageDialog.HideLoading(); } refresher.Refresh += Refresher_Refresh; adapter.ItemClick += Adapter_ItemClick; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); ViewModel = new BuildingsViewModel(); AppPreferences ap = new AppPreferences(Application.Context); facilityId = Convert.ToInt32(ap.GetFacilityId()); var data = Intent.GetStringExtra("data"); informationButton = FindViewById <Button>(Resource.Id.information_button); informationButton.Touch += (sender, e) => { var intent = new Intent(this, typeof(FacilityInformationActivity)); StartActivity(intent); }; recyclerView = FindViewById <RecyclerView>(Resource.Id.buildingRecyclerView); addButton = FindViewById <FloatingActionButton>(Resource.Id.addnewBuilding_button); recyclerView.HasFixedSize = true; recyclerView.SetAdapter(adapter = new BrowseBuildingsAdapter(this, ViewModel)); refresher = FindViewById <SwipeRefreshLayout>(Resource.Id.buildingRefresher); refresher.SetColorSchemeColors(Resource.Color.accent); addButton.Click += AddButton_Click; addButton.SetBackgroundColor(Android.Graphics.Color.Tan); Toolbar.MenuItemClick += (sender, e) => { var intent = new Intent(this, typeof(LoginActivity)); ap.SaveUserId("0"); StartActivity(intent); }; if (data != null) { facility = Newtonsoft.Json.JsonConvert.DeserializeObject <Facility>(data); SupportActionBar.Title = facility.Name; } SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); }