コード例 #1
0
        private void DataTemplateBasic(View view, int i, AnimeVideoData animeVideoData)
        {
            var str = new SpannableString($"{animeVideoData.Name} - {animeVideoData.AnimeTitle}");

            str.SetSpan(PrefixStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive);
            str.SetSpan(PrefixColorStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive);
            view.FindViewById <TextView>(Resource.Id.PromoVideosPageItemSubtitle)
            .SetText(str.SubSequenceFormatted(0, str.Length()), TextView.BufferType.Spannable);
        }
コード例 #2
0
        private void SetItemBindingsFull(View view, int i, AnimeVideoData animeVideoData)
        {
            var img = view.FindViewById <ImageViewAsync>(Resource.Id.PromoVideosPageItemImage);

            if (img.Tag == null || (string)img.Tag != animeVideoData.Thumb)
            {
                img.Into(animeVideoData.Thumb);
            }
            view.FindViewById(Resource.Id.PromoVideosPageItemImgPlaceholder).Visibility = ViewStates.Gone;
        }
コード例 #3
0
        private void SetItemBindingsFling(View view, AnimeVideoData animeVideoData)
        {
            view.FindViewById(Resource.Id.PromoVideosPageItemImgPlaceholder).Visibility = ViewStates.Visible;
            view.FindViewById(Resource.Id.PromoVideosPageItemImage).Visibility          = ViewStates.Invisible;

            var str = new SpannableString($"{animeVideoData.Name} - {animeVideoData.AnimeTitle}");

            str.SetSpan(PrefixStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive);
            str.SetSpan(PrefixColorStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive);
            view.FindViewById <TextView>(Resource.Id.PromoVideosPageItemSubtitle)
            .SetText(str.SubSequenceFormatted(0, str.Length()), TextView.BufferType.Spannable);
        }
コード例 #4
0
        public async Task <List <AnimeVideoData> > GetVideos()
        {
            var output = new List <AnimeVideoData>();
            var raw    = await GetRequestResponse(false);

            if (string.IsNullOrEmpty(raw))
            {
                return(output);
            }

            var doc = new HtmlDocument();

            doc.LoadHtml(raw);

            try
            {
                foreach (var videoNode in doc.WhereOfDescendantsWithClass("div", "video-list-outer-vertical"))
                {
                    var current = new AnimeVideoData();

                    var link = videoNode.ChildNodes.First(node => node.Name == "a");
                    current.Thumb = link.Attributes["data-bg"].Value;
                    if (current.Thumb.Contains("banned"))
                    {
                        continue;
                    }
                    current.AnimeId = int.Parse(link.Attributes["data-anime-id"].Value);

                    var href = link.Attributes["href"].Value;
                    var pos  = href.IndexOf('?');
                    href           = href.Substring(0, pos);
                    current.YtLink = $"https://www.youtube.com/watch?v={href.Split('/').Last()}";

                    current.Name =
                        WebUtility.HtmlDecode(
                            videoNode.FirstOfDescendantsWithClass("div", "info-container").InnerText.Trim());

                    current.AnimeTitle = WebUtility.HtmlDecode(videoNode.Descendants("a").Last().InnerText.Trim());

                    output.Add(current);
                }
            }
            catch (Exception)
            {
                //
            }

            return(output);
        }
コード例 #5
0
        private void SetItemBindingsFling(View view, int i, AnimeVideoData animeVideoData)
        {
            var img = view.FindViewById <ImageViewAsync>(Resource.Id.PromoVideosPageItemImage);

            if (img.IntoIfLoaded(animeVideoData.Thumb))
            {
                img.Visibility = ViewStates.Visible;
                view.FindViewById(Resource.Id.PromoVideosPageItemImgPlaceholder).Visibility = ViewStates.Visible;
            }
            else
            {
                img.Visibility = ViewStates.Invisible;
                view.FindViewById(Resource.Id.PromoVideosPageItemImgPlaceholder).Visibility = ViewStates.Gone;
            }
        }
コード例 #6
0
        private void SetItemBindingsFull(View view, AnimeVideoData animeVideoData)
        {
            var img = view.FindViewById <ImageViewAsync>(Resource.Id.PromoVideosPageItemImage);

            if ((string)img.Tag != animeVideoData.YtLink)
            {
                view.FindViewById(Resource.Id.PromoVideosPageItemImgPlaceholder).Visibility = ViewStates.Gone;
                img.Tag = animeVideoData.YtLink;
                img.Into(animeVideoData.Thumb);
            }

            var str = new SpannableString($"{animeVideoData.Name} - {animeVideoData.AnimeTitle}");

            str.SetSpan(PrefixStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive);
            str.SetSpan(PrefixColorStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive);
            view.FindViewById <TextView>(Resource.Id.PromoVideosPageItemSubtitle)
            .SetText(str.SubSequenceFormatted(0, str.Length()), TextView.BufferType.Spannable);
        }
コード例 #7
0
        public async Task <List <AnimeVideoData> > GetVideos(bool force)
        {
            var output = force
                ? new List <AnimeVideoData>()
                : await DataCache.RetrieveData <List <AnimeVideoData> >($"videos_{_id}", "AnimeDetails", 7) ??
                         new List <AnimeVideoData>();

            if (output.Any())
            {
                return(output);
            }

            var raw = await GetRequestResponse();

            if (string.IsNullOrEmpty(raw))
            {
                return(output);
            }

            var doc = new HtmlDocument();

            doc.LoadHtml(raw);

            try
            {
                foreach (
                    var video in
                    doc.FirstOfDescendantsWithClass("div", "video-block promotional-video mt16")
                    .WhereOfDescendantsWithClass("div", "video-list-outer po-r pv"))
                {
                    try
                    {
                        var current = new AnimeVideoData();
                        var img     = video.Descendants("img").First();
                        current.Thumb = img.Attributes["data-src"].Value;
                        if (current.Thumb.Contains("banned"))
                        {
                            continue;
                        }
                        var href = video.Descendants("a").First().Attributes["href"].Value;
                        var pos  = href.IndexOf('?');
                        href           = href.Substring(0, pos);
                        current.YtLink = $"https://www.youtube.com/watch?v={href.Split('/').Last()}";

                        current.Name = WebUtility.HtmlDecode(img.Attributes["data-title"].Value);

                        output.Add(current);
                    }
                    catch (Exception)
                    {
                        //html
                    }
                }
            }
            catch (Exception)
            {
                //no videos
            }

            DataCache.SaveData(output, $"videos_{_id}", "AnimeDetails");

            return(output);
        }