simplified coroutine calls
This commit is contained in:
@@ -54,7 +54,7 @@ namespace RothenburgAR.UI
|
|||||||
if (!data.HasModelDescription) return;
|
if (!data.HasModelDescription) return;
|
||||||
|
|
||||||
this.currentPoiData = data;
|
this.currentPoiData = data;
|
||||||
StartCoroutine("SetModelCoroutine", data);
|
StartCoroutine(SetModelCoroutine(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator SetModelCoroutine(PoiData data)
|
public IEnumerator SetModelCoroutine(PoiData data)
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ namespace RothenburgAR.Updater
|
|||||||
};
|
};
|
||||||
|
|
||||||
result = result.Substring(0, result.Length - 1) + "}";
|
result = result.Substring(0, result.Length - 1) + "}";
|
||||||
|
return "{}";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,12 +180,7 @@ namespace RothenburgAR.Updater
|
|||||||
|
|
||||||
private void UpdateMeta(ApiExhibitionVersion exhibition)
|
private void UpdateMeta(ApiExhibitionVersion exhibition)
|
||||||
{
|
{
|
||||||
var versionData = new UpdateVersionFileCoroutineData
|
var currentHandlers = new List<HttpHandler>();
|
||||||
{
|
|
||||||
path = PathHelper.CombinePaths(PathHelper.ExhibitionPath, exhibition.Id, "version.txt"),
|
|
||||||
httpHandlers = new List<HttpHandler>(),
|
|
||||||
version = exhibition.Meta.UpdateVersion.ToString()
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var lang in VersionAnswer.Languages)
|
foreach (var lang in VersionAnswer.Languages)
|
||||||
{
|
{
|
||||||
@@ -192,7 +188,7 @@ namespace RothenburgAR.Updater
|
|||||||
var url = exhibition.Meta.UpdateUrl.Replace("{lang}", lang);
|
var url = exhibition.Meta.UpdateUrl.Replace("{lang}", lang);
|
||||||
var http = new HttpRequest(url, HttpVerb.GET).Send();
|
var http = new HttpRequest(url, HttpVerb.GET).Send();
|
||||||
httpHandlers.Add(http);
|
httpHandlers.Add(http);
|
||||||
versionData.httpHandlers.Add(http);
|
currentHandlers.Add(http);
|
||||||
|
|
||||||
http.Operation.completed += ar =>
|
http.Operation.completed += ar =>
|
||||||
{
|
{
|
||||||
@@ -217,23 +213,18 @@ namespace RothenburgAR.Updater
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
StartCoroutine("UpdateVersionFileCoroutine", versionData);
|
var versionPath = PathHelper.CombinePaths(PathHelper.ExhibitionPath, exhibition.Id, "version.txt");
|
||||||
|
var version = exhibition.Meta.UpdateVersion.ToString();
|
||||||
|
StartCoroutine(UpdateVersionFileCoroutine(currentHandlers, versionPath, version));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator UpdateVersionFileCoroutine(UpdateVersionFileCoroutineData versionData)
|
private IEnumerator UpdateVersionFileCoroutine(List<HttpHandler> currentHandlers, string versionPath, string version)
|
||||||
{
|
{
|
||||||
// updates version file only if all sub files were downloaded successfully
|
// updates version file only if all sub files were downloaded successfully
|
||||||
yield return new WaitUntil(() => versionData.httpHandlers.All(h => h.IsDone));
|
yield return new WaitUntil(() => httpHandlers.All(h => h.IsDone));
|
||||||
if (versionData.httpHandlers.Any(http => http.Request.isNetworkError || http.Request.isHttpError)) yield break;
|
if (httpHandlers.Any(http => http.Request.isNetworkError || http.Request.isHttpError)) yield break;
|
||||||
|
|
||||||
File.WriteAllText(versionData.path, versionData.version);
|
File.WriteAllText(versionPath, version);
|
||||||
}
|
|
||||||
|
|
||||||
private class UpdateVersionFileCoroutineData
|
|
||||||
{
|
|
||||||
public List<HttpHandler> httpHandlers;
|
|
||||||
public string path;
|
|
||||||
public string version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateMedia(ApiExhibit exhibit)
|
private void UpdateMedia(ApiExhibit exhibit)
|
||||||
|
|||||||
Reference in New Issue
Block a user