public void LoadContent(FeaturedInfo featuredInfo) { this.loopScroll.Init((!SafeLayout.IsTablet) ? this.phoneConfig : this.tabletConfig); this.visabilityEventTracker.SetDelegate((int index) => this.items[index]); for (int i = 0; i < featuredInfo.orderedList.Count; i++) { OrderedItemType itemType = featuredInfo.orderedList[i].itemType; if (itemType != OrderedItemType.PromoPic) { if (itemType != OrderedItemType.Daily) { if (itemType == OrderedItemType.ExternalLink) { ExternalLinkInfo externalLinkInfo = (ExternalLinkInfo)featuredInfo.orderedList[i]; this.AddExternalLinkItem(externalLinkInfo); } } else { DailyPicInfo dailyPicInfo = (DailyPicInfo)featuredInfo.orderedList[i]; this.AddDailyItem(dailyPicInfo); } } else { PromoPicInfo promoPicInfo = (PromoPicInfo)featuredInfo.orderedList[i]; this.AddEditorItem(promoPicInfo); } } this.loopScroll.PrepareLayout(); }
public void LoadContent(FeaturedInfo featuredInfo) { this.Init(); for (int i = 0; i < featuredInfo.orderedList.Count; i++) { OrderedItemType itemType = featuredInfo.orderedList[i].itemType; if (itemType != OrderedItemType.PromoPic) { if (itemType != OrderedItemType.Daily) { if (itemType == OrderedItemType.ExternalLink) { ExternalLinkInfo externalLinkInfo = (ExternalLinkInfo)featuredInfo.orderedList[i]; this.AddExternalLinkItem(externalLinkInfo); } } else { DailyPicInfo dailyPicInfo = (DailyPicInfo)featuredInfo.orderedList[i]; this.AddDailyItem(dailyPicInfo); } } else { PromoPicInfo promoPicInfo = (PromoPicInfo)featuredInfo.orderedList[i]; this.AddEditorItem(promoPicInfo); } } this.loopScroll.PrepareLayout(); }
public void Init(DailyPicInfo picInfo) { base.Id = picInfo.id; this.Order = picInfo.order; base.Type = FeaturedItem.ItemType.Daily; if (GeneralSettings.IsOldDesign) { this.dayLabel.text = picInfo.day; this.monthLabel.text = picInfo.month; } else { this.dayLabel.text = picInfo.day + "\n" + picInfo.month; this.btnLabel.text = picInfo.btnLabel; } this.descLabel.text = picInfo.desc; this.picItem.Init(picInfo.picData, false, false, false); if (picInfo.picData.HasSave) { PictureSaveData save = SharedData.Instance.GetSave(picInfo.picData); if (save != null) { this.picItem.AddSave(save); } } }
private void AddDailyItem(DailyPicInfo dailyPicInfo) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.dailyPrefab); DailyPicItem component = gameObject.GetComponent <DailyPicItem>(); component.Init(dailyPicInfo); this.items.Add(component); this.AddItemToScroll(component); }
private void ParseMainPageContent(LibraryPageResponce responce) { List <PictureData> localPictures = DatabaseManager.GetLocalPictures(); List <PictureData> list = new List <PictureData>(); for (int i = 0; i < responce.content.Count; i++) { WebPicData webPic = responce.content[i]; PictureData pictureData = this.ParseWebPic(webPic, responce.paths, localPictures, false); if (pictureData != null) { list.Add(pictureData); } } this.orderedMainPage = list; this.featuredSection = new FeaturedInfo(); if (responce.featured != null) { this.featuredSection.dailies = new List <DailyPicInfo>(); this.featuredSection.promoPics = new List <PromoPicInfo>(); this.featuredSection.externalLinks = new List <ExternalLinkInfo>(); if (responce.featured.daily_items != null) { for (int j = 0; j < responce.featured.daily_items.Count; j++) { FeaturedDailyResp tmp = responce.featured.daily_items[j]; DailyPicInfo dailyPicInfo = new DailyPicInfo(); dailyPicInfo.order = tmp.order; dailyPicInfo.id = tmp.id; dailyPicInfo.desc = (tmp.description ?? string.Empty); dailyPicInfo.day = (tmp.day ?? string.Empty); dailyPicInfo.month = (tmp.month ?? string.Empty); dailyPicInfo.btnLabel = (tmp.cta ?? string.Empty); PictureData pictureData2 = this.orderedMainPage.Find((PictureData p) => p.Id == tmp.pic.id); if (pictureData2 != null) { dailyPicInfo.picData = pictureData2; } else { dailyPicInfo.picData = this.ParseWebPic(tmp.pic, responce.paths, localPictures, false); } dailyPicInfo.picData.SetPicClass(PicClass.Daily); this.featuredSection.dailies.Add(dailyPicInfo); } } if (responce.featured.editor_choice != null) { for (int k = 0; k < responce.featured.editor_choice.Count; k++) { FeaturedEditorChoiceResp tmp = responce.featured.editor_choice[k]; PromoPicInfo promoPicInfo = new PromoPicInfo(); promoPicInfo.order = tmp.order; promoPicInfo.id = tmp.id; promoPicInfo.desc = (tmp.description ?? string.Empty); promoPicInfo.title = (tmp.title ?? string.Empty); promoPicInfo.btnLabel = (tmp.cta ?? string.Empty); PictureData pictureData3 = this.orderedMainPage.Find((PictureData p) => p.Id == tmp.pic.id); if (pictureData3 != null) { promoPicInfo.picData = pictureData3; } else { promoPicInfo.picData = this.ParseWebPic(tmp.pic, responce.paths, localPictures, false); } this.featuredSection.promoPics.Add(promoPicInfo); } } if (responce.featured.external_links != null) { for (int l = 0; l < responce.featured.external_links.Count; l++) { FeaturedExternalLink featuredExternalLink = responce.featured.external_links[l]; ExternalLinkInfo externalLinkInfo = new ExternalLinkInfo(); externalLinkInfo.id = featuredExternalLink.id; externalLinkInfo.order = featuredExternalLink.order; externalLinkInfo.desc = (featuredExternalLink.description ?? string.Empty); externalLinkInfo.title = (featuredExternalLink.title ?? string.Empty); externalLinkInfo.btnLabel = (featuredExternalLink.cta ?? string.Empty); externalLinkInfo.targetUrl = featuredExternalLink.target_url; externalLinkInfo.targetScheme = (featuredExternalLink.target_scheme ?? string.Empty); externalLinkInfo.imageData = new ImageData(featuredExternalLink.paths, featuredExternalLink.img_url); this.featuredSection.externalLinks.Add(externalLinkInfo); } } } this.featuredSection.OrderItems(); this.newsTabInfo = new NewsInfo(); if (responce.news != null) { this.newsTabInfo.promoPics = new List <PromoPicInfo>(); this.newsTabInfo.externalLinks = new List <ExternalLinkInfo>(); if (responce.news.editor_choice != null) { for (int m = 0; m < responce.news.editor_choice.Count; m++) { FeaturedEditorChoiceResp tmp = responce.news.editor_choice[m]; PromoPicInfo promoPicInfo2 = new PromoPicInfo(); promoPicInfo2.id = tmp.id; promoPicInfo2.order = tmp.order; promoPicInfo2.desc = (tmp.description ?? string.Empty); promoPicInfo2.title = (tmp.title ?? string.Empty); promoPicInfo2.btnLabel = (tmp.cta ?? string.Empty); PictureData pictureData4 = this.orderedMainPage.Find((PictureData p) => p.Id == tmp.pic.id); if (pictureData4 != null) { promoPicInfo2.picData = pictureData4; } else { promoPicInfo2.picData = this.ParseWebPic(tmp.pic, responce.paths, localPictures, false); } this.newsTabInfo.promoPics.Add(promoPicInfo2); } } if (responce.news.external_links != null) { for (int n = 0; n < responce.news.external_links.Count; n++) { FeaturedExternalLink featuredExternalLink2 = responce.news.external_links[n]; ExternalLinkInfo externalLinkInfo2 = new ExternalLinkInfo(); externalLinkInfo2.id = featuredExternalLink2.id; externalLinkInfo2.order = featuredExternalLink2.order; externalLinkInfo2.desc = (featuredExternalLink2.description ?? string.Empty); externalLinkInfo2.title = (featuredExternalLink2.title ?? string.Empty); externalLinkInfo2.btnLabel = (featuredExternalLink2.cta ?? string.Empty); externalLinkInfo2.targetUrl = featuredExternalLink2.target_url; externalLinkInfo2.targetScheme = (featuredExternalLink2.target_scheme ?? string.Empty); externalLinkInfo2.imageData = new ImageData(featuredExternalLink2.paths, featuredExternalLink2.img_url); this.newsTabInfo.externalLinks.Add(externalLinkInfo2); } } } this.newsTabInfo.OrderItems(); }