public void UnFlagCurrentLocation(DataEntryBase data) { UserFlagsEntry flags = data as UserFlagsEntry; if (null == flags) { return; } HelperMethods.UserFlags tempFlags = flags.Data; if (flags == null) { return; } else { if (tempFlags == null) { tempFlags = new HelperMethods.UserFlags(); } tempFlags.hasToggledLocation = false; ITTDataCache.Instance.Data.UpdateDataEntry((int)DataCacheIndices.USER_FLAGS, tempFlags, false); } }
public IEnumerator UpdateLocation(Action callback, Action <string> errorCallback, UserFlagsEntry userFlags = null) { if (!Input.location.isEnabledByUser) { errorCallback("Location service is not activated. Please check settings and try again."); yield break; } Input.location.Start(); int maxWait = 20; while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) { yield return(new WaitForSeconds(1)); maxWait--; } if (maxWait < 1) { if (null != errorCallback) { errorCallback("Location service timed out. Please try again."); yield break; } } if (Input.location.status == LocationServiceStatus.Failed) { if (null != errorCallback) { errorCallback("Location service is not activated. Please check settings and try again."); yield break; } } else { if (userFlags == null) { ITTDataCache.Instance.Data.GetDataEntry((int)DataCacheIndices.USER_FLAGS, HelperMethods.Instance.FlagCurrentLocation); } else { HelperMethods.Instance.FlagCurrentLocation(userFlags); } Debug.Log("Retrieved Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.timestamp); LocationDataModel lastLocationData = new LocationDataModel(); lastLocationData.lat = Input.location.lastData.latitude; lastLocationData.lon = Input.location.lastData.longitude; lastLocationData.lastAltitude = Input.location.lastData.altitude; lastLocationData.locationTimeStamp = Input.location.lastData.timestamp; _dataBlob.UpdateDataEntry((int)DataCacheIndices.LOCATION, lastLocationData); Input.location.Stop(); if (null != callback) { callback(); } } }