Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
考虑其它各集合为空的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiichiamane committed May 21, 2019
1 parent 7b5d270 commit 0392da9
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 66 deletions.
5 changes: 3 additions & 2 deletions PixivFSUWP/Controls/WaterfallListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ private async Task LoadPage()
while (scrollViewer.ScrollableHeight == 0)
try
{
await (ItemsSource as ISupportIncrementalLoading)?.LoadMoreItemsAsync(0);
var res = await (ItemsSource as ISupportIncrementalLoading)?.LoadMoreItemsAsync(0);
if (res.Count == 0) return;
}
catch(InvalidOperationException)
catch (InvalidOperationException)
{
return;
}
Expand Down
31 changes: 19 additions & 12 deletions PixivFSUWP/Data/BookmarkIllustsCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,25 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
if (!HasMoreItems) return new LoadMoreItemsResult() { Count = 0 };
LoadMoreItemsResult toret = new LoadMoreItemsResult() { Count = 0 };
JsonObject bookmarkres = null;
if (nexturl == "begin")
bookmarkres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.UserBookmarksIllust(userID);
else
try
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
bookmarkres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.UserBookmarksIllust(userID, getparam("restrict"),
getparam("filter"), getparam("max_bookmark_id"));
if (nexturl == "begin")
bookmarkres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.UserBookmarksIllust(userID);
else
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
bookmarkres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.UserBookmarksIllust(userID, getparam("restrict"),
getparam("filter"), getparam("max_bookmark_id"));
}
}
catch
{
return toret;
}
nexturl = bookmarkres["next_url"].TryGetString();
foreach (var recillust in bookmarkres["illusts"].GetArray())
Expand All @@ -93,7 +100,7 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
{
nexturl = "";
Clear();
throw new Exception();
return new LoadMoreItemsResult() { Count = 0 };
}
Data.WaterfallItem recommendi = Data.WaterfallItem.FromJsonValue(recillust.GetObject());
var recommendmodel = ViewModels.WaterfallItemViewModel.FromItem(recommendi);
Expand Down
29 changes: 18 additions & 11 deletions PixivFSUWP/Data/CommentsCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,24 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
if (!HasMoreItems) return new LoadMoreItemsResult() { Count = 0 };
LoadMoreItemsResult toret = new LoadMoreItemsResult() { Count = 0 };
JsonObject commentres = null;
if (nexturl == "begin")
commentres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustComments(illustid, IncludeTotalComments: true);
else
try
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
commentres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustComments(illustid, getparam("offset"), bool.Parse(getparam("include_total_comments")));
if (nexturl == "begin")
commentres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustComments(illustid, IncludeTotalComments: true);
else
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
commentres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustComments(illustid, getparam("offset"), bool.Parse(getparam("include_total_comments")));
}
}
catch
{
return toret;
}
nexturl = commentres["next_url"].TryGetString();
foreach (var recillust in commentres["comments"].GetArray())
Expand All @@ -87,7 +94,7 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
{
nexturl = "";
Clear();
throw new Exception();
return new LoadMoreItemsResult() { Count = 0 };
}
Data.IllustCommentItem recommendi = Data.IllustCommentItem.FromJsonValue(recillust.GetObject());
var recommendmodel = ViewModels.CommentViewModel.FromItem(recommendi);
Expand Down
29 changes: 18 additions & 11 deletions PixivFSUWP/Data/FollowingIllustsCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,24 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
if (!HasMoreItems) return new LoadMoreItemsResult() { Count = 0 };
LoadMoreItemsResult toret = new LoadMoreItemsResult() { Count = 0 };
JsonObject followingres = null;
if (nexturl == "begin")
followingres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustFollow();
else
try
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
followingres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustFollow(getparam("restrict"), getparam("offset"));
if (nexturl == "begin")
followingres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustFollow();
else
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
followingres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustFollow(getparam("restrict"), getparam("offset"));
}
}
catch
{
return toret;
}
nexturl = followingres["next_url"].TryGetString();
foreach (var recillust in followingres["illusts"].GetArray())
Expand All @@ -84,7 +91,7 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
{
nexturl = "";
Clear();
throw new Exception();
return new LoadMoreItemsResult() { Count = 0 };
}
Data.WaterfallItem recommendi = Data.WaterfallItem.FromJsonValue(recillust.GetObject());
var recommendmodel = ViewModels.WaterfallItemViewModel.FromItem(recommendi);
Expand Down
29 changes: 18 additions & 11 deletions PixivFSUWP/Data/RankingIllustsCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,24 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
if (!HasMoreItems) return new LoadMoreItemsResult() { Count = 0 };
LoadMoreItemsResult toret = new LoadMoreItemsResult() { Count = 0 };
JsonObject rankingres = null;
if (nexturl == "begin")
rankingres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustRanking();
else
try
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
rankingres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustRanking(Mode: getparam("mode"), Filter: getparam("filter"), Offset: getparam("offset"));
if (nexturl == "begin")
rankingres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustRanking();
else
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
rankingres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustRanking(Mode: getparam("mode"), Filter: getparam("filter"), Offset: getparam("offset"));
}
}
catch
{
return toret;
}
nexturl = rankingres["next_url"].TryGetString();
foreach (var recillust in rankingres["illusts"].GetArray())
Expand All @@ -84,7 +91,7 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
{
nexturl = "";
Clear();
throw new Exception();
return new LoadMoreItemsResult() { Count = 0 };
}
Data.WaterfallItem recommendi = Data.WaterfallItem.FromJsonValue(recillust.GetObject());
var recommendmodel = ViewModels.WaterfallItemViewModel.FromItem(recommendi);
Expand Down
45 changes: 26 additions & 19 deletions PixivFSUWP/Data/RecommendIllustsCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,32 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
if (!HasMoreItems) return new LoadMoreItemsResult() { Count = 0 };
LoadMoreItemsResult toret = new LoadMoreItemsResult() { Count = 0 };
JsonObject recommendres = null;
if (nexturl == "begin")
recommendres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustRecommended();
else
try
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
recommendres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustRecommended(ContentType:
getparam("content_type"),
IncludeRankingLabel: bool.Parse(getparam("include_ranking_label")),
Filter: getparam("filter"),
MinBookmarkIDForRecentIllust: getparam("min_bookmark_id_for_recent_illust"),
MaxBookmarkIDForRecommended: getparam("max_bookmark_id_for_recommend"),
Offset: getparam("offset"),
IncludeRankingIllusts: bool.Parse(getparam("include_ranking_illusts")),
IncludePrivacyPolicy: getparam("include_privacy_policy"));
if (nexturl == "begin")
recommendres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustRecommended();
else
{
Uri next = new Uri(nexturl);
string getparam(string param) => HttpUtility.ParseQueryString(next.Query).Get(param);
recommendres = await new PixivCS
.PixivAppAPI(OverAll.GlobalBaseAPI)
.IllustRecommended(ContentType:
getparam("content_type"),
IncludeRankingLabel: bool.Parse(getparam("include_ranking_label")),
Filter: getparam("filter"),
MinBookmarkIDForRecentIllust: getparam("min_bookmark_id_for_recent_illust"),
MaxBookmarkIDForRecommended: getparam("max_bookmark_id_for_recommend"),
Offset: getparam("offset"),
IncludeRankingIllusts: bool.Parse(getparam("include_ranking_illusts")),
IncludePrivacyPolicy: getparam("include_privacy_policy"));
}
}
catch
{
return toret;
}
nexturl = recommendres["next_url"].TryGetString();
foreach (var recillust in recommendres["illusts"].GetArray())
Expand All @@ -93,7 +100,7 @@ protected async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c
{
nexturl = "";
Clear();
throw new Exception();
return new LoadMoreItemsResult() { Count = 0 };
}
Data.WaterfallItem recommendi = Data.WaterfallItem.FromJsonValue(recillust.GetObject());
var recommendmodel = ViewModels.WaterfallItemViewModel.FromItem(recommendi);
Expand Down

0 comments on commit 0392da9

Please sign in to comment.