Skip to content

Commit

Permalink
Merge branch 'feature/#184_search_mylist' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tor4kichi committed Aug 8, 2016
2 parents dc1bd51 + aad6642 commit 3cb6200
Show file tree
Hide file tree
Showing 33 changed files with 1,111 additions and 558 deletions.
14 changes: 7 additions & 7 deletions NicoPlayerHohoema/Models/FavFeedManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,15 @@ private async Task<List<FavFeedItem>> GetUserFeedItems(FavFeedList userFavFeedLi

private async Task<List<FavFeedItem>> GetTagFeedItems(FavFeedList tagFavFeedList)
{
var tagVideos = await _HohoemaApp.ContentFinder.GetTagSearch(tagFavFeedList.Id, 1, SortMethod.FirstRetrieve);
var tagVideos = await _HohoemaApp.ContentFinder.GetTagSearch(tagFavFeedList.Id, 0, 50);

return tagVideos.list.Select(x =>
return tagVideos.VideoInfoItems.Select(x =>
{
return new FavFeedItem()
{
VideoId = x.id,
Title = x.title,
SubmitDate = x.FirstRetrieve,
VideoId = x.Video.Id,
Title = x.Video.Title,
SubmitDate = x.Video.FirstRetrieve,
ParentList = tagFavFeedList,
};
})
Expand All @@ -464,8 +464,8 @@ private async Task<List<FavFeedItem>> GetMylistFeedItems(FavFeedList mylistFavFe
{
VideoId = x.Video.Id,
Title = x.Video.Title,
SubmitDate = DateTime.Parse(x.Video.First_retrieve),
IsDeleted = int.Parse(x.Video.Deleted) == 0 ? false : true,
SubmitDate = x.Video.FirstRetrieve,
IsDeleted = x.Video.IsDeleted,
ParentList = mylistFavFeedList,
};
})
Expand Down
26 changes: 14 additions & 12 deletions NicoPlayerHohoema/Models/NiconicoContentFinder.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Mntone.Nico2;
using Mntone.Nico2.Mylist;
using Mntone.Nico2.Mylist.MylistGroup;
using Mntone.Nico2.Searches.Video;
using Mntone.Nico2.Users.Fav;
using Mntone.Nico2.Users.User;
using Mntone.Nico2.Users.Video;
using Mntone.Nico2.Videos.Histories;
using Mntone.Nico2.Videos.Ranking;
using Mntone.Nico2.Videos.Search;
using NicoPlayerHohoema.Util;
using Prism.Mvvm;
using System;
Expand All @@ -29,9 +29,11 @@ public NiconicoContentFinder(HohoemaApp app)
}


public async Task Initialize()
public Task Initialize()
{
// お気に入りデータの読み込み

return Task.CompletedTask;
}


Expand Down Expand Up @@ -61,22 +63,22 @@ public async Task<NiconicoRankingRss> GetCategoryRanking(RankingCategory categor
}


public async Task<SearchResponse> GetKeywordSearch(string keyword, uint pageCount, SortMethod sortMethod, SortDirection sortDir = SortDirection.Descending)
public async Task<VideoSearchResponse> GetKeywordSearch(string keyword, uint from, uint limit, Sort sort = Sort.FirstRetrieve, Order order = Order.Descending)
{
return await ConnectionRetryUtil.TaskWithRetry(async () =>
{
return await _HohoemaApp.NiconicoContext.Video.GetKeywordSearchAsync(keyword, pageCount, sortMethod, sortDir);
return await _HohoemaApp.NiconicoContext.Search.KeywordSearchAsync(keyword, from, limit, sort, order);
});
}

public async Task<SearchResponse> GetTagSearch(string keyword, uint pageCount, SortMethod sortMethod, SortDirection sortDir = SortDirection.Descending)
public async Task<VideoSearchResponse> GetTagSearch(string tag, uint from, uint limit, Sort sort = Sort.FirstRetrieve, Order order = Order.Descending)
{
return await ConnectionRetryUtil.TaskWithRetry(async () =>
{
return await _HohoemaApp.NiconicoContext.Video.GetKeywordSearchAsync(keyword, pageCount, sortMethod, sortDir)
return await _HohoemaApp.NiconicoContext.Search.TagSearchAsync(tag, from, limit, sort, order)
.ContinueWith(prevTask =>
{
if (!prevTask.Result.IsStatusOK)
if (!prevTask.Result.IsOK)
{
throw new WebException();
}
Expand Down Expand Up @@ -131,7 +133,7 @@ public Task<List<MylistGroupData>> GetUserMylistGroups(string userId)
private List<MylistGroupData> _CachedUserMylistGroupDatum = null;


public async Task<MylistGroupDetail> GetMylist(string mylistGroupid)
public async Task<MylistGroupResponse> GetMylist(string mylistGroupid)
{
return await ConnectionRetryUtil.TaskWithRetry(async () =>
{
Expand Down Expand Up @@ -177,14 +179,14 @@ public async Task<List<FavData>> GetFavMylists()



public async Task<UserVideoResponse> GetUserVideos(uint userId, uint page, SortMethod sortMethod = SortMethod.FirstRetrieve, SortDirection sortDir = SortDirection.Descending)
public async Task<UserVideoResponse> GetUserVideos(uint userId, uint page, Sort sort = Sort.FirstRetrieve, Order order = Order.Descending)
{
return await _HohoemaApp.NiconicoContext.User.GetUserVideos(userId, page, sortMethod, sortDir);
return await _HohoemaApp.NiconicoContext.User.GetUserVideos(userId, page, sort, order);
}

public async Task<NicoVideoResponse> GetRelatedVideos(string videoId, uint from, uint limit, SortMethod sortMethod = SortMethod.FirstRetrieve, SortDirection sortDir = SortDirection.Descending)
public async Task<NicoVideoResponse> GetRelatedVideos(string videoId, uint from, uint limit, Sort sort = Sort.FirstRetrieve, Order order = Order.Descending)
{
return await _HohoemaApp.NiconicoContext.Video.GetRelatedVideoAsync(videoId, from, limit, sortMethod, sortDir);
return await _HohoemaApp.NiconicoContext.Video.GetRelatedVideoAsync(videoId, from, limit, sort, order);
}


Expand Down
8 changes: 4 additions & 4 deletions NicoPlayerHohoema/Models/SearchOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class SearchOption : IEquatable<SearchOption>
{
public string Keyword { get; set; }
public SearchTarget SearchTarget { get; set; }
public Mntone.Nico2.SortMethod SortMethod { get; set; }
public Mntone.Nico2.SortDirection SortDirection { get; set; }
public Mntone.Nico2.Order Order { get; set; }
public Mntone.Nico2.Sort Sort { get; set; }


public string ToParameterString()
Expand Down Expand Up @@ -42,8 +42,8 @@ public bool Equals(SearchOption other)

return this.Keyword == other.Keyword
&& this.SearchTarget == other.SearchTarget
&& this.SortDirection == other.SortDirection
&& this.SortMethod == other.SortMethod;
&& this.Order == other.Order
&& this.Sort == other.Sort;
}
}
}
19 changes: 18 additions & 1 deletion NicoPlayerHohoema/NicoPlayerHohoema.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@
<Compile Include="ViewModels\FavoriteManagePageViewModel.cs" />
<Compile Include="ViewModels\FavoriteVideoInfoControlViewModel.cs" />
<Compile Include="ViewModels\HistoryPageViewModel.cs" />
<Compile Include="ViewModels\HohoemaListingPageItemBase.cs" />
<Compile Include="ViewModels\HohoemaListingPageViewModelBase.cs" />
<Compile Include="ViewModels\HohoemaVideoListingPageViewModelBase.cs" />
<Compile Include="ViewModels\HohoemaViewModelBase.cs" />
<Compile Include="ViewModels\LoginPageViewModel.cs" />
Expand All @@ -182,7 +184,8 @@
<Compile Include="ViewModels\PortalContent\HistoryPortalPageContentViewModel.cs" />
<Compile Include="ViewModels\SearchContent\EmptySearchPageContentViewModel.cs" />
<Compile Include="ViewModels\SearchContent\KeywordSearchPageContentViewModel.cs" />
<Compile Include="ViewModels\SearchContent\searchSortOptionListItem.cs" />
<Compile Include="ViewModels\SearchContent\MylistSearchPageContentViewModel.cs" />
<Compile Include="ViewModels\SearchContent\SearchSortOptionListItem.cs" />
<Compile Include="ViewModels\SearchContent\TagSearchPageContentViewModel.cs" />
<Compile Include="ViewModels\SettingsContent\CacheSettingsPageContentViewModel.cs" />
<Compile Include="ViewModels\SettingsContent\CommentSettingsPageContentViewModel.cs" />
Expand Down Expand Up @@ -232,6 +235,9 @@
<Compile Include="Views\Controls\HohoemaIncrementalLoadingList.xaml.cs">
<DependentUpon>HohoemaIncrementalLoadingList.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\MylistSearchListItem.xaml.cs">
<DependentUpon>MylistSearchListItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\RankingCategoryListItem.xaml.cs">
<DependentUpon>RankingCategoryListItem.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -262,6 +268,9 @@
<Compile Include="Views\SearchContent\KeywordSearchPageContent.xaml.cs">
<DependentUpon>KeywordSearchPageContent.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SearchContent\MylistSearchPageContent.xaml.cs">
<DependentUpon>MylistSearchPageContent.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SearchContent\TagSearchPageContent.xaml.cs">
<DependentUpon>TagSearchPageContent.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -506,6 +515,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Controls\MylistSearchListItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Controls\RankingCategoryListItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -554,6 +567,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SearchContent\MylistSearchPageContent.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SearchContent\TagSearchPageContent.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
22 changes: 11 additions & 11 deletions NicoPlayerHohoema/Util/SortMethodHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@

namespace NicoPlayerHohoema.Util
{
public static class SortMethodHelper
public static class SortHelper
{
public static string ToCulturizedText(SortMethod method, SortDirection dir)
public static string ToCulturizedText(Sort sort, Order order)
{
var isAscending = dir == SortDirection.Ascending;
switch (method)
var isAscending = order == Order.Ascending;
switch (sort)
{
case SortMethod.NewComment:
case Sort.NewComment:
return isAscending ? "コメントが古い順" : "コメントが新しい順";
case SortMethod.ViewCount:
case Sort.ViewCount:
return isAscending ? "再生数が少ない順" : "再生数が多い順";
case SortMethod.MylistCount:
case Sort.MylistCount:
return isAscending ? "マイリスト数が少ない順" : "マイリスト数が多い順";
case SortMethod.CommentCount:
case Sort.CommentCount:
return isAscending ? "コメント数が少ない順" : "コメント数が多い順";
case SortMethod.FirstRetrieve:
case Sort.FirstRetrieve:
return isAscending ? "投稿日時が古い順" : "投稿日時が新しい順";
case SortMethod.Length:
case Sort.Length:
return isAscending ? "動画時間が短い順" : "動画時間が長い順";
case SortMethod.Popurarity:
case Sort.Popurarity:
return "人気が高い順";
default:
throw new NotSupportedException();
Expand Down
6 changes: 3 additions & 3 deletions NicoPlayerHohoema/ViewModels/FavoriteAllFeedPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public FavoriteAllFeedPageViewModel(HohoemaApp hohoemaApp, PageManager pageManag
});


SelectedItemsMarkAsReadCommand = SelectedVideoInfoItems.ToCollectionChanged()
.Select(x => SelectedVideoInfoItems.Count > 0)
SelectedItemsMarkAsReadCommand = SelectedItems.ToCollectionChanged()
.Select(x => SelectedItems.Count > 0)
.ToReactiveCommand()
.AddTo(_CompositeDisposable);

SelectedItemsMarkAsReadCommand.Subscribe(async _ =>
{
foreach (var item in SelectedVideoInfoItems)
foreach (var item in SelectedItems)
{
await HohoemaApp.FavFeedManager.MarkAsRead(item.VideoId);
await HohoemaApp.FavFeedManager.MarkAsRead(item.RawVideoId);
Expand Down
4 changes: 2 additions & 2 deletions NicoPlayerHohoema/ViewModels/FavoriteManagePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public DelegateCommand SelectedCommand
{
Keyword = this.SourceId,
SearchTarget = SearchTarget.Tag,
SortMethod = Mntone.Nico2.SortMethod.FirstRetrieve,
SortDirection = Mntone.Nico2.SortDirection.Descending,
Sort = Mntone.Nico2.Sort.FirstRetrieve,
Order = Mntone.Nico2.Order.Descending,
}.ToParameterString();
_PageManager.OpenPage(HohoemaPageType.Search, param);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public DelegateCommand OpenFeedSourceCommand
{
Keyword = feedList.Id,
SearchTarget = SearchTarget.Tag,
SortDirection = Mntone.Nico2.SortDirection.Descending,
SortMethod = Mntone.Nico2.SortMethod.FirstRetrieve
Sort = Mntone.Nico2.Sort.FirstRetrieve,
Order = Mntone.Nico2.Order.Descending,
}.ToParameterString());
break;
case FavoriteItemType.Mylist:
Expand Down
6 changes: 3 additions & 3 deletions NicoPlayerHohoema/ViewModels/HistoryPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ public class HistoryPageViewModel : HohoemaVideoListingPageViewModelBase<History
public HistoryPageViewModel(HohoemaApp hohoemaApp, PageManager pageManager, Views.Service.MylistRegistrationDialogService mylistDialogService)
: base(hohoemaApp, pageManager, mylistDialogService)
{
RemoveHistoryCommand = SelectedVideoInfoItems.ObserveProperty(x => x.Count)
RemoveHistoryCommand = SelectedItems.ObserveProperty(x => x.Count)
.Select(x => x > 0)
.ToReactiveCommand()
.AddTo(_CompositeDisposable);

RemoveHistoryCommand.Subscribe(async _ =>
{
var selectedItems = SelectedVideoInfoItems.ToArray();
var selectedItems = SelectedItems.ToArray();
foreach (var item in selectedItems)
{
await RemoveHistory(item.RawVideoId);
SelectedVideoInfoItems.Remove(item);
SelectedItems.Remove(item);
await Task.Delay(250);
}
Expand Down
17 changes: 17 additions & 0 deletions NicoPlayerHohoema/ViewModels/HohoemaListingPageItemBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace NicoPlayerHohoema.ViewModels
{
abstract public class HohoemaListingPageItemBase : BindableBase, IDisposable
{
public abstract ICommand SelectedCommand { get; }

public abstract void Dispose();
}
}
Loading

0 comments on commit 3cb6200

Please sign in to comment.