Пример #1
0
        async Task LoadItem(GridView list, SearchType type)
        {
            try
            {
                if (list.Items.Count == 0 && !isLoading)
                {
                    ArrayList items = new ArrayList();
                    switch (type)
                    {
                    case SearchType.Videos:
                        var t1 = await ContentServ.GetSearchResultAsync(keyword, 1);

                        foreach (var item in t1)
                        {
                            items.Add(item);
                        }
                        break;

                    case SearchType.Animes:
                        var t2 = await ContentServ.GetBangumisAsync(keyword, 1);

                        foreach (var item in t2)
                        {
                            items.Add(item);
                        }
                        break;

                    case SearchType.Ups:
                        var t3 = await ContentServ.GetUpsAsync(keyword, 1);

                        foreach (var item in t3)
                        {
                            items.Add(item);
                        }
                        break;
                    }
                    if (items == null)
                    {
                        return;
                    }
                    else if (list != null && items.Count > 0)
                    {
                        foreach (var item in items)
                        {
                            list.Items.Add(item);
                        }
                    }
                    if (items.Count < 20)
                    {
                        var text = Load.FindChildOfType <TextBlock>(list);
                        text.Text = "装填完毕!";
                    }
                }
                return;
            }
            catch { }
        }
Пример #2
0
        private void list_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            GridView listview = sender as GridView;
            var      scroll   = Load.FindChildOfType <ScrollViewer>(listview);
            var      text     = Load.FindChildOfType <TextBlock>(listview);

            scroll.ViewChanged += async(s, a) =>
            {
                if ((scroll.VerticalOffset >= scroll.ScrollableHeight - 50 || scroll.ScrollableHeight == 0) && !isLoading)
                {
                    text.Visibility = Visibility.Visible;
                    int count0 = listview.Items.Count;
                    int page   = listview.Items.Count / 20 + 1;
                    isLoading = true;
                    switch (listview.Tag.ToString())
                    {
                    case "videos":
                    {
                        var temps = await ContentServ.GetSearchResultAsync(keyword, page);

                        if (temps.Count < 20)
                        {
                            text.Text = "装填完毕!";
                            return;
                        }
                        text.Visibility = Visibility.Collapsed;
                        foreach (var item in temps)
                        {
                            listview.Items.Add(item);
                        }
                        isLoading = false;
                    }
                    break;

                    case "bangumi":
                    {
                        var temps = await ContentServ.GetBangumisAsync(keyword, page);

                        if (temps.Count < 20)
                        {
                            text.Text = "装填完毕!";
                            return;
                        }
                        text.Visibility = Visibility.Collapsed;
                        foreach (var item in temps)
                        {
                            listview.Items.Add(item);
                        }
                        isLoading = false;
                        break;
                    }

                    case "up":
                    {
                        List <UpForSearch> uplist = await ContentServ.GetUpsAsync(keyword, page);

                        if (uplist.Count < 20)
                        {
                            text.Text = "装填完毕!";
                            return;
                        }
                        text.Visibility = Visibility.Collapsed;
                        foreach (var item in uplist)
                        {
                            listview.Items.Add(item);
                        }
                        isLoading = false;
                        break;
                    }
                    }
                }
            };
        }