Beispiel #1
0
    /// <summary>
    /// Create Carousel from the information in the res parameters
    /// </summary>
    /// <param name="res"> The results from the google query </param>
    public void CreateCarousel(ResultsGooglePlace res, bool isLocal)
    {
        foreach (LocationData location in res.results)
        {
            // :: enough item in the carousel
            if (_numberItem == locationList.Count)
            {
                break;
            }

            if (location.photos.Count > 0)
            {
                CreateLocationInCarousel(location);
            }
        }


        if (res.next_page_token != null && _numberItem > locationList.Count)
        {
            GetNextPageGoogleNearbySearch.Invoke(res.next_page_token);
        }
        else if (isLocal)
        {
            LoadAllLocationLocal();
        }
        else
        {
            StartCoroutine(LoadAllRemoteLocation());
        }
    }
Beispiel #2
0
    ResultsGooglePlace GetLastGoogleResult()
    {
        ResultsGooglePlace placesResults = null;

        if (File.Exists(Application.persistentDataPath + SAVE_PATH_JSON))
        {
            string jsonSave = File.ReadAllText(Application.persistentDataPath + SAVE_PATH_JSON);
            placesResults = JsonUtility.FromJson <ResultsGooglePlace>(jsonSave);

            foreach (LocationData location in placesResults.results)
            {
                if (location.savedPhoto != null)
                {
                    location.savedPhoto.texture = GetTexture2DFromPath(location.place_id);
                }
            }
        }

        return(placesResults);
    }
Beispiel #3
0
    public void ReadGoogleResults(string response)
    {
        bool isLocal           = false;
        ResultsGooglePlace res = JsonUtility.FromJson <ResultsGooglePlace>(response);//

        if (res == null)
        {
            res = GetLastGoogleResult(); isLocal = true;
        }

        // no correct response - no internet connection - no saved result
        if (res == null || res.status == "ZERO_RESULTS")
        {
            DisplayErrorNoResults.Invoke();
        }
        else
        {
            currentPlaceResult = res;
            CreateCarousel.Invoke(res, isLocal);
        }
    }