public void Setup(Int32 answerId) { //if (AnswerId > 0) //{ // VmHelper.SaveStates(this, AnswerId.ToString()); //} AnswerId = answerId; //VmHelper.ResumeStates(this, AnswerId.ToString()); if (LoginUser.Current.Profile == null) { return; } _isDetailLoaded = false; AnswerId = answerId; Detail = null; Relationship = new AnswerRelationship(); Comments = new IncrementalLoading <Comment>(GetAnswerCommentsMethod, String.Format("/answers/{0}/comments", AnswerId), "offset=0&limit=20", false); Collections = new IncrementalLoading <Collection>(GetPersonCollectionsMethod, String.Format("/people/{0}/collections", LoginUser.Current.Profile.Id), "limit=20&offset=0", false); }
public void Setup(Int32 questionId) { //if (Id > 0) //{ // VmHelper.SaveStates(this, Id.ToString()); //} Id = questionId; //if (VmHelper.HasSaved(this, Id.ToString())) //{ // VmHelper.ResumeStates(this, Id.ToString()); // return; //} Detail = null; Relationship = null; Answers = null; Comments = null; _detailLoaded = false; _relationLoaded = false; Answers = new IncrementalLoading <Answer>(GetMoreAnswersMethod, String.Format("/questions/{0}/answers", Id), "offset=0&limit=20", false); Comments = new IncrementalLoading <Comment>(GetMoreCommentsMethod, String.Format("/questions/{0}/comments", Id), "offset=0&limit=20", false); }
private void LoadMethod() { if (_isLoaded) { return; } #region 检测当前系统主题,若为浅色主题且当前时间大于等于22:00,提示开启暗夜模式 var currentTheme = LocalSettingUtility.Instance.Read <String>(Utility.Instance.CurrentThemeKey); if (currentTheme != "Dark" && DateTime.Now.Hour >= 22) { TurnDarkVisible = Visibility.Visible; } else { TurnDarkVisible = Visibility.Collapsed; } #endregion //VmHelper.Save(this); _isLoaded = true; FeedsLoading = false; Feeds = new IncrementalLoading <Feed>(GetMoreFeeds, "/feeds?excerpt_len=75", Offset, false); }
public void Setup(Int32 topicId) { //if (_topicId < 0) //{ // VmHelper.SaveStates(this, _topicId.ToString()); //} _topicId = topicId; //VmHelper.ResumeStates(this, _topicId.ToString()); _isLoaded = false; Detail = null; BestAnswers = null; Following = new Following() { IsFollowing = false }; Questions = new IncrementalLoading <Question>(GetMoreQuestions, String.Format("topics/{0}/unanswered_questions", _topicId), FirstOffset, false); BestAnswers = new IncrementalLoading <Answer>(GetMoreBestAnswers, String.Format("topics/{0}/best_answers", _topicId), FirstOffset, false); Activities = new IncrementalLoading <TopicActivity>(GetMoreActivities, String.Format("topics/{0}/activities_new", topicId), "limit=20&after_id=", false); }
private async void CreateCollectionMethod() { #region Checking Network if (false == Utility.Instance.IsNetworkAvailable) { ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3); return; } #endregion var result = await _collection.CreateAsync(LoginUser.Current.Token, !IsCollePrivate, ColleTitle, ColleDes); if (null != result.Error) { ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3); Debug.WriteLine(Regex.Unescape(result.Error.Message)); return; } IsCollePrivate = false; ColleTitle = ColleDes = String.Empty; Collections = new IncrementalLoading <Collection>(GetPersonCollectionsMethod, String.Format("/people/{0}/collections", LoginUser.Current.Profile.Id), "limit=20&offset=0", false); }
private async void RefreshMethod() { #region Checking Network if (false == Utility.Instance.IsNetworkAvailable) { ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3); return; } #endregion FeedsLoading = true; var result = await _feed.GetFeedsAsync(LoginUser.Current.Token, "/feeds?excerpt_len=75", true); if (result.Result == null) { ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3); return; } var previousUri = new Uri(result.Result.Paging.Previous); var feedsAll = (from object feed in Feeds select feed as Feed).ToList(); var newFeeds = new List <Feed>(); var query = from i in result.Result.GetItems() let asFeed = i as Feed where feedsAll.All(o => asFeed != null && o.Target.Url != asFeed.Target.Url) select asFeed; newFeeds.AddRange(query); if (newFeeds.Count == 0) { FeedsLoading = false; ToasteIndicator.Instance.Show(String.Empty, "没有更新的内容了...", null, 3); return; } ToasteIndicator.Instance.Show(String.Empty, String.Format("获得了 {0} 条动态...", newFeeds.Count), null, 3); FeedsLoading = false; if (newFeeds.Count == 20) { Feeds = new IncrementalLoading <Feed>(GetMoreFeeds, "/feeds?excerpt_len=75", Offset, false); return; } for (var i = 0; i < newFeeds.Count; i++) { Feeds.Insert(i, newFeeds[i]); } }
private void SearchQuestionsMethod() { if (String.IsNullOrEmpty(Keyword) && Questions != null) { Questions.Clear(); } Questions = new IncrementalLoading <Question>(GetMoreQuestions, "search?t=question&q={0}", FirstOffset, false); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); IncrementalLoadingBorder.SetVisibility(true); IncrementalLoading.SetVisibility(true); var args = e.Parameter as NavigateParameter; currentUri = args.ToUri; }
private async void RefreshRecommendsMethod() { #region Checking Network if (false == Utility.Instance.IsNetworkAvailable) { ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3); return; } #endregion if (RecommendsLoading) { return; } RecommendsLoading = true; var result = await _hot.GetRecommends(LoginUser.Current.Token, "/hot/editor/recommend", true); RecommendsLoading = false; if (result == null) { return; } if (result.Result == null) { ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3); return; } var recommendsAll = (from object recommend in Recommends select recommend as EditorRecommend).ToList(); var newRecommends = new List <EditorRecommend>(); var query = from i in result.Result.GetItems() let asRecommend = i as EditorRecommend where recommendsAll.All(o => asRecommend != null && o.Url != asRecommend.Url) select asRecommend; newRecommends.AddRange(query); if (newRecommends.Count == 20) { Recommends = new IncrementalLoading <EditorRecommend>(GetMoreRecommends, "/hot/editor/recommend", FirstOffset, false); return; } for (var i = 0; i < newRecommends.Count; i++) { Recommends.Insert(i, newRecommends[i]); } }
private async void RefreshHotAnswersMethod() { #region Checking Network if (false == Utility.Instance.IsNetworkAvailable) { ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3); return; } #endregion if (AnswersLoading) { return; } AnswersLoading = true; var result = await _hot.GetTodayHotAnswers(LoginUser.Current.Token, "/hot/top/answers/day", true); AnswersLoading = false; if (result == null) { return; } if (result.Result == null) { ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3); return; } var hotAnswersAll = (from object hotAnswer in HotAnswers select hotAnswer as HotAnswer).ToList(); var newHotAnswers = new List <HotAnswer>(); var query = from i in result.Result.GetItems() let asHotAnswer = i as HotAnswer where hotAnswersAll.All(o => asHotAnswer != null && o.Answers[0].Url != asHotAnswer.Answers[0].Url) select asHotAnswer; newHotAnswers.AddRange(query); if (newHotAnswers.Count == 20) { HotAnswers = new IncrementalLoading <HotAnswer>(GetMoreHotAnswers, "/hot/top/answers/day", FirstOffset, false); return; } for (var i = 0; i < newHotAnswers.Count; i++) { HotAnswers.Insert(i, newHotAnswers[i]); } }
private async void RefreshLikesMethod() { #region Checking Network if (false == Utility.Instance.IsNetworkAvailable) { ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3); return; } #endregion if (null == _notify || LikesLoading == true) { return; } LikesLoading = true; var result = await _notify.CheckLikesAync(LoginUser.Current.Token, "notifications/likes", true); LikesLoading = false; if (result == null) { return; } if (result.Error != null) { ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3); return; } var likesAll = (from object like in Likes select like as NotifyItem).ToList(); var newLikes = new List <NotifyItem>(); var query = from i in result.Result.GetItems() let asLike = i as NotifyItem where likesAll.All(o => asLike != null && o.ThreadId != asLike.ThreadId) select asLike; newLikes.AddRange(query); if (newLikes.Count == 20) { Likes = new IncrementalLoading <NotifyItem>(GetMoreLikes, "notifications/likes", "limit=20&offset=", false); return; } for (var i = 0; i < newLikes.Count; i++) { Likes.Insert(i, newLikes[i]); } }
public CommentViewModel(string articleId, string type) { LatestComments = new IncrementalLoading<Comment>((pageIndex, pageSize) => _api.GetComments(articleId, type, SortType.latest.ToString(), pageIndex, pageSize)); LatestComments.DataLoading += DataLoading; LatestComments.DataLoaded += DataLoaded; HotComments = new IncrementalLoading<Comment>((pageIndex, pageSize) => _api.GetComments(articleId, type, SortType.hot.ToString(), pageIndex, pageSize)); HotComments.DataLoading += DataLoading; HotComments.DataLoaded += DataLoaded; }
private void SearchTopicsMethod() { if (String.IsNullOrEmpty(TopicsKeyword) && SearchTopics != null) { SearchTopics.Clear(); } SearchTopics = new IncrementalLoading <Topic>(GetMoreTopics, "search?t=topic&q={0}", FirstOffset, false); }
private async void RefreshChatsMethod() { #region Checking Network if (false == Utility.Instance.IsNetworkAvailable) { ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3); return; } #endregion if (null == _message || ChatsLoading == true) { return; } ChatsLoading = true; var result = await _message.GetChats(LoginUser.Current.Token, "inbox", true); ChatsLoading = false; if (result == null) { return; } if (result.Error != null) { ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3); return; } var chatsAll = (from object chat in Chats select chat as Chat).ToList(); var newChats = new List <Chat>(); var query = from i in result.Result.GetItems() let asChat = i as Chat where chatsAll.All(o => asChat != null && o.Url != asChat.Url) select asChat; newChats.AddRange(query); if (newChats.Count == 20) { Chats = new IncrementalLoading <Chat>(GetMoreChats, "inbox", "limit=20&after_id=", false); return; } for (var i = 0; i < newChats.Count; i++) { Chats.Insert(i, newChats[i]); } }
public MainViewModel() { SlideArticles = new ObservableCollection<SlideArticle>(); Articles = new IncrementalLoading<MainModelBase>(new int[] { 35, 5, 5 }, (p, s) => _api.GetR3ArticleList(p, s), (p, s) => _api.GetR2ArticleList(p, s), (p, s) => _api.GetUArticleList(p, s)); //结果处理 Articles.ResultProcessDelegate = ResultProcess; Subjects = new IncrementalLoading<Subject>((p, s) => _api.GetSubjectList(null, null, null, SortType.latest.ToString(), p, s)); Initialize(); }
public FindViewModel(IFind hot) : this() { _hot = hot; GetBanner = new RelayCommand(GetBannerMethod); RefreshRecommends = new RelayCommand(RefreshRecommendsMethod); RefreshHotAnswers = new RelayCommand(RefreshHotAnswersMethod); RefreshCollections = new RelayCommand(RefreshHotCollectionsMethod); Recommends = new IncrementalLoading <EditorRecommend>(GetMoreRecommends, "/hot/editor/recommend", FirstOffset, false); HotAnswers = new IncrementalLoading <HotAnswer>(GetMoreHotAnswers, "/hot/top/answers/day", FirstOffset, false); Collections = new IncrementalLoading <HotCollection>(GetMoreHotCollections, "/explore/collections", FirstOffset, false); }
public void Setup(Int32 articleId) { //if (_articleId > 0) //{ // VmHelper.SaveStates(this, articleId.ToString()); //} _articleId = articleId; //VmHelper.ResumeStates(this, _articleId.ToString()); Detail = null; _detailLoaded = false; Comments = new IncrementalLoading <Comment>(GetMoreCommentsMethod, String.Format("/articles/{0}/comments", _articleId), FirstCommentsUri, false); }
public void Setup(Int32 collectionId) { //if (_collectionId > 0) //{ // VmHelper.SaveStates(this, _collectionId.ToString()); //} _collectionId = collectionId; //VmHelper.ResumeStates(this, _collectionId.ToString()); _isLoaded = false; Detail = null; Answers = new IncrementalLoading <Answer>(GetMoreAnswersMethod, String.Format("/collections/{0}/answers", _collectionId), FirstAnswersUri, false); }
public UArticleViewModel(string otherUserId, string tag) { //热门用户作品 HotUArticles = new IncrementalLoading<UArticle>((p, s) => _api.GetUArticles(otherUserId, UArticleType.hot.ToString(), tag, p, s)); HotUArticles.DataLoading += DataLoading; HotUArticles.DataLoaded += DataLoaded; //最新用户作品 LatestUArticles = new IncrementalLoading<UArticle>((p, s) => _api.GetUArticles(otherUserId, UArticleType.latest.ToString(), tag, p, s)); LatestUArticles.DataLoading += DataLoading; LatestUArticles.DataLoaded += DataLoaded; //关注用户作品 AttentionUArticles = new IncrementalLoading<UArticle>((p, s) => _api.GetUArticles(otherUserId, UArticleType.focus.ToString(), tag, p, s)); AttentionUArticles.DataLoading += DataLoading; AttentionUArticles.DataLoaded += DataLoaded; }
private void SearchMethod() { if (String.IsNullOrEmpty(Keyword) && Contents != null) { Contents.Clear(); } if (String.IsNullOrEmpty(Keyword) && People != null) { People.Clear(); } Contents = new IncrementalLoading <SearchItem>(GetMoreContents, "search?t=union&q={0}", FirstOffset, false); People = new IncrementalLoading <Author>(GetMorePeople, "search?t=people&q={0}", FirstOffset, false); }
public void Setup(String columnId) { //if (String.IsNullOrEmpty(_columnId) == false) //{ // VmHelper.SaveStates(this, _columnId.ToString()); //} _columnId = columnId; //VmHelper.ResumeStates(this, _columnId.ToString()); _isLoaded = false; Detail = null; Articles = new IncrementalLoading <Article>(GetMoreArticlesMethod, String.Format("/columns/{0}/articles", _columnId), FirstArticlesUri, false); }
private NotifyViewModel() { Notifies = new IncrementalLoading <NotifyItem>(GetMoreNotifies, "notifications/contents", "limit=20&offset=", false); Likes = new IncrementalLoading <NotifyItem>(GetMoreLikes, "notifications/likes", "limit=20&offset=", false); Chats = new IncrementalLoading <Chat>(GetMoreChats, "inbox", "limit=20&after_id=", false); CheckUnreadFollows = new RelayCommand(CheckUnreadFollowsMethod); DismissContentsNotify = new RelayCommand(DismissContentsNotifyMethod); DismissFollowsNotify = new RelayCommand(DismissFollowsNotifyMethod); DismissLikesNotify = new RelayCommand(DismissLikesNotifyMethod); DismissContentNotify = new RelayCommand <NotifyItem>(DismissContentNotifyMethod); RefreshNotifies = new RelayCommand(RefreshNotifiesMethod); RefreshLikes = new RelayCommand(RefreshLikesMethod); RefreshChats = new RelayCommand(RefreshChatsMethod); }
private async void ReplyCommentMethod(String comment) { #region Checking Network if (false == Utility.Instance.IsNetworkAvailable) { ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3); return; } #endregion if (_commentService == null) { return; } var result = await _commentService.ReplyQuestionComment(LoginUser.Current.Token, this.Detail.Id, CurrentComment.Id, comment); if (result == null) { return; } if (null != result.Error) { ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3); Debug.WriteLine(Regex.Unescape(result.Error.Message)); return; } ToasteIndicator.Instance.Show(String.Empty, String.Format("回复 {0} 的评论已发出", CurrentComment.Author.Name), null, 3); // Reload Comments Comments = new IncrementalLoading <Comment>(GetMoreCommentsMethod, String.Format("/questions/{0}/comments", Id), "offset=0&limit=20", false); Detail.CommentCount += 1; }
public void Setup(String tableId) { //if (false == String.IsNullOrEmpty(this._tableId)) //{ // VmHelper.SaveStates(this, _tableId.ToString()); //} _tableId = tableId; //VmHelper.ResumeStates(this, _tableId.ToString()); Loading = ActivitiesLoading = CommentsLoading = QuestionsLoading = false; Activities = new IncrementalLoading <TableActivity>(GetMoreActivitiesMethod, String.Format("/roundtables/{0}/activities", _tableId), "limit=20&offset=0", false); Comments = new IncrementalLoading <Comment>(GetMoreCommentsMethod, String.Format("/roundtables/{0}/comments", _tableId), "limit=20&offset=0", false); Questions = new IncrementalLoading <TableQuestion>(GetMoreQuestionsMethod, String.Format("/roundtables/{0}/questions", _tableId), "limit=20&offset=0", false); }
private async void CreateCommentMethod(String comment) { #region Checking Network if (false == Utility.Instance.IsNetworkAvailable) { ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3); return; } #endregion CommentSending = true; var result = await _commentService.CommentAnswerAsync(LoginUser.Current.Token, AnswerId, comment); CommentSending = false; if (null != result.Error) { ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3); Debug.WriteLine(Regex.Unescape(result.Error.Message)); return; } Detail.CommentCount += 1; ToasteIndicator.Instance.Show(String.Empty, "评论已发出", null, 3); Comments = new IncrementalLoading <Comment>(GetAnswerCommentsMethod, String.Format("/answers/{0}/comments", AnswerId), "offset=0&limit=20", false); #if Windows_App if (_navigation != null) { _navigation.GoBack(); } #endif }
public void Setup(String userId) { //if (false == String.IsNullOrEmpty(_userId)) //{ // VmHelper.SaveStates(this, _userId); //} if (LoginUser.Current.Profile == null) { return; } _userId = userId; //VmHelper.ResumeStates(this, _userId); if (String.IsNullOrEmpty(_userId) || "self" == _userId || _userId == LoginUser.Current.Profile.Id) { SelfVisibility = Visibility.Collapsed; } else { SelfVisibility = Visibility.Visible; } _isLoaded = false; Profile = null; Activities = new IncrementalLoading <Activity>(GetMoreActivities, String.Format("people/{0}/activities", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstActivitiesOffset, false); AnswersByCreated = new IncrementalLoading <Answer>(GetMoreAnswersByCreated, String.Format("people/{0}/answers", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); AnswersByVoteNum = new IncrementalLoading <Answer>(GetMoreAnswersByVoteNum, String.Format("people/{0}/answers", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); Questions = new IncrementalLoading <Question>(GetMoreQuestions, String.Format("people/{0}/questions", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); Collections = new IncrementalLoading <Collection>(GetMoreCollections, String.Format("people/{0}/collections", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); FollowingQues = new IncrementalLoading <Question>(GetMoreQuestions, String.Format("people/{0}/following_questions", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); FollowingColles = new IncrementalLoading <Collection>(GetMoreCollections, String.Format("people/{0}/following_collections", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); Columns = new IncrementalLoading <Column>(GetMoreColumns, String.Format("people/{0}/columns", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); ColumnsFollowing = new IncrementalLoading <Column>(GetMoreColumns, String.Format("people/{0}/following_columns", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); FollowingTopics = new IncrementalLoading <Topic>(GetMoreFollowingTopics, String.Format("people/{0}/following_topics", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); Followees = new IncrementalLoading <Profile>(GetMoreFollowees, String.Format("people/{0}/followees", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); Followers = new IncrementalLoading <Profile>(GetMoreFollowers, String.Format("people/{0}/followers", "self" == _userId ? LoginUser.Current.Profile.Id : _userId), FirstOffset, false); }
private void SetPageLoadingStatus() { IncrementalLoadingBorder.SetVisibility(true); IncrementalLoading.SetVisibility(true); }