Exemple #1
0
 public bool IsValid()
 {
     if (!this.IsValidPaths(this.paths))
     {
         return(false);
     }
     if (this.content == null)
     {
         return(false);
     }
     for (int i = this.content.Count - 1; i >= 0; i--)
     {
         if (!this.content[i].IsValid())
         {
             this.content.RemoveAt(i);
         }
     }
     if (this.content.Count < 1)
     {
         return(false);
     }
     if (this.categories != null)
     {
         for (int j = this.categories.Count - 1; j >= 0; j--)
         {
             if (string.IsNullOrEmpty(this.categories[j].name))
             {
                 FMLogger.vCore("filter cat.");
                 this.categories.RemoveAt(j);
             }
         }
     }
     if (this.featured != null)
     {
         if (this.featured.daily_items != null)
         {
             for (int k = this.featured.daily_items.Count - 1; k >= 0; k--)
             {
                 if (this.featured.daily_items[k].pic == null || !this.featured.daily_items[k].pic.IsValid())
                 {
                     FMLogger.vCore("filter daily.");
                     this.featured.daily_items.RemoveAt(k);
                 }
             }
         }
         if (this.featured.editor_choice != null)
         {
             for (int l = this.featured.editor_choice.Count - 1; l >= 0; l--)
             {
                 if (this.featured.editor_choice[l].pic == null || !this.featured.editor_choice[l].pic.IsValid())
                 {
                     FMLogger.vCore("filter promo pic.");
                     this.featured.editor_choice.RemoveAt(l);
                 }
             }
         }
         if (this.featured.external_links != null)
         {
             for (int m = this.featured.external_links.Count - 1; m >= 0; m--)
             {
                 bool flag = false;
                 FeaturedExternalLink featuredExternalLink = this.featured.external_links[m];
                 if (string.IsNullOrEmpty(featuredExternalLink.target_url))
                 {
                     flag = true;
                 }
                 if (!this.IsValidPaths(featuredExternalLink.paths))
                 {
                     flag = true;
                 }
                 if (string.IsNullOrEmpty(featuredExternalLink.img_url))
                 {
                     flag = true;
                 }
                 if (flag)
                 {
                     this.featured.external_links.RemoveAt(m);
                 }
             }
         }
     }
     if (this.update_dialog != null && (string.IsNullOrEmpty(this.update_dialog.body) || string.IsNullOrEmpty(this.update_dialog.title) || string.IsNullOrEmpty(this.update_dialog.yes) || string.IsNullOrEmpty(this.update_dialog.no)))
     {
         this.update_dialog = null;
     }
     return(true);
 }
    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();
    }