Exemplo n.º 1
0
        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);
                }));
            }
        }
Exemplo n.º 2
0
 private void ExecuteShowCommentsByMe(IWeiboAccessToken at)
 {
     var mv = new CommentlineByMeViewModel();
     mv.Reload(at.get());
     Commentline = mv;
     Content = mv;
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 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;
 }
        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;

        }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
        public override void OnTick(IWeiboAccessToken token)
        {

        }
Exemplo n.º 9
0
 public abstract void NextPage(IWeiboAccessToken token);
Exemplo n.º 10
0
        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);
            
        }
Exemplo n.º 11
0
 public void OnTick(IWeiboAccessToken token)
 {
     SwitchSecondContent();
     if(Timeline != null)
         Timeline.OnTick(token);
     CommentsTimelineItem.OnTick(token);
     HomeTimelineItem.OnTick(token);
     Recomendations.OnTick(token);
 }
Exemplo n.º 12
0
 private void ExecuteShowHomeTimeline(IWeiboAccessToken obj)
 {
     Content = Timeline;
 }
Exemplo n.º 13
0
 private bool CanExecuteReply(IWeiboAccessToken arg)
 {
     return true;
 }
Exemplo n.º 14
0
 void execute_show_more(IWeiboAccessToken at)
 {
     Debug.Assert(at != null);
     initialize(at.get());
 }
Exemplo n.º 15
0
 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;
     }
 }
Exemplo n.º 16
0
 public abstract void Reload(IWeiboAccessToken token);
Exemplo n.º 17
0
 private bool can_show_more(IWeiboAccessToken at)
 {// IsEnabled="{Binding can_show_more,Mode=OneWay}"
     return (_page - 1) * item_per_page < _total_number;
 }
Exemplo n.º 18
0
 private void ExecuteReload(IWeiboAccessToken obj)
 {
     Reload(obj.get());
 }
Exemplo n.º 19
0
 private void ExecuteNextPage(IWeiboAccessToken obj)
 {
     NextPage(obj.get());
 }
Exemplo n.º 20
0
 public override void NextPage(IWeiboAccessToken token)
 {
     SecondPage(token.get(),true);
     ++PageNo;
 }
Exemplo n.º 21
0
 public abstract void MorePage(IWeiboAccessToken token);
Exemplo n.º 22
0
 public override void MorePage(IWeiboAccessToken token)
 {
     SecondPage(token.get(), false);
 }
Exemplo n.º 23
0
 private bool CanExecuteSubmit(IWeiboAccessToken arg)
 {
     return true;
 }
Exemplo n.º 24
0
 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;
 }
Exemplo n.º 25
0
 public abstract void OnTick(IWeiboAccessToken token);