void GetAdditionalGroups( ) { if (RetrievingGroups == false) { RetrievingGroups = true; BlockerView.Show(delegate { GroupFinder.GetGroups(GroupTypeId, StreetValue, CityValue, StateValue, ZipValue, CurrGroupIndex, NumRequestedGroups, delegate(MobileAppApi.GroupSearchResult sourceLocation, List <MobileAppApi.GroupSearchResult> groupEntries, bool result) { BlockerView.Hide(delegate { RetrievingGroups = false; // for additional groups, only take action if we got something back. if (result) { // increment our index to the next set, or the end of the list, whichever is less // this will ensure when we hit the end of the list, CurrGroupIndex reflects that. CurrGroupIndex += Math.Min(groupEntries.Count, NumRequestedGroups); GroupEntries.AddRange(groupEntries); UpdateMap(true); } }); }); }); } }
void GetInitialGroups(int groupTypeId, string streetValue, string cityValue, string stateValue, string zipValue) { if (RetrievingGroups == false) { // since this is the first search for the new address, get initial values // so that if they leave the page and return, we can re-populate them. StreetValue = SearchPage.Street.Text; CityValue = SearchPage.City.Text; StateValue = SearchPage.State.Text; ZipValue = SearchPage.ZipCode.Text; RetrievingGroups = true; BlockerView.Show(delegate { GroupTypeId = groupTypeId; CurrGroupIndex = 0; GroupFinder.GetGroups(groupTypeId, streetValue, cityValue, stateValue, zipValue, CurrGroupIndex, NumRequestedGroups, delegate(MobileAppApi.GroupSearchResult sourceLocation, List <MobileAppApi.GroupSearchResult> groupEntries, bool result) { BlockerView.Hide(delegate { RetrievingGroups = false; SourceLocation = sourceLocation; GroupEntries = groupEntries; UpdateMap(result); // if the result was valid string address = StreetValue + " " + CityValue + ", " + StateValue + ", " + ZipValue; if (result) { // take the lesser of the two. The number we requested, or the amount returned, because // it's possible there weren't as many as we requested. CurrGroupIndex = Math.Min(NumRequestedGroups, groupEntries.Count); // record an analytic that they searched GroupFinderAnalytic.Instance.Trigger(GroupFinderAnalytic.Location, address); //GroupFinderAnalytic.Instance.Trigger( GroupFinderAnalytic.Neighborhood, GroupEntries[ 0 ].NeighborhoodArea ); } else { // record an analytic that this address failed GroupFinderAnalytic.Instance.Trigger(GroupFinderAnalytic.OutOfBounds, address); } }); }); }); } }
void GetAdditionalGroups( ) { if (Searching == false) { Searching = true; BlockerView.Show(delegate { GroupFinder.GetGroups(GroupTypeId, StreetValue, CityValue, StateValue, ZipValue, CurrGroupIndex, NumRequestedGroups, delegate(MobileAppApi.GroupSearchResult sourceLocation, List <MobileAppApi.GroupSearchResult> groupEntries, bool result) { BlockerView.Hide(delegate { Searching = false; if (result) { // increment our index to the next set, or the end of the list, whichever is less // this will ensure when we hit the end of the list, CurrGroupIndex reflects that. CurrGroupIndex += Math.Min(groupEntries.Count, NumRequestedGroups); // add in the new results GroupEntries.AddRange(groupEntries); // update the map UpdateMap(result); // and reload the table GroupFinderTableView.ReloadData( ); // since we're only loading additional groups, don't flag the // list as updated. We don't want it to reset to the top. GroupListUpdated = false; } }); }); }); } }
void GetInitialGroups(int groupTypeId, string street, string city, string state, string zip) { if (Searching == false) { // since this is the first search for the new address, get initial values // so that if they leave the page and return, we can re-populate them. StreetValue = SearchPage.Street.Text; CityValue = SearchPage.City.Text; StateValue = SearchPage.State.Text; ZipValue = SearchPage.ZipCode.Text; Searching = true; BlockerView.Show(delegate { // set the group index we'll begin with CurrGroupIndex = 0; GroupTypeId = groupTypeId; // request groups from CurrGroupIndex thru CurrGroupIndex + NumRequestedGroups GroupFinder.GetGroups(groupTypeId, StreetValue, CityValue, StateValue, ZipValue, CurrGroupIndex, NumRequestedGroups, delegate(MobileAppApi.GroupSearchResult sourceLocation, List <MobileAppApi.GroupSearchResult> groupEntries, bool result) { BlockerView.Hide(delegate { Searching = false; // store the source location SourceLocation = sourceLocation; // take the initial group entries GroupEntries = groupEntries; // update the map UpdateMap(result); // reload the table. GroupFinderTableView.ReloadData( ); // flag that our group list was updated so that // on the region updated callback from the map, we // can select the appropriate group GroupListUpdated = true; // and record an analytic for the neighborhood that this location was apart of. This helps us know // which neighborhoods get the most hits. string address = StreetValue + " " + CityValue + ", " + StateValue + ", " + ZipValue; // send an analytic if the request went thru ok if (result) { if (groupEntries.Count > 0) { // increment our index to the next set, or the final amount available, whichever is less. // this will ensure when we hit the end of the list, CurrGroupIndex reflects that. CurrGroupIndex = CurrGroupIndex + Math.Min(groupEntries.Count, NumRequestedGroups); // record an analytic that they searched GroupFinderAnalytic.Instance.Trigger(GroupFinderAnalytic.Location, address); //GroupFinderAnalytic.Instance.Trigger( GroupFinderAnalytic.Neighborhood, groupEntries[ 0 ].NeighborhoodArea ); } else { // record that this address failed GroupFinderAnalytic.Instance.Trigger(GroupFinderAnalytic.OutOfBounds, address); } } }); }); }); } }