private void GridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { GridView gridview = sender as GridView; var scroll = Load.FindChildOfType <ScrollViewer>(gridview); var text = Load.FindChildOfType <TextBlock>(gridview); scroll.ViewChanged += async(s, a) => { if ((scroll.VerticalOffset >= scroll.ScrollableHeight - 50 || scroll.ScrollableHeight == 0) && !isLoading) { text.Visibility = Visibility.Visible; int count0 = gridview.Items.Count; int page = gridview.Items.Count / 20 + 1; isLoading = true; List <Content> temps = await ContentServ.GetContentAsync(int.Parse(gridview.Tag.ToString()), page); if (temps.Count == 0) { text.Text = "装填完毕!"; return; } text.Visibility = Visibility.Collapsed; foreach (var item in temps) { gridview.Items.Add(item); } isLoading = false; } }; }
async void load(string mid) { if (mid.Length == 0) { foreach (var item in await ContentServ.GetConAsync(1)) { conlist.Items.Add(item); conlist2.Items.Add(item); } } else { foreach (var item in await ContentServ.GetFriendsCons(mid, 1)) { conlist.Items.Add(item); conlist2.Items.Add(item); } } if (conlist.Items.Count < 20) { var text1 = Load.FindChildOfType <TextBlock>(conlist); text1.Text = "加载完毕!"; } con.Text += conlist.Items.Count == 0 ? "(暂无订阅)" : ""; isConcernLoad = true; }
async Task load(string mid) { if (SettingHelper.DeviceType == DeviceType.PC) { isGrid = true; conlist.ItemTemplate = this.Resources["TemplateGrid"] as DataTemplate; } else { isGrid = false; conlist.ItemTemplate = this.Resources["TemplateList"] as DataTemplate; } isMySelf = mid == UserHelper.Mid ? true : false; var concern = await UserRelated.GetConcernBangumiAsync(mid, 1, (bool)isMySelf); if (concern != null) { var list = concern.Result; foreach (var item in list) { conlist.Items.Add(item); } if (conlist.Items.Count < 20) { var text1 = Load.FindChildOfType <TextBlock>(conlist); text1.Text = "加载完毕!"; } con.Text += conlist.Items.Count == 0 ? "(暂无订阅)" : ""; } }
private async void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e) { PivotItem item = (PivotItem)pivot.SelectedItem; string tag = item.Header.ToString(); if (tag == "评论" && listview.Items.Count == 0) { if (aid.Length > 0) { var text = Load.FindChildOfType <TextBlock>(listview); bool isDone = await load(1, aid); if (isDone && text != null) { text.Text = "评论装填完毕!"; } } else { // load(1,season_id) } } if (tag == "相关视频" && list_relates.Items.Count == 0) { if (aid.Length > 0) { list_relates.ItemsSource = await ContentServ.GetRelatesAsync(aid); } else { // load(1,season_id) } } }
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 { } }
private void list_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var scroll = Load.FindChildOfType <ScrollViewer>(list); scroll.ViewChanged += (s, a) => { panel.Value = scroll.VerticalOffset; }; }
private async Task RefreshReply() { listview.Items.Clear(); var text = Load.FindChildOfType <TextBlock>(listview); bool isDone = await load(1, aid); if (isDone && text != null) { text.Text = "评论装填完毕!"; } page = 1; }
private void list_pull_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var scroll = Load.FindChildOfType <ScrollViewer>(list_pull); scroll.ViewChanged += async(s, a) => { if (scroll.VerticalOffset == scroll.ScrollableHeight && !isloadingpull && !isPullLoadingDone) { // 滑动到底部了 int page = list_pull.Items.Count / 20 + 1; await loadpulls(page); } }; }
private void hslist_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var scroll = Load.FindChildOfType <ScrollViewer>(hslist); var text = Load.FindChildOfType <TextBlock>(hslist); scroll.ViewChanged += async(s, a) => { if (scroll.VerticalOffset == scroll.ScrollableHeight) { // 滑动到底部了 text.Visibility = Visibility.Visible; page++; await load(page); text.Visibility = Visibility.Collapsed; } }; }
private void GridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { GridView gridview = sender as GridView; var scroll = Load.FindChildOfType <ScrollViewer>(gridview); scroll.ViewChanged += async(s, a) => { if ((scroll.VerticalOffset >= scroll.ScrollableHeight - 50 || scroll.ScrollableHeight == 0) && !isLoading) { int count0 = gridview.Items.Count; int page = gridview.Items.Count / 20 + 1; isLoading = true; if (gridview.Tag.ToString() == "0") { var temps = await ContentServ.GetTopicListAsync(page); if (temps.Count == 0) { return; } foreach (var item in temps) { gridview.Items.Add(item); } isLoading = false; } else { var temps = await ContentServ.GetEventListAsync(page); if (temps.Count == 0) { return; } foreach (var item in temps) { gridview.Items.Add(item); } isLoading = false; } } }; }
private void GridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (isLoading) { return; } if (LoadingDone) { return; } GridView view = sender as GridView; var scroll = Load.FindChildOfType <ScrollViewer>(view); var text = Load.FindChildOfType <TextBlock>(view); scroll.ViewChanged += async(s, a) => { if (scroll.VerticalOffset >= scroll.ScrollableHeight - 50 && !isLoading) { text.Visibility = Visibility.Visible; int count0 = view.Items.Count; page++; isLoading = true; var concern = await UserRelated.GetConcernBangumiAsync(mid, page, (bool)isMySelf); if (concern != null) { var list = concern.Result; foreach (var item in list) { view.Items.Add(item); } text.Visibility = Visibility.Collapsed; if (list.Count < 20) { LoadingDone = true; text.Text = "装填完毕!"; return; } } isLoading = false; } }; }
// http://api.bilibili.com/x/v2/history?_device=android&_hwid=ccbb856c97ccb8d2&_ulv=10000&access_key=a48208a7c5b67a4a369124cf5c1b515c&appkey=1d8b6e7d45233436&build=427000&mobi_app=android&platform=android&pn=1&ps=200 async Task load(int p) { try { string url = "http://api.bilibili.com/x/v2/history?_device=wp&_ulv=10000&access_key=" + ApiHelper.accesskey + "&appkey=" + ApiHelper.appkey + "&build=427000&platform=android&pn=" + p.ToString() + "&ps=20"; url += ApiHelper.GetSign(url); List <Models.History> hs = await ContentServ.GetHistoryAsync(url); foreach (var item in hs) { hslist.Items.Add(item); } if (hs.Count < 20) { var text = Load.FindChildOfType <TextBlock>(hslist); text.Text = "没有更多历史项"; hslist.ContainerContentChanging -= hslist_ContainerContentChanging; } } catch { } }
private void list_friends_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var scroll = Load.FindChildOfType <ScrollViewer>(list_friends); scroll.ViewChanged += async(s, a) => { if (scroll.VerticalOffset == scroll.ScrollableHeight) { page_friend++; var result = await ContentServ.GetFriendsAsync(UserHelper.Mid, page_friend); if (list_friends.Items.Count < result.Result) { for (int i = 0; i < result.List.Count; i++) { list_friends.Items.Add(result.List[i]); } } } }; }
private void GridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { Type type = sender.GetType(); ListViewBase view; if (type.Name == "GridView") { view = sender as GridView; } else { view = sender as ListView; } var scroll = Load.FindChildOfType <ScrollViewer>(view); var text = Load.FindChildOfType <TextBlock>(view); scroll.ViewChanged += async(s, a) => { if (scroll.VerticalOffset >= scroll.ScrollableHeight - 50 && !isLoading) { text.Visibility = Visibility.Visible; int count0 = view.Items.Count; int page = view.Items.Count / 20 + 1; isLoading = true; List <Concern> temps = await ContentServ.GetConAsync(page); text.Visibility = Visibility.Collapsed; foreach (var item in temps) { view.Items.Add(item); } if (temps.Count < 30) { text.Text = "装填完毕!"; return; } isLoading = false; } }; }
private async void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e) { ReadyList.SelectionMode = ListViewSelectionMode.Single; btn_addfav.Visibility = btn_like.Visibility = btn_down.Visibility = btn_share.Visibility = Visibility.Visible; btn_all.Visibility = btn_ok.Visibility = btn_cal.Visibility = Visibility.Collapsed; PivotItem item = (PivotItem)pivot.SelectedItem; string tag = item.Header.ToString(); if (tag == "评论" && listview.Items.Count == 0) { if (aid.Length > 0) { var text = Load.FindChildOfType <TextBlock>(listview); bool isDone = await load(1, aid); if (isDone && text != null) { text.Text = "评论装填完毕!"; } } else { //load(1,season_id) } } if (tag == "相关视频" && list_relates.Items.Count == 0) { if (aid.Length > 0) { list_relates.ItemsSource = await ContentServ.GetRelatesAsync(aid); } else { //load(1,season_id) } } }
private void hslist_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var scroll = Load.FindChildOfType <ScrollViewer>(hslist); var text = Load.FindChildOfType <TextBlock>(hslist); scroll.ViewChanged += async(s, a) => { if (scroll.VerticalOffset == scroll.ScrollableHeight && isDone == false) { int count0 = hslist.Items.Count; //滑动到底部了 text.Visibility = Visibility.Visible; page++; await load(page); if (hslist.Items.Count == count0) { text.Text = "没有更多历史项!"; return; } text.Visibility = Visibility.Collapsed; } }; }
private void Listview_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var scroll = Load.FindChildOfType <ScrollViewer>(listview); var text = Load.FindChildOfType <TextBlock>(listview); scroll.ViewChanged += async(s, a) => { if (scroll.VerticalOffset == scroll.ScrollableHeight && !isLoading) { text.Visibility = Visibility.Visible; page++; isLoading = true; bool isDone = await load(page, aid); if (isDone && text != null) { text.Text = "评论装填完毕!"; return; } text.Visibility = Visibility.Collapsed; isLoading = false; } }; }
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; } } } }; }