상속: IDetailsPageArgs
        private View RelatedItemTemplateDelegate(int i, RelatedAnimeData relatedAnimeData, View convertView)
        {
            var view = convertView ??
                       MainActivity.CurrentContext.LayoutInflater.Inflate(Resource.Layout.AnimeRelatedItem, null);


            view.Tag = relatedAnimeData.Wrap();
            view.FindViewById<TextView>(Resource.Id.AnimeRelatedItemContent).Text = relatedAnimeData.WholeRelation;

            return view;
        }
예제 #2
0
        public async Task<List<RelatedAnimeData>> GetRelatedAnime(bool force = false)
        {
            var output = force
                ? new List<RelatedAnimeData>()
                : await DataCache.RetrieveRelatedAnimeData(_animeId, _animeMode) ?? new List<RelatedAnimeData>();
            if (output.Count != 0) return output;

            var raw = await GetRequestResponse(false);
            if (string.IsNullOrEmpty(raw))
                return null;

            var doc = new HtmlDocument();
            doc.LoadHtml(raw);
            try
            {
                var relationsNode = doc.DocumentNode.Descendants("table")
                    .First(
                        node =>
                            node.Attributes.Contains("class") &&
                            node.Attributes["class"].Value ==
                            HtmlClassMgr.ClassDefs["#Related:relationsNode:class"]);

                foreach (var row in relationsNode.Descendants("tr"))
                {
                    try
                    {
                        var current = new RelatedAnimeData();
                        current.WholeRelation = WebUtility.HtmlDecode(row.Descendants("td").First().InnerText.Trim()) +
                                                " ";
                        var linkNode = row.Descendants("a").First();
                        var link = linkNode.Attributes["href"].Value.Split('/');
                        current.Type = link[1] == "anime"
                            ? RelatedItemType.Anime
                            : link[1] == "manga" ? RelatedItemType.Manga : RelatedItemType.Unknown;
                        current.Id = Convert.ToInt32(link[2]);
                        current.Title = WebUtility.HtmlDecode(linkNode.InnerText.Trim());
                        current.WholeRelation += current.Title;
                        output.Add(current);
                    }
                    catch (Exception)
                    {
                        //mystery
                    }
                }
            }
            catch (Exception)
            {
                //no recom
            }
            DataCache.SaveRelatedAnimeData(_animeId, output, _animeMode);

            return output;
        }