Exemplo n.º 1
0
        protected override async Task NavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            NowLoading = true;

            string userId = null;

            if (e.Parameter is string)
            {
                userId = e.Parameter as string;
            }
            else if (e.Parameter is uint)
            {
                userId = ((uint)e.Parameter).ToString();
            }
            else
            {
                userId = HohoemaApp.LoginUserId.ToString();
            }

            if (userId == UserId)
            {
                return;
            }

            UserId = userId;


            // ログインユーザーと同じ場合、お気に入り表示をOFFに
            IsLoginUser = HohoemaApp.LoginUserId.ToString() == userId;

            IsLoadFailed = false;

            MylistGroups.Clear();
            VideoInfoItems.Clear();

            try
            {
                var userInfo = await HohoemaApp.ContentProvider.GetUserDetail(UserId);

                var user = userInfo;
                UserName    = user.Nickname;
                UserIconUri = user.ThumbnailUri;
                Description = user.Description;

                FollowerCount  = user.FollowerCount;
                StampCount     = user.StampCount;
                VideoCount     = user.TotalVideoCount;
                IsVideoPrivate = user.IsOwnerVideoPrivate;
            }
            catch
            {
                IsLoadFailed = true;
                NowLoading   = false;
            }


            if (UserId == null)
            {
                return;
            }


            // NGユーザーの設定

            if (!IsLoginUser)
            {
                var ngResult = HohoemaApp.UserSettings.NGSettings.IsNgVideoOwnerId(UserId);
                IsNGVideoOwner.Value = ngResult != null;
            }
            else
            {
                IsNGVideoOwner.Value = false;
            }


            // お気に入り状態の取得
            _NowProcessFavorite = true;

            if (HohoemaApp.IsLoggedIn)
            {
                var favManager = HohoemaApp.FollowManager;
                IsFavorite.Value = favManager.IsFollowItem(FollowItemType.User, UserId);

                CanChangeFavoriteState.Value =
                    IsFavorite.Value == true ||
                    favManager.CanMoreAddFollow(FollowItemType.User);
            }

            _NowProcessFavorite = false;

            try
            {
                await Task.Delay(500);

                var userVideos = await HohoemaApp.ContentProvider.GetUserVideos(uint.Parse(UserId), 1);

                foreach (var item in userVideos.Items.Take(5))
                {
                    var vm = new VideoInfoControlViewModel(item.VideoId, isNgEnabled: false);
                    vm.SetTitle(item.Title);
                    vm.SetThumbnailImage(item.ThumbnailUrl.OriginalString);
                    VideoInfoItems.Add(vm);
                }
                RaisePropertyChanged(nameof(VideoInfoItems));
            }
            catch (Exception ex)
            {
                IsLoadFailed = true;
                NowLoading   = false;
                Debug.WriteLine(ex.Message);
            }

            HasOwnerVideo = VideoInfoItems.Count != 0;


            if (HohoemaApp.LoginUserId.ToString() == UserId)
            {
                foreach (var item in HohoemaApp.UserMylistManager.UserMylists)
                {
                    MylistGroups.Add(new MylistGroupListItem(item, PageManager));
                }
            }
            else
            {
                try
                {
//					await Task.Delay(500);

                    var mylistGroups = await HohoemaApp.ContentProvider.GetUserMylistGroups(UserId);

                    foreach (var item in mylistGroups)
                    {
                        MylistGroups.Add(new MylistGroupListItem(item, PageManager));
                    }
                }
                catch (Exception ex)
                {
                    IsLoadFailed = true;
                    Debug.WriteLine(ex.Message);
                }
            }
            RaisePropertyChanged(nameof(MylistGroups));


            UserBookmark = Database.BookmarkDb.Get(Database.BookmarkType.User, UserId)
                           ?? new Database.Bookmark()
            {
                Content      = UserId,
                Label        = UserName,
                BookmarkType = Database.BookmarkType.User
            };

            RaisePropertyChanged(nameof(UserBookmark));

            NowLoading = false;
        }
Exemplo n.º 2
0
        protected override async Task NavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            NowLoading = true;

            string userId = null;

            if (e.Parameter is string)
            {
                userId = e.Parameter as string;
            }
            else if (e.Parameter is uint)
            {
                userId = ((uint)e.Parameter).ToString();
            }
            else
            {
                userId = NiconicoSession.UserId.ToString();
            }

            if (userId == UserId)
            {
                NowLoading = false;
                return;
            }

            UserId = userId;


            // ログインユーザーと同じ場合、お気に入り表示をOFFに
            IsLoginUser = NiconicoSession.UserId.ToString() == userId;

            IsLoadFailed = false;

            MylistGroups.Clear();
            VideoInfoItems.Clear();

            try
            {
                var userInfo = await UserProvider.GetUserDetail(UserId);

                var user = userInfo;
                UserName    = user.Nickname;
                UserIconUri = user.ThumbnailUri;

                FollowerCount  = user.FollowerCount;
                StampCount     = user.StampCount;
                VideoCount     = user.TotalVideoCount;
                IsVideoPrivate = user.IsOwnerVideoPrivate;
            }
            catch
            {
                IsLoadFailed = true;
                NowLoading   = false;
            }


            if (UserId == null)
            {
                return;
            }


            // NGユーザーの設定

            if (!IsLoginUser)
            {
                var ngResult = NgSettings.IsNgVideoOwnerId(UserId);
                IsNGVideoOwner.Value = ngResult != null;
            }
            else
            {
                IsNGVideoOwner.Value = false;
            }

            try
            {
                await Task.Delay(500);

                var userVideos = await UserProvider.GetUserVideos(uint.Parse(UserId), 1);

                foreach (var item in userVideos.Items.Take(5))
                {
                    var vm = new VideoInfoControlViewModel(item.VideoId);
                    vm.SetTitle(item.Title);
                    vm.SetThumbnailImage(item.ThumbnailUrl.OriginalString);
                    VideoInfoItems.Add(vm);
                }
                RaisePropertyChanged(nameof(VideoInfoItems));
            }
            catch (Exception ex)
            {
                IsLoadFailed = true;
                NowLoading   = false;
                Debug.WriteLine(ex.Message);
            }

            HasOwnerVideo = VideoInfoItems.Count != 0;


            if (NiconicoSession.IsLoginUserId(UserId))
            {
                foreach (var item in UserMylistManager.Mylists)
                {
                    MylistGroups.Add(new MylistGroupListItem(item));
                }
            }
            else
            {
                try
                {
                    //					await Task.Delay(500);

                    var mylistGroups = await UserProvider.GetUserMylistGroups(UserId);

                    foreach (var item in mylistGroups)
                    {
                        MylistGroups.Add(new MylistGroupListItem(item));
                    }
                }
                catch (Exception ex)
                {
                    IsLoadFailed = true;
                    Debug.WriteLine(ex.Message);
                }
            }
            RaisePropertyChanged(nameof(MylistGroups));


            UserBookmark = Database.BookmarkDb.Get(Database.BookmarkType.User, UserId)
                           ?? new Database.Bookmark()
            {
                Content      = UserId,
                Label        = UserName,
                BookmarkType = Database.BookmarkType.User
            };

            RaisePropertyChanged(nameof(UserBookmark));


            FollowToggleButtonService.SetFollowTarget(this);


            NowLoading = false;
        }
Exemplo n.º 3
0
        protected override async Task NavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            NowLoading = true;

            string userId = null;

            if (e.Parameter is string)
            {
                userId = e.Parameter as string;
            }
            else if (e.Parameter is uint)
            {
                userId = ((uint)e.Parameter).ToString();
            }

            if (userId == UserId)
            {
                return;
            }

            UserId = userId;


            // ログインユーザーと同じ場合、お気に入り表示をOFFに
            IsLoginUser = HohoemaApp.LoginUserId.ToString() == userId;

            IsLoadFailed = false;

            MylistGroups.Clear();
            VideoInfoItems.Clear();


            try
            {
                var userInfo = await HohoemaApp.ContentFinder.GetUserDetail(UserId);

                var user = userInfo;
                UserName    = user.Nickname;
                UserIconUri = user.ThumbnailUri;
                Description = user.Description;

                FollowerCount  = user.FollowerCount;
                StampCount     = user.StampCount;
                VideoCount     = user.TotalVideoCount;
                IsVideoPrivate = user.IsOwnerVideoPrivate;
            }
            catch
            {
                IsLoadFailed = true;
                NowLoading   = false;
            }


            if (UserId == null)
            {
                return;
            }

            UpdateTitle($"{UserName} さん");

            // NGユーザーの設定

            if (!IsLoginUser)
            {
                var ngResult = HohoemaApp.UserSettings.NGSettings.IsNgVideoOwnerId(UserId);
                IsNGVideoOwner.Value = ngResult != null;
            }
            else
            {
                IsNGVideoOwner.Value = false;
            }


            // お気に入り状態の取得
            _NowProcessFavorite = true;

            var favManager = HohoemaApp.FollowManager;

            IsFavorite.Value = favManager.IsFollowItem(FollowItemType.User, UserId);

            CanChangeFavoriteState.Value =
                IsFavorite.Value == true ||
                favManager.CanMoreAddFollow(FollowItemType.User);

            _NowProcessFavorite = false;

            try
            {
                await Task.Delay(500);

                var userVideos = await HohoemaApp.ContentFinder.GetUserVideos(uint.Parse(UserId), 1);

                foreach (var item in userVideos.Items.Take(5))
                {
                    var nicoVideo = await HohoemaApp.MediaManager.GetNicoVideoAsync(item.VideoId);

                    VideoInfoItems.Add(new VideoInfoControlViewModel(nicoVideo, PageManager));
                }
            }
            catch (Exception ex)
            {
                IsLoadFailed = true;
                NowLoading   = false;
                Debug.WriteLine(ex.Message);
            }

            HasOwnerVideo = VideoInfoItems.Count != 0;


            if (HohoemaApp.LoginUserId.ToString() == UserId)
            {
                foreach (var item in HohoemaApp.UserMylistManager.UserMylists)
                {
                    MylistGroups.Add(new MylistGroupListItem(item, PageManager));
                }
            }
            else
            {
                try
                {
                    await Task.Delay(500);

                    var mylistGroups = await HohoemaApp.ContentFinder.GetUserMylistGroups(UserId);

                    foreach (var item in mylistGroups)
                    {
                        MylistGroups.Add(new MylistGroupListItem(item, PageManager));
                    }
                }
                catch (Exception ex)
                {
                    IsLoadFailed = true;
                    Debug.WriteLine(ex.Message);
                }
            }



            NowLoading = false;
        }