private static IEnumerator _LoadDataFromFile() { string path = Application.streamingAssetsPath + "/MyJson.json"; string jsonstring = File.ReadAllText(path); data = JsonUtility.FromJson <PlacesCollection>(jsonstring); yield return(null); }
public IEnumerator ApplyFilter(System.Func <Place, bool> filter) { // Waiting data load complete yield return(PlacementDataSource.WaitingDataReady()); // Load data to list this.currentData = PlacementDataSource.GetPlacesCollectionWithFilter(filter); Scroll.ApplyDataTo(currentData.Places.Length, 0, InfiniteScroll.Direction.Bottom); }
IEnumerator _LoadFromDataSource() { // Waiting data load complete yield return(PlacementDataSource.WaitingDataReady()); // Load data to list this.currentData = PlacementDataSource.GetPlacesCollection(); Scroll.InitData(currentData.Places.Length); }
public async Task ShouldBeAbleToLoadMorePlaces() { string token = await _client.App.GetAccessTokenAsync(); FacebookPlacesApi placesApi = _client.GetPlacesApi(token); PlacesCollection places = await placesApi.PlacesSearchAsync("-73.9921", "40.7304"); bool loadMoreResult = await places.Load(); places.Should().NotBeNull(); loadMoreResult.Should().Be(true, "The load more operation should be successful"); places.Count.Should().Be(100, "It loaded more results"); }
public async Task ShouldBeAbleToGetPlaces() { string token = await _client.App.GetAccessTokenAsync(); FacebookPlacesApi placesApi = _client.GetPlacesApi(token); PlacesCollection places = await placesApi.PlacesSearchAsync("-73.9921", "40.7304"); places.Should().NotBeNull(); places.Count.Should().Be(50, "Default limitation is 50 and we're querying a popular place so we should get such result."); //PlacesCollection placesBefore = places.After(); //placesApi.PlacesSearch("-73.9921", "40.7304", 1000, null, null, null, 0); }
/// <summary> /// Search for places /// </summary> /// <param name="lon">Longitude</param> /// <param name="lat">Latitude</param> /// <param name="distance">Distance in meters from the center</param> /// <param name="categories">Places that match one or more categories (consult Facebook API for available options)</param> /// <param name="fields">Place information fields you want returned (consult Facebook API for available options)</param> /// <param name="name">Name of place</param> /// <param name="limit">Limit the number of returned results</param> /// <returns></returns> public async Task <PlacesCollection> PlacesSearchAsync(string lon, string lat, int distance, string categories, string fields, string name, int limit) { //https://graph.facebook.com/v3.2/search?type=place¢er=40.7304,-73.9921&distance=1000&q=cafe&fields=name,checkins,picture&limit=3&access_token={access-token}' string center = string.Empty; if (!string.IsNullOrWhiteSpace(lon) && !string.IsNullOrWhiteSpace(lat)) { center = "¢er=" + lat + "," + lon; } string distanceStr = string.Empty; if (distance > 0) { distanceStr = "&distance=" + distance.ToString(); } string query = string.Empty; if (!string.IsNullOrWhiteSpace(name)) { query = "&q=" + name; } if (string.IsNullOrWhiteSpace(fields)) { fields = "name,checkins,picture"; } fields = "&fields=" + fields; string limitStr = string.Empty; if (limit > 0) { limitStr = "&limit=" + limit.ToString(); } //var response = FacebookClient.Get($"/search?type=place{center}{distance}{query}{fields}{limit}", _authToken); string apiQuery = $"/search?type=place{center}{distance}{query}{fields}{limitStr}"; PlacesCollection collection = new PlacesCollection(_fbClient, apiQuery, _authToken, null); await collection.Load(); return(collection); }
public async Task ShouldBeAbleToGetPlacesAfterAndBefore() { string token = await _client.App.GetAccessTokenAsync(); FacebookPlacesApi placesApi = _client.GetPlacesApi(token); PlacesCollection places = await placesApi.PlacesSearchAsync("-73.9921", "40.7304"); PlacesCollection after = await places.AfterAsync(); PlacesCollection before = await after.BeforeAsync(); places.Should().NotBeNull(); after.Should().NotBeNull(); before.Should().NotBeNull(); places.Count.Should().Be(50); after.Count.Should().Be(50); before.Count.Should().Be(50); before[10].Id.Should().Be(places[10].Id, "Before is taken from after and therefor should match the original `places` requester"); }
public static PlacesCollection GetPlacesCollectionWithFilter(System.Func <Place, bool> filter = null) { if (filter == null) { return(GetPlacesCollection()); } Debug.Assert(data != null, "Data have not been loaded. Please check WaitingDataReady first"); PlacesCollection cloneData = new PlacesCollection(); List <Place> filteredData = new List <Place>(); foreach (Place item in data.Places) { if (filter(item)) { filteredData.Add(item); } } cloneData.Places = filteredData.ToArray(); return(cloneData); }