public void OnDRFetched(DRFetchContext ctxt) { DRFetchContext retContext = ctxt; if (context != null) { foreach (string date in ctxt.drMap.Keys) { if (!context.drMap.ContainsKey(date)) { context.drMap [date] = ctxt.drMap [date]; } } foreach (string date in ctxt.drDisplayDateMap.Keys) { if (!context.drDisplayDateMap.ContainsKey(date)) { context.drDisplayDateMap [date] = ctxt.drDisplayDateMap [date]; } } retContext = context; } if (callback != null) { callback(retContext); } }
public static IEnumerator FetchDRFromServer(string fetchDate, string lang, Action <DRFetchContext> callback) { WWW download = StartDownload(fetchDate, lang); yield return(download); DRFetchContext context = new DRFetchContext(lang); if (!string.IsNullOrEmpty(download.error)) { Debug.Log("Error downloading DR for fetch date: " + fetchDate + " with error: " + download.error); } else { DailyReflection dr = ExtractDR(lang, fetchDate, download.text); if (dr != null) { context.drMap [dr.date] = dr; context.drDisplayDateMap [fetchDate] = dr.date; dr.DebugLogDR(); } } if (callback != null) { callback(context); } }
public DRFetcher(DRCache _cacheHandle, string _lang, Action <DRFetchContext> _callback) { cacheHandle = _cacheHandle; language = _lang; callback = _callback; context = null; }
public static IEnumerator FetchDRsFromJson(string lang, Action <DRFetchContext> callback) { CopyDRJSONFiles(lang); yield return(null); DRFetchContext context = new DRFetchContext(lang); context.ctxt = null; context.drMap = FetchDRMapFromJson(lang); context.drDisplayDateMap = FetchDRDisplayDateMap(lang); if (callback != null) { callback(context); } }
public void OnReceivedDROfDate(DRFetchContext ctxt) { OnReceivedDRs(ctxt); if (ctxt.ctxt != null) { Action <DailyReflection> callback = (Action <DailyReflection>)ctxt.ctxt; DailyReflection dr = null; if (ctxt.drMap.Keys.Count > 0) { string date = (new List <string> (ctxt.drMap.Keys)) [0]; dr = ctxt.drMap [date]; } if (callback != null) { callback(dr); } } }
public void OnReceivedDRs(DRFetchContext ctxt) { if (!drMap.ContainsKey(ctxt.lang)) { drMap [ctxt.lang] = ctxt.drMap; } else { AddEntriesToDRMap(ctxt.lang, ctxt.drMap); } if (!drDisplayDateMap.ContainsKey(ctxt.lang)) { drDisplayDateMap [ctxt.lang] = ctxt.drDisplayDateMap; } else { AddEntriesToDRDisplayDateMap(ctxt.lang, ctxt.drDisplayDateMap); } }
public void OnDRsFetchedFromJSON(DRFetchContext ctxt) { context = ctxt; CacheRecentDRs(); }
public void InitContext(System.Object ctxt) { context = new DRFetchContext(language); context.ctxt = ctxt; }