Пример #1
0
        private async void LoadData()
        {
            // hide splash screen after 2 seconds
            ThreadPoolTimer.CreateTimer(SplashTimeOut, new TimeSpan(0, 0, 2));

            this.recentDS = new LatestPostsDS();
            this.recentDS.DataRequestError    += recentDS_DataRequestError;
            this.recentDS.OnLoadMoreCompleted += recentDS_OnLoadMoreCompleted;
            this.lv_HomePosts.ItemsSource      = this.recentDS;
            this.tb_HomeTag.DataContext        = this.recentDS;

            this.topViewDS = new DataHelper.CloudAPI.TwoDaysTopViewPostsDS();
            this.topViewDS.DataRequestError += recentDS_DataRequestError;
            this.lv_HotPosts.ItemsSource     = this.topViewDS;
            this.tb_HotTag.DataContext       = this.topViewDS;

            this.topLikeDS = new TenDaysTopLikePostsDS();
            this.topLikeDS.DataRequestError += recentDS_DataRequestError;
            this.lv_BestPosts.ItemsSource    = this.topLikeDS;
            this.tb_BestTag.DataContext      = this.topLikeDS;

            this.topBloggerDS = new RecommendBloggerDS();
            this.topBloggerDS.DataRequestError += recentDS_DataRequestError;
            this.lv_Bloggers.ItemsSource        = this.topBloggerDS.Bloggers;
            await topBloggerDS.LoadRemoteData();

            this.newsDs = new NewsDS();
            this.newsDs.DataRequestError += recentDS_DataRequestError;
            this.lv_News.ItemsSource      = this.newsDs;
            this.tb_NewsTag.DataContext   = this.newsDs;
        }
Пример #2
0
 private void LoadData()
 {
     this.newsDs = new NewsDS();
     this.newsDs.OnLoadMoreStarted   += TitleControl.DS_OnLoadMoreStarted;
     this.newsDs.OnLoadMoreCompleted += TitleControl.DS_OnLoadMoreCompleted;
     this.gv_News.ItemsSource         = this.newsDs;
     this.gv_SimpleNews.ItemsSource   = this.newsDs;
     this.DataContext = this.newsDs;
 }
Пример #3
0
 private void LoadData()
 {
     this.newsDs = new NewsDS();
     this.newsDs.OnLoadMoreStarted += TitleControl.DS_OnLoadMoreStarted;
     this.newsDs.OnLoadMoreCompleted += TitleControl.DS_OnLoadMoreCompleted;
     this.gv_News.ItemsSource = this.newsDs;
     this.gv_SimpleNews.ItemsSource = this.newsDs;
     this.DataContext = this.newsDs;
 }
Пример #4
0
        /// <summary>
        /// Load all data
        /// </summary>
        private async void LoadMainSource()
        {
            try
            {
                this.IsActive = true;
                var latest = await _latestNewsService.GetObjectAsync2("stories", "latest");

                //await when all task finish
                if (latest != null && latest.Stories != null)
                {
                    _latestDate = DateTime.ParseExact(latest.Date, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);

                    this.NewsDS = new NewsBeforeDataSource(_latestNewsService, _latestDate);

                    this.LatestNews = latest;
                    List <Story> list = new List <Story>();

                    list.Add(new Story
                    {
                        Date = DateTime.Now,
                        IsDateTitleDisplay = Visibility.Visible,
                        IsStoryItemDisplay = Visibility.Collapsed
                    });// 今日热闻头部
                    list.AddRange(latest.Stories);
                    for (int i = 1; i < list.Count; i++)
                    {
                        list[i].Date = DateTime.Now;
                        list[i].IsDateTitleDisplay = Visibility.Collapsed;
                        list[i].IsStoryItemDisplay = Visibility.Visible;
                    }
                    //this.LatestNews.Stories = list;
                    foreach (var item in list)
                    {
                        NewsDS.Add(item);
                    }

                    this.IsActive = false;
                }
            }
            catch (Exception)
            {
                // throw new Exception(ex.Message);
            }
        }
Пример #5
0
        /// <summary>
        /// Refresh all data
        /// </summary>
        /// <returns></returns>
        private async Task LoadMainSourceAsync()
        {
            try
            {
                this.IsActive = true;
                Messenger.Default.Send(new NotificationMessage("NotifyRefreshMenu"));

                var latest = await _latestNewsService.GetObjectAsync2("stories", "latest");

                if (latest != null && latest.Stories != null)
                {
                    List <Story> newList = new List <Story>(latest.Stories);

                    if (this.LatestNews != null && this.LatestNews.Stories != null)
                    {
                        foreach (var story in this.LatestNews.Stories)
                        {
                            newList.RemoveAll(sy => sy.Id == story.Id);
                        }
                    }
                    else
                    {
                        this.NewsDS = new NewsBeforeDataSource(_latestNewsService, _latestDate);
                    }

                    this.LatestNews = latest;

                    for (int i = 0; i < newList.Count; i++)
                    {
                        newList[i].Date = DateTime.Now;
                        newList[i].IsDateTitleDisplay = Visibility.Collapsed;
                        newList[i].IsStoryItemDisplay = Visibility.Visible;
                        NewsDS.Insert(i, newList[i]);
                    }

                    this.IsActive = false;
                }
            }
            catch (Exception)
            {
                // throw new Exception(ex.Message);
            }
        }
Пример #6
0
        private async void LoadData()
        {
            // hide splash screen after 2 seconds
            //ThreadPoolTimer.CreateTimer(SplashTimeOut, new TimeSpan(0, 0, 2));

            this.recentDS = new LatestPostsDS();
            this.recentDS.DataRequestError    += recentDS_DataRequestError;
            this.recentDS.OnLoadMoreStarted   += recentDS_OnLoadMoreStarted;
            this.recentDS.OnLoadMoreCompleted += recentDS_OnLoadMoreCompleted;
            this.lv_HomePosts.ItemsSource      = this.recentDS;
            this.tb_HomeTag.DataContext        = this.recentDS;
            await this.recentDS.LoadMoreItemsAsync(20);

            this.newsDs = new NewsDS();
            this.newsDs.DataRequestError += recentDS_DataRequestError;
            this.lv_News.ItemsSource      = this.newsDs;
            this.tb_NewsTag.DataContext   = this.newsDs;
            await this.newsDs.LoadMoreItemsAsync(20);

            CreateColumnData();
            this.lv_Column.ItemsSource = this.listColumn;
        }
Пример #7
0
 private void LoadData()
 {
     this.newsDs = new NewsDS();
     this.gv_News.ItemsSource = this.newsDs;
     this.DataContext         = this.newsDs;
 }
Пример #8
0
        private async void LoadData()
        {
            // hide splash screen after 2 seconds
            //ThreadPoolTimer.CreateTimer(SplashTimeOut, new TimeSpan(0, 0, 2));

            this.recentDS = new LatestPostsDS();
            this.recentDS.DataRequestError += recentDS_DataRequestError;
            this.recentDS.OnLoadMoreStarted += newsDs_OnLoadMoreStarted;
            this.recentDS.OnLoadMoreCompleted += newsDs_OnLoadMoreCompleted;
            this.lv_HomePosts.ItemsSource = this.recentDS;
            this.tn_Home.DataContext = this.recentDS;
            await this.recentDS.LoadMoreItemsAsync(20);

            this.newsDs = new NewsDS();
            this.newsDs.DataRequestError += recentDS_DataRequestError;
            //this.newsDs.OnLoadMoreStarted += newsDs_OnLoadMoreStarted;
            //this.newsDs.OnLoadMoreCompleted += newsDs_OnLoadMoreCompleted;
            this.lv_News.ItemsSource = this.newsDs;
            this.tn_News.DataContext = this.newsDs;
            await this.newsDs.LoadMoreItemsAsync(20);

            this.listColumn = await DataHelper.Function.PostHelper.GetColumns();
            this.lv_Column.ItemsSource = this.listColumn;
            this.tn_Column.DataContext = this.listColumn;

            await FavoriteCategoryDS.Instance.LoadData();
            this.fgc_Category.DataContext = FavoriteCategoryDS.Instance;
            this.lv_category.ItemsSource = FavoriteCategoryDS.Instance.Items;
            this.fg_Category = new FavoriteGroup(this.lv_category);

            await FavoriteAuthorDS.Instance.LoadData();
            this.fgc_Author.DataContext = FavoriteAuthorDS.Instance;
            this.lv_author.ItemsSource = FavoriteAuthorDS.Instance.Items;
            this.fg_Author = new FavoriteGroup(this.lv_author);

            this.lv_blog.ItemsSource = FavoritePostDS.Instance;
            await FavoritePostDS.Instance.LoadMoreItemsAsync(20);
            this.fgc_Post.DataContext = FavoritePostDS.Instance;
            this.fg_Blog = new FavoriteGroup(this.lv_blog);

            // check updates for first time
            var updateTasks = new List<Task>(2);

            updateTasks.Add(FavoriteAuthorDS.Instance.CheckUpdateForAll());
            updateTasks.Add(FavoriteCategoryDS.Instance.CheckUpdateForAll());

            //this.recentDS_OnLoadMoreCompleted(20);

            // we do not need to wait for the result, let's update UI when the tasks finished
           await Task.Run(async () =>
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
                {
                    await FavoriteAuthorDS.Instance.CheckUpdateForAll();
                    await FavoriteCategoryDS.Instance.CheckUpdateForAll();
                });
            });

            // with DispatcherTimer, we can update UI without using Dispatcher.RunAsync
            var timer = new DispatcherTimer();

            //check for update every 15 mins
            timer.Interval = TimeSpan.FromMinutes(15);
            timer.Tick += timer_Tick;

            // start the timer
            timer.Start();

            FunctionHelper.Functions.RefreshUIOnDataLoaded(this.pb_Top, this.cmdBar);
        }
Пример #9
0
        /// <summary>
        /// Load all data
        /// </summary>
        private async void LoadMainSource()
        {
            Themes_Style = new List <Theme_Style>();
            Themes_Style.Add(new Theme_Style {
                Id = -1, PicUri = new Uri("ms-appx:///Assets/FunIcon/menu_home.png"), Title = "主页", FontColor = "#FF297ACD", TbMargin = "15,0,0,0"
            });
            //Themes_Style.Add(new Theme_Style { Id = 12, Title = "导航到某夜" });
            try
            {
                this.SplashInfo = await _startImageService.GetObjectAsync("start-image", "1080*1776");

                DownloadHelper.SaveImage(SplashInfo.Img);
                var themes = _themesService.GetObjectAsync("themes");
                var latest = _latestNewsService.GetObjectAsync("news", "latest");

                //await when all task finish
                await Task.WhenAll(themes, latest);

                if (themes != null && latest != null)
                {
                    this.Themes     = themes.Result;
                    this.LatestNews = latest.Result;
                    IList <Story> list = new List <Story>(this.LatestNews.Stories);

                    list.Add(new Story {
                        Date = DateTime.Now,
                        IsDateTitleDisplay = Visibility.Visible,
                        IsStoryItemDisplay = Visibility.Collapsed
                    });
                    for (int i = 0; i < list.Count; i++)
                    {
                        list[i].Date = DateTime.Now;
                        list[i].IsDateTitleDisplay = Visibility.Collapsed;
                        list[i].IsStoryItemDisplay = Visibility.Visible;
                    }
                    //this.LatestNews.Stories = list;
                    foreach (var item in list)
                    {
                        NewsDS.Add(item);
                    }
                    if (this.Themes.Others != null)
                    {
                        foreach (Others other in this.Themes.Others)
                        {
                            Themes_Style.Add(new Theme_Style {
                                Id = other.Id, Title = other.Name
                            });
                        }
                    }

                    this.IsCompleted = true;
                }
                else
                {
                    MessageDialog msg = new MessageDialog(_startImageService.ExceptionsParameter, "提示");
                    await msg.ShowAsync();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #10
0
        private async void LoadData()
        {
            // hide splash screen after 2 seconds
            //ThreadPoolTimer.CreateTimer(SplashTimeOut, new TimeSpan(0, 0, 2));

            this.recentDS = new LatestPostsDS();
            this.recentDS.DataRequestError    += recentDS_DataRequestError;
            this.recentDS.OnLoadMoreStarted   += newsDs_OnLoadMoreStarted;
            this.recentDS.OnLoadMoreCompleted += newsDs_OnLoadMoreCompleted;
            this.lv_HomePosts.ItemsSource      = this.recentDS;
            this.tn_Home.DataContext           = this.recentDS;
            await this.recentDS.LoadMoreItemsAsync(20);

            this.newsDs = new NewsDS();
            this.newsDs.DataRequestError += recentDS_DataRequestError;
            //this.newsDs.OnLoadMoreStarted += newsDs_OnLoadMoreStarted;
            //this.newsDs.OnLoadMoreCompleted += newsDs_OnLoadMoreCompleted;
            this.lv_News.ItemsSource = this.newsDs;
            this.tn_News.DataContext = this.newsDs;
            await this.newsDs.LoadMoreItemsAsync(20);

            this.listColumn = await DataHelper.Function.PostHelper.GetColumns();

            this.lv_Column.ItemsSource = this.listColumn;
            this.tn_Column.DataContext = this.listColumn;

            await FavoriteCategoryDS.Instance.LoadData();

            this.fgc_Category.DataContext = FavoriteCategoryDS.Instance;
            this.lv_category.ItemsSource  = FavoriteCategoryDS.Instance.Items;
            this.fg_Category = new FavoriteGroup(this.lv_category);

            await FavoriteAuthorDS.Instance.LoadData();

            this.fgc_Author.DataContext = FavoriteAuthorDS.Instance;
            this.lv_author.ItemsSource  = FavoriteAuthorDS.Instance.Items;
            this.fg_Author = new FavoriteGroup(this.lv_author);

            this.lv_blog.ItemsSource = FavoritePostDS.Instance;
            await FavoritePostDS.Instance.LoadMoreItemsAsync(20);

            this.fgc_Post.DataContext = FavoritePostDS.Instance;
            this.fg_Blog = new FavoriteGroup(this.lv_blog);

            // check updates for first time
            var updateTasks = new List <Task>(2);

            updateTasks.Add(FavoriteAuthorDS.Instance.CheckUpdateForAll());
            updateTasks.Add(FavoriteCategoryDS.Instance.CheckUpdateForAll());

            //this.recentDS_OnLoadMoreCompleted(20);

            // we do not need to wait for the result, let's update UI when the tasks finished
            await Task.Run(async() =>
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
                {
                    await FavoriteAuthorDS.Instance.CheckUpdateForAll();
                    await FavoriteCategoryDS.Instance.CheckUpdateForAll();
                });
            });

            // with DispatcherTimer, we can update UI without using Dispatcher.RunAsync
            var timer = new DispatcherTimer();

            //check for update every 15 mins
            timer.Interval = TimeSpan.FromMinutes(15);
            timer.Tick    += timer_Tick;

            // start the timer
            timer.Start();

            FunctionHelper.Functions.RefreshUIOnDataLoaded(this.pb_Top, this.cmdBar);
        }