private void ChangeSortMethod(PlaceSortMethod sortMethod) { NavigationItem.SetRightBarButtonItem (null, true); BusyView.Busy = true; Func<int> func = delegate { PlaceList list = new PlaceList (); if (sortMethod == PlaceSortMethod.Popularity) list = Engine.Instance.CheckInAccess.GetPopularPlaceList ( SystemConstants.MaxPlacesPerRequest); else if (sortMethod == PlaceSortMethod.NearConventionCenter) { list = Engine.Instance.CheckInAccess.GetPlaceListNearLocation ( SystemConstants.DefaultPlace.Latitude, SystemConstants.DefaultPlace.Longitude, SystemConstants.MaxPlacesPerRequest); } else if (sortMethod == PlaceSortMethod.NearUser) { GeolocationResult result = GeolocationHelper.GetLocation (); if (result.Position == null) { this.BeginInvokeOnMainThread (delegate { ShowLocatinError (new XamarinEvolveSSLibrary.PlaceList (), result); NavigationItem.SetRightBarButtonItem (_sortButton, true); }); return 0; } list = Engine.Instance.CheckInAccess.GetPlaceListNearLocation ( (float)result.Position.Latitude, (float)result.Position.Longitude, SystemConstants.MaxPlacesPerRequest); } else if (sortMethod == PlaceSortMethod.Recent) { list = Engine.Instance.CheckInAccess.GetRecentPlaceList ( SystemConstants.MaxPlacesPerRequest); } this.BeginInvokeOnMainThread (delegate { PlaceList = list; TableView.ReloadData (); SortMethod = sortMethod; BusyView.Busy = false; NavigationItem.SetRightBarButtonItem (_sortButton, true); }); return 0; }; func.BeginInvoke (null, null); }
public override void ViewDidLoad() { base.ViewDidLoad (); this.NavigationItem.BackBarButtonItem = new UIBarButtonItem ( "Back", UIBarButtonItemStyle.Bordered, null, null); TableView.DataSource = new MeetUpViewDataDource (this); TableView.Delegate = new MeetUpViewDelegate (this); _sortButton = new UIBarButtonItem ("Sort", UIBarButtonItemStyle.Plain, delegate { SortButtonTouched (); }); this.NavigationItem.RightBarButtonItem = _sortButton; SortMethod = PlaceSortMethod.Recent; ChangeSortMethod (PlaceSortMethod.Recent); }