コード例 #1
0
    private void OnDailyPageLoaded(bool success, string text)
    {
        DailyPageResponse dailyPageResponse = null;

        if (success && !string.IsNullOrEmpty(text))
        {
            try
            {
                dailyPageResponse = JsonUtility.FromJson <DailyPageResponse>(text);
                FMLogger.vCore("daily resp: " + text);
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogError("daily ex: " + ex.Message);
                UnityEngine.Debug.LogError("daily failed to parse page responce");
                UnityEngine.Debug.LogError(text);
                dailyPageResponse = null;
            }
            if (dailyPageResponse == null || !dailyPageResponse.IsValid())
            {
                UnityEngine.Debug.LogError("daily resp not valid: " + text);
                dailyPageResponse = null;
            }
        }
        else
        {
            FMLogger.vCore("daily req fail. 404 or resp empty");
        }
        this.dailyResponce = dailyPageResponse;
        if (this.dailyPageCallback != null)
        {
            this.dailyPageCallback(this.dailyResponce);
        }
        this.dailyPageCallback = null;
    }
コード例 #2
0
    private void ParseDailyPageContent(DailyPageResponse response)
    {
        List <PictureData> localPictures = DatabaseManager.GetLocalPictures();

        this.dailyTabInfo         = new DailyTabInfo();
        this.dailyTabInfo.monthes = new List <DailyMonthInfo>();
        if (response.months != null)
        {
            for (int i = 0; i < response.months.Count; i++)
            {
                DailyMonthInfo dailyMonthInfo = new DailyMonthInfo();
                dailyMonthInfo.monthName  = ((!string.IsNullOrEmpty(response.months[i].monthName)) ? response.months[i].monthName : string.Empty);
                dailyMonthInfo.monthIndex = response.months[i].monthIndex;
                dailyMonthInfo.year       = response.months[i].year;
                dailyMonthInfo.pics       = new List <PictureData>();
                for (int j = 0; j < response.months[i].pics.Count; j++)
                {
                    WebPicData  webPic      = response.months[i].pics[j];
                    PictureData pictureData = this.ParseWebPic(webPic, response.paths, localPictures, false);
                    if (pictureData != null)
                    {
                        pictureData.SetDailyTabDate(response.months[i].pics.Count - j);
                        pictureData.SetPicClass(PicClass.Daily);
                        dailyMonthInfo.pics.Add(pictureData);
                    }
                }
                this.dailyTabInfo.monthes.Add(dailyMonthInfo);
            }
        }
        if (response.daily != null)
        {
            this.dailyTabInfo.dailyPic          = new DailyPicInfo();
            this.dailyTabInfo.dailyPic.day      = ((!string.IsNullOrEmpty(response.daily.day)) ? response.daily.day : string.Empty);
            this.dailyTabInfo.dailyPic.desc     = ((!string.IsNullOrEmpty(response.daily.description)) ? response.daily.description : string.Empty);
            this.dailyTabInfo.dailyPic.month    = ((!string.IsNullOrEmpty(response.daily.month)) ? response.daily.month : string.Empty);
            this.dailyTabInfo.dailyPic.btnLabel = (response.daily.cta ?? string.Empty);
            PictureData pictureData2 = this.ParseWebPic(response.daily.pic, response.paths, localPictures, false);
            if (pictureData2 != null)
            {
                pictureData2.SetPicClass(PicClass.Daily);
                this.dailyTabInfo.dailyPic.picData = pictureData2;
            }
            else
            {
                this.dailyTabInfo.dailyPic = null;
            }
        }
    }
コード例 #3
0
    private DailyPageResponse FakeResp()
    {
        DailyPageResponse dailyPageResponse = new DailyPageResponse();

        dailyPageResponse.months = new List <DailyMonthResp>();
        dailyPageResponse.months.Add(new DailyMonthResp
        {
            monthIndex = 6,
            year       = 2018
        });
        dailyPageResponse.months.Add(new DailyMonthResp
        {
            monthIndex = 2,
            year       = 2017
        });
        dailyPageResponse.months.Add(new DailyMonthResp
        {
            monthIndex = 4,
            year       = 2018
        });
        dailyPageResponse.months.Add(new DailyMonthResp
        {
            monthIndex = 4,
            year       = 2018
        });
        dailyPageResponse.months.Add(new DailyMonthResp
        {
            monthIndex = 4,
            year       = 2017
        });
        dailyPageResponse.months.Add(new DailyMonthResp
        {
            monthIndex = 12,
            year       = 2018
        });
        dailyPageResponse.months.Add(new DailyMonthResp
        {
            monthIndex = 8,
            year       = 2018
        });
        dailyPageResponse.months.Add(new DailyMonthResp
        {
            monthIndex = 7,
            year       = 2018
        });
        dailyPageResponse.Sort();
        return(dailyPageResponse);
    }