示例#1
0
        public FavoritePage()
        {
            InitializeComponent();

            statuses.load = async(c) =>
            {
                try
                {
                    var result =
                        await FanfouAPI.FanfouAPI.Instance.FavoritesId(user.id, SettingStorage.Instance.messageSize, ++page);

                    if (result.Count == 0)
                    {
                        statuses.HasMoreItems = false;
                    }
                    StatusesReform.append(statuses, result);
                    return(result.Count);
                }
                catch (Exception)
                {
                    Utils.ToastShow.ShowInformation("加载失败,请检查网络");
                    return(0);
                }
            };

            navigationHelper            = new NavigationHelper(this);
            navigationHelper.LoadState += NavigationHelper_LoadState;
            navigationHelper.SaveState += NavigationHelper_SaveState;
        }
示例#2
0
        private async void SearchItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var ss = await FanfouAPI.FanfouAPI.Instance.SearchUserTimeline(search.Text, user.id, SettingStorage.Instance.messageSize);

                statuses.Clear();
                StatusesReform.append(statuses, ss);
                defaultViewModel["date"] = DateTime.Now.ToString();
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,请检查网络");
            }
        }
示例#3
0
        private async void RefreshItem_Click(object sender, RoutedEventArgs e)
        {
            page = 1;
            try
            {
                var ss = await FanfouAPI.FanfouAPI.Instance.FavoritesId(user.id, SettingStorage.Instance.messageSize, page);

                statuses.Clear();
                StatusesReform.append(statuses, ss);
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,请检查网络");
            }
        }
示例#4
0
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            defaultViewModel["statuses"] = statuses;

            try
            {
                var ss = await FanfouAPI.FanfouAPI.Instance.StatusPublicTimeline(SettingStorage.Instance.messageSize, 1);

                statuses.Clear();
                StatusesReform.append(statuses, ss);
                defaultViewModel["date"] = DateTime.Now.ToString();
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,请检查网络");
            }
        }
示例#5
0
        private async void search_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.Enter)
            {
                try
                {
                    var ss = await FanfouAPI.FanfouAPI.Instance.SearchUserTimeline(search.Text, user.id, SettingStorage.Instance.messageSize);

                    statuses.Clear();
                    StatusesReform.append(statuses, ss);
                    defaultViewModel["date"] = DateTime.Now.ToString();
                }
                catch (Exception)
                {
                    Utils.ToastShow.ShowInformation("加载失败,请检查网络");
                }
            }
        }
示例#6
0
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            defaultViewModel["statuses"] = statuses;
            user = Utils.DataConverter <User> .Convert(e.NavigationParameter as string);

            try
            {
                page = 1;
                var ss = await FanfouAPI.FanfouAPI.Instance.FavoritesId(user.id, SettingStorage.Instance.messageSize, page);

                statuses.Clear();
                StatusesReform.append(statuses, ss);
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,请检查网络");
            }
        }
示例#7
0
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            defaultViewModel["statuses"] = statuses;
            user = Utils.DataConverter <User> .Convert(e.NavigationParameter as string);

            title.Text = user.screen_name + "的时间线";
            try
            {
                var ss = await FanfouAPI.FanfouAPI.Instance.StatusHomeTimeline(SettingStorage.Instance.messageSize, id : user.id);

                statuses.Clear();
                StatusesReform.append(statuses, ss);
                defaultViewModel["date"] = DateTime.Now.ToString();
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,请检查网络");
            }
        }
示例#8
0
        public UserPage()
        {
            InitializeComponent();

            navigationHelper            = new NavigationHelper(this);
            navigationHelper.LoadState += NavigationHelper_LoadState;
            navigationHelper.SaveState += NavigationHelper_SaveState;

            App.RootFrame.SizeChanged += RootFrame_SizeChanged;

            statuses.load = async(c) =>
            {
                if (statuses.Count > 0)
                {
                    try
                    {
                        var list = await FanfouAPI.FanfouAPI.Instance.StatusUserTimeline(user.id, c, max_id : statuses.Last().id);

                        if (list.Count == 0)
                        {
                            statuses.HasMoreItems = false;
                        }
                        Utils.StatusesReform.append(statuses, list);
                        return(list.Count);
                    }
                    catch (Exception)
                    {
                        Utils.ToastShow.ShowInformation("加载失败,请检查网络");
                        return(0);
                    }
                }
                return(0);
            };

            favorites.load = async(c) =>
            {
                if (favorites.Count > 0)
                {
                    try
                    {
                        var result =
                            await FanfouAPI.FanfouAPI.Instance.FavoritesId(user.id, SettingStorage.Instance.messageSize, ++favoritePage);

                        if (result.Count == 0)
                        {
                            favorites.HasMoreItems = false;
                        }
                        StatusesReform.append(favorites, result);

                        return(result.Count);
                    }
                    catch (Exception)
                    {
                        return(0);
                    }
                }
                return(0);
            };


            friends.load = async(c) =>
            {
                if (friends.Count > 0)
                {
                    try
                    {
                        var result =
                            await FanfouAPI.FanfouAPI.Instance.UsersFriends(user.id, SettingStorage.Instance.messageSize, ++friendsPage);

                        if (result.Count == 0)
                        {
                            friends.HasMoreItems = false;
                        }

                        foreach (User i in result)
                        {
                            friends.Add(i);
                        }

                        return(result.Count);
                    }
                    catch (Exception)
                    {
                        Utils.ToastShow.ShowInformation("加载失败,请检查网络");
                        return(0);
                    }
                }
                return(0);
            };

            followers.load = async(c) =>
            {
                if (followers.Count > 0)
                {
                    try
                    {
                        var result =
                            await FanfouAPI.FanfouAPI.Instance.UsersFollowers(user.id, SettingStorage.Instance.messageSize, ++followersPage);

                        if (result.Count == 0)
                        {
                            followers.HasMoreItems = false;
                        }

                        foreach (User i in result)
                        {
                            followers.Add(i);
                        }

                        return(result.Count);
                    }
                    catch (Exception)
                    {
                        Utils.ToastShow.ShowInformation("加载失败,请检查网络");
                        return(0);
                    }
                }
                return(0);
            };
        }
示例#9
0
        /// <summary>
        ///     使用在导航过程中传递的内容填充页。  在从以前的会话
        ///     重新创建页时,也会提供任何已保存状态。
        /// </summary>
        /// <param name="sender">
        ///     事件的来源; 通常为 <see cref="NavigationHelper" />
        /// </param>
        /// <param name="e">
        ///     事件数据,其中既提供在最初请求此页时传递给
        ///     <see cref=" Frame.Navigate1(Type, Object)" /> 的导航参数,又提供
        ///     此页在以前会话期间保留的状态的
        ///     字典。 首次访问页面时,该状态将为 null。
        /// </param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            user = Utils.DataConverter <User> .Convert(e.NavigationParameter as string);

            if (user.index != null)
            {
                switch (user.index as string)
                {
                case "timeline":
                    pivot.SelectedIndex = 0;
                    break;

                case "favorite":
                    pivot.SelectedIndex = 1;
                    break;

                case "follower":
                    pivot.SelectedIndex = 2;
                    break;

                case "friend":
                    pivot.SelectedIndex = 3;
                    break;

                default:
                    break;
                }
            }

            if (user.screen_name == null || user.screen_name == "")
            {
                try
                {
                    user = await FanfouAPI.FanfouAPI.Instance.UsersShow(user.id);

                    defaultViewModel["user"] = user;
                }
                catch (Exception)
                {
                    Utils.ToastShow.ShowInformation("加载失败,请检查网络");
                }
            }

            defaultViewModel["user"] = user;
            defaultViewModel["tags"] = tags;

            checkUserItem();
            checkFriendship();

            statuses.Clear();
            favorites.Clear();
            followers.Clear();
            friends.Clear();
            tags.Clear();

            try
            {
                var ss = await FanfouAPI.FanfouAPI.Instance.StatusUserTimeline(user.id, SettingStorage.Instance.messageSize);

                statuses.Clear();
                StatusesReform.append(statuses, ss);
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,可能未公开");
            }
            try
            {
                tags.Clear();
                var list = await FanfouUWP.FanfouAPI.FanfouAPI.Instance.TaggedList(this.user.id);

                foreach (var item in list)
                {
                    tags.Add(item);
                }
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,可能未公开");
            }
            favoritePage = 1;


            try
            {
                var ss = await FanfouAPI.FanfouAPI.Instance.FavoritesId(user.id, SettingStorage.Instance.messageSize, favoritePage);

                favorites.Clear();
                StatusesReform.append(favorites, ss);
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,可能未公开");
            }

            friendsPage = 1;

            try
            {
                var ss = await FanfouAPI.FanfouAPI.Instance.UsersFriends(user.id, SettingStorage.Instance.messageSize, friendsPage);

                friends.Clear();
                foreach (User i in ss)
                {
                    friends.Add(i);
                }
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,可能未公开");
            }

            followersPage = 1;
            try
            {
                var ss = await FanfouAPI.FanfouAPI.Instance.UsersFollowers(user.id, SettingStorage.Instance.messageSize, followersPage);

                followers.Clear();
                foreach (User i in ss)
                {
                    followers.Add(i);
                }
            }
            catch (Exception)
            {
                Utils.ToastShow.ShowInformation("加载失败,可能未公开");
            }
        }