Exemplo n.º 1
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"]);


                try
                {
                    var tds = relationsNode.Descendants("tr").First().Descendants("td").ToList();
                    for(int i = 0; i < tds.Count; i+=2)
                    {
                        var relation = WebUtility.HtmlDecode(tds[i].InnerText.Trim());
                        foreach (var linkNode in tds[i+1].Descendants("a"))
                        {
                            var current = new RelatedAnimeData();
                            current.WholeRelation = relation;
                            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());
                            output.Add(current);
                        }
                    }
                       

                }
                catch (Exception)
                {
                    //mystery
                }
                
            }
            catch (Exception)
            {
                //no recom
            }
            DataCache.SaveRelatedAnimeData(_animeId, output, _animeMode);

            return output;
        }
Exemplo n.º 2
0
        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 + relatedAnimeData.Title;

            return(view);
        }
Exemplo n.º 3
0
        private void DataTemplateFull(View view1, int i, RelatedAnimeData arg3)
        {
            var    img    = view1.FindViewById <ImageViewAsync>(Resource.Id.Image);
            string imgUrl = null;

            if (AnimeImageQuery.IsCached(arg3.Id, arg3.Type == RelatedItemType.Anime, ref imgUrl))
            {
                img.Into(imgUrl);
            }
            else
            {
                img.IntoWithTask(AnimeImageQuery.GetImageUrl(arg3.Id, arg3.Type == RelatedItemType.Anime));
            }
        }
Exemplo n.º 4
0
        private void DataTemplateFling(View view1, int i, RelatedAnimeData arg3)
        {
            var    img  = view1.FindViewById <ImageViewAsync>(Resource.Id.Image);
            string link = null;

            if (AnimeImageQuery.IsCached(arg3.Id, arg3.Type == RelatedItemType.Anime, ref link))
            {
                if (!img.IntoIfLoaded(link))
                {
                    img.Visibility = ViewStates.Invisible;
                }
            }
            else
            {
                img.Visibility = ViewStates.Invisible;
            }
        }
Exemplo n.º 5
0
 private void DataTemplateBasic(View view, int i, RelatedAnimeData relatedAnimeData)
 {
     view.FindViewById <TextView>(Resource.Id.AnimeRelatedItemContent).Text = relatedAnimeData.WholeRelation + relatedAnimeData.Title;
 }