History and watch later pages
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using FoxTube.Controls;
|
||||
using Microsoft.AppCenter.Analytics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
@@ -11,8 +14,12 @@ namespace FoxTube.Pages
|
||||
/// </summary>
|
||||
public sealed partial class History : Page
|
||||
{
|
||||
List<string> entries;
|
||||
int page = 1;
|
||||
public string id = "HL";
|
||||
LoadingPage loading;
|
||||
VideoGrid list;
|
||||
ShowMore more;
|
||||
|
||||
public History()
|
||||
{
|
||||
@@ -24,25 +31,65 @@ namespace FoxTube.Pages
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
loading = grid.Children[2] as LoadingPage;
|
||||
list = scroll.Content as VideoGrid;
|
||||
list = stack.Children[0] as VideoGrid;
|
||||
more = stack.Children[1] as ShowMore;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(e.Parameter.ToString()))
|
||||
id = e.Parameter.ToString();
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
public async void Initialize()
|
||||
{
|
||||
loading.Refresh();
|
||||
try
|
||||
{
|
||||
loading.Refresh();
|
||||
|
||||
loading.Close();
|
||||
entries = id == "HL" ? await Methods.GetHistory() : await Methods.GetLater();
|
||||
|
||||
for (int k = 0; k < 50 && k < entries.Count; k++)
|
||||
list.Add(new VideoCard(entries[k]));
|
||||
|
||||
if (list.Count >= entries.Count)
|
||||
more.Complete(true);
|
||||
|
||||
loading.Close();
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException)
|
||||
{
|
||||
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
loading.Error(e.GetType().ToString(), e.Message);
|
||||
Analytics.TrackEvent("History loading error", new Dictionary<string, string>()
|
||||
{
|
||||
{ "Exception", e.GetType().ToString() },
|
||||
{ "Message", e.Message },
|
||||
{ "ID", id }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void toBrowser_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new Uri("youtube.com/feed/history"));
|
||||
await Launcher.LaunchUriAsync(new Uri(id == "HL" ? "https://www.youtube.com/feed/history" : "https://www.youtube.com/playlist?list=WL"));
|
||||
}
|
||||
|
||||
private void Refresh_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
list.Clear();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void ShowMore_Clicked()
|
||||
{
|
||||
for (int k = 50 * page++; k < 50 * page; k++)
|
||||
list.Add(new VideoCard(entries[k]));
|
||||
|
||||
if (list.Count >= entries.Count)
|
||||
more.Complete(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user