Ejemplo n.º 1
0
 public void UpdateDRTagsPanel(DailyReflection dr)
 {
     drTagsPanelObject.SetActive(false);
     tag1Object.SetActive(false);
     tag2Object.SetActive(false);
     tag3Object.SetActive(false);
     authorTagObject.SetActive(false);
     if (dr.tags.Count > 0)
     {
         Tag1.text = dr.tags [0];
         tag1Object.SetActive(true);
     }
     if (dr.tags.Count > 1)
     {
         Tag2.text = dr.tags [1];
         tag2Object.SetActive(true);
     }
     if (dr.tags.Count > 2)
     {
         Tag3.text = dr.tags [2];
         tag3Object.SetActive(true);
     }
     if (!string.IsNullOrEmpty(dr.author))
     {
         AuthorTag.text = dr.author;
         authorTagObject.SetActive(true);
     }
     drTagsPanelObject.SetActive(true);
 }
Ejemplo n.º 2
0
    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);
        }
    }
Ejemplo n.º 3
0
 public void InitResultPair(DailyReflection dr1, DailyReflection dr2)
 {
     itemObject.SetActive(false);
     if (dr1 != null)
     {
         Title1.text   = dr1.title;
         Date1.text    = dr1.date;
         Message1.text = dr1.message;
         panel1.SetActive(true);
     }
     else
     {
         panel1.SetActive(false);
     }
     if (dr2 != null)
     {
         Title2.text   = dr2.title;
         Date2.text    = dr2.date;
         Message2.text = dr2.message;
         panel2.SetActive(true);
     }
     else
     {
         panel2.SetActive(false);
     }
     itemObject.SetActive(true);
 }
Ejemplo n.º 4
0
    private DailyReflection GetDROfDisplayDate(string lang, string date)
    {
        DailyReflection dr = null;

        if (drMap != null && drMap.ContainsKey(lang) && drMap [lang].ContainsKey(date))
        {
            dr = drMap [lang] [date];
        }
        return(dr);
    }
Ejemplo n.º 5
0
    public DailyReflection GetDROfDate(string lang, string fetchDate)
    {
        DailyReflection dr = null;

        if (drDisplayDateMap != null && drDisplayDateMap.ContainsKey(lang) && drDisplayDateMap [lang].ContainsKey(fetchDate))
        {
            dr = GetDROfDisplayDate(lang, drDisplayDateMap [lang] [fetchDate]);
        }
        return(dr);
    }
Ejemplo n.º 6
0
 public void UpdateDRPanel(DailyReflection dr)
 {
     currentDR = dr;
     drPanelObject.SetActive(false);
     title.text    = currentDR.title;
     date.text     = currentDR.date;
     message.text  = currentDR.message;
     footnote.text = currentDR.footnote;
     tagsPanel.UpdateDRTagsPanel(dr);
     drPanelObject.SetActive(true);
 }
Ejemplo n.º 7
0
    private static Dictionary <string, DailyReflection> FetchDRMapFromJson(string lang)
    {
        Dictionary <string, DailyReflection> drMap = new Dictionary <string, DailyReflection> ();
        string drCachePath = ExtensionMethods.AppWritableDirectory() + DRJSONRelativePath(lang, drCacheFileName);

        JsonHelper drJson = new JsonHelper();
        Dictionary <string, object> allDRObjects = drJson.ReadAndDeserializeJson(drCachePath, false);

        foreach (string date in new List <string>(allDRObjects.Keys))
        {
            DailyReflection dr = ExtractDR(allDRObjects [date]);
            drMap [date] = dr;
        }

        return(drMap);
    }
Ejemplo n.º 8
0
 public void InitListItem(DailyReflection dr1)
 {
     itemObject.SetActive(false);
     if (dr1 != null)
     {
         Title1.text    = dr1.title;
         Date1.text     = dr1.date;
         Message1.text  = dr1.message;
         Footnote1.text = dr1.footnote;
         panel1.SetActive(true);
     }
     else
     {
         panel1.SetActive(false);
     }
     itemObject.SetActive(true);
 }
Ejemplo n.º 9
0
    public void FetchDROfDate(string lang, string fetchDate, Action <DailyReflection> callback)
    {
        DailyReflection dr = GetDROfDate(lang, fetchDate);

        if (dr != null)
        {
            if (callback != null)
            {
                callback(dr);
            }
        }
        else
        {
            DRFetcher drFetcher = new DRFetcher(this, lang, OnReceivedDROfDate);
            drFetcher.InitContext((object)callback);
            drFetcher.FetchFromServer(fetchDate);
        }
    }
Ejemplo n.º 10
0
 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);
         }
     }
 }
Ejemplo n.º 11
0
 public void InitScrollView(List <DailyReflection> _searchResults)
 {
     scrollRect    = GetComponent <ScrollRect>();
     searchResults = _searchResults;
     for (int i = 0; i < searchResults.Count; i += 2)
     {
         DailyReflection dr1 = searchResults [i];
         DailyReflection dr2 = null;
         if (i + 1 < searchResults.Count)
         {
             dr2 = searchResults [i + 1];
         }
         GameObject resultPairObj = Instantiate(DRSearchResultPrefab) as GameObject;
         DRSearchResultItemController controller = resultPairObj.GetComponent <DRSearchResultItemController> ();
         controller.InitResultPair(dr1, dr2);
         resultPairObj.transform.parent     = ContentPanel.transform;
         resultPairObj.transform.localScale = Vector3.one;
     }
 }