public async void OnTick(IWeiboAccessToken at) { if (_tick++%57 != 0) return; var resp = await WeiboClient.suggestions_statuses_hot_async(at.get(), 20, true, 1, _type); if(++_type == hot_status_type.count) _type = hot_status_type.musement; if (resp.Failed() || resp.Value.Length == 0) return; var queue = new PriorityQueue<long, Status>(); foreach(var s in resp.Value) { queue.Enqueue(EvalMark(s),s); } while (queue.Size > 5) queue.Dequeue(); while(!queue.IsEmpty) { var s = queue.Dequeue(); var ws = new WeiboStatus(); ws.assign_sina(s); await DispatcherHelper.UIDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (Action) (() => { if(statuses.Count > 10) statuses.RemoveAt(0); statuses.Add(ws); })); } }
private void ExecuteShowCommentsByMe(IWeiboAccessToken at) { var mv = new CommentlineByMeViewModel(); mv.Reload(at.get()); Commentline = mv; Content = mv; }
private async void ExecuteReply(IWeiboAccessToken token) { is_busying = true; var resp = await WeiboClient.comments_create_async(body, _status_id, reply_to_original,token.get()); DispatcherHelper.CheckBeginInvokeOnUI(()=>reason_phrase = resp.Reason); await Task.Delay(5000); DispatcherHelper.CheckBeginInvokeOnUI(()=>is_busying = false); }
private async void ExecuteSubmit(IWeiboAccessToken at) { is_busying = true; if (string.IsNullOrEmpty(image)) { var resp = await WeiboClient.statuses_update_async(at.get(), _body); reason = resp.Reason; }else { if (!File.Exists(image)) reason = "ͼƬÎļþ²»´æÔÚ"; var resp = await WeiboClient.statuses_upload_async(image, _body, at.get()); reason = resp.Reason; } await Task.Delay(5000); is_busying = false; }
private async void ExecuteRetweet(IWeiboAccessToken token) { is_busying = true; var r = reply_to_original ? WeiboClient.StatusesRepostIsCommentFlag.CommentOrignal : WeiboClient.StatusesRepostIsCommentFlag.NoComment; var resp = await WeiboClient.statuses_repost_async(body, _status_id, r, token.get()); DispatcherHelper.CheckBeginInvokeOnUI(()=>reason_phrase = resp.Reason); await Task.Delay(5000); DispatcherHelper.CheckBeginInvokeOnUI(()=>is_busying = false); }
public override async void OnTick(IWeiboAccessToken at) { if (_ticks++ % 23 != 0) return; var resp = await WeiboClient.comments_to_me_refresh_async(at.get(), _since_id, 1, 1); if (resp.Failed()) return; var popimgref = 0; var popular_image = string.Empty; var recent_text = string.Empty; notifications = resp.Value.total_number - _total_number; _total_number = resp.Value.total_number; Debug.WriteLine("comments-timeline total : {0},next:{1},prev:{2}", resp.Value.total_number,resp.Value.next_cursor,resp.Value.previous_cursor); foreach (var c in resp.Value.comments) { if (_since_id < c.id) _since_id = c.id; if (recent_text.Length < c.text.Length) recent_text = c.text; if (c.status == null) continue; if (!string.IsNullOrEmpty(c.status.thumbnail_pic) && c.status.comments_count > popimgref) { popular_image = c.status.thumbnail_pic; popimgref = c.status.comments_count; } if (c.status.retweeted_status == null) continue; if ( c.status.retweeted_status.comments_count > popimgref && !string.IsNullOrEmpty(c.status.retweeted_status.thumbnail_pic)) { popular_image = c.status.retweeted_status.thumbnail_pic; popimgref = c.status.retweeted_status.comments_count; } } if (!string.IsNullOrEmpty(popular_image)) image = popular_image; if (!string.IsNullOrEmpty(recent_text)) text = recent_text; }
public override async void Reload(IWeiboAccessToken token) { var ses = await WeiboClient.statuses_friends_timeline_refresh_async(token.get()); if (ses.Failed()) { FireNotificationMessage("{0} - timeline {1}", ses.Error(), ses.Reason); return; } FireNotificationMessage("{0} Status fetched", ses.Value.statuses.Length); Messenger.Default.Send(new WeiboMediaReset()); await FetchUrlInfos(ses.Value.statuses); ReloadSinaV2(ses.Value,true); MaxId = long.MinValue; MinId = long.MaxValue; SetMinMaxIds(ses.Value); PageNo = 1; }
private void execute_show_comments(IWeiboAccessToken o) { Debug.Assert(o != null); comments = comments == null ? new CommentsViewModel(id) : null; if (comments == null || (retweeted_status != null ? retweeted_status.id : 0) != comments.id ) { comments = new CommentsViewModel(id); comments.initialize(o.get()); } else comments = null; }
void execute_show_retweeted_comments(IWeiboAccessToken o) { Debug.Assert(o != null && retweeted_status != null); if(comments == null || comments.id != retweeted_status.id) { comments = new CommentsViewModel(retweeted_status.id); comments.initialize(o.get()); }else { comments = null; } }
public override void MorePage(IWeiboAccessToken token) { SecondPage(token.get(), false); }
public override void NextPage(IWeiboAccessToken token) { SecondPage(token.get(),true); ++PageNo; }
public async void Initialize(IWeiboAccessToken at) { if (IsInDesignMode) return; var t = WeiboClient.users_show_async(uid, at.get()); Timeline = new TimelineHomeViewModel(); Content = Timeline; Timeline.Reload(at); var r = await t; if (!r.Failed()) { var u = new UserExt(); u.assign_sina(r.Value); user = u; FireNotificationMessage("@{0} Wecolme",u.screen_name); } else FireNotificationMessage("{0} - user {1}",r.Error(), r.Reason); // await Task.Delay(2000); }
private void ExecuteReload(IWeiboAccessToken obj) { Reload(obj.get()); }
private void ExecuteNextPage(IWeiboAccessToken obj) { NextPage(obj.get()); }
void execute_show_more(IWeiboAccessToken at) { Debug.Assert(at != null); initialize(at.get()); }