Пример #1
0
 void UpdateTimeLine(RestUsage r, RestUpdateDelegate func, TimeLineType type, int sinceListIndex)
 {
     r.LastExecTime = DateTime.Now;
     r.IsRunning    = true;
     ThreadPool.QueueUserWorkItem(delegate(object o) {
         try {
             Status[] statuses = func(_restSinceList[sinceListIndex], null, r.Count, null);
             _restSinceList[sinceListIndex] = TwitterClient.GetMaxStatusID(_restSinceList[sinceListIndex], statuses);
             _dispatcher.BeginInvoke(new EmptyDelegate(delegate() {
                 for (int i = 0; i < statuses.Length; i++)
                 {
                     statuses[i].AccountInfo = this;
                     if (type == TimeLineType.Home && IsMention(statuses[i]))
                     {
                         Mentions.Add(statuses[i]);
                         if (!_mgr.HomeIncludeMentions)
                         {
                             continue;
                         }
                     }
                     else if (type == TimeLineType.Mentions && _mgr.HomeIncludeMentions)
                     {
                         HomeTimeline.Add(statuses[i]);
                     }
                     r.TimeLine.Add(statuses[i]);
                 }
             }));
         } catch {
         } finally {
             r.IsRunning    = false;
             r.LastExecTime = DateTime.Now;
             r.UpdateNextExecTimeRemaining();
         }
     });
 }
Пример #2
0
 /// <summary>
 /// メンションをスタックに積む
 /// </summary>
 /// <param name="status">メンション</param>
 public static void StackMention(Status status)
 {
     if (Mentions == null)
     {
         Mentions = new ObservableCollection <Mention>();
         BindingOperations.EnableCollectionSynchronization(Mentions, new object());
     }
     Mentions.Add(new Mention(status));
 }
        public void AddMention(Mention mention)
        {
            if (Mentions == null)
            {
                Mentions = new List <Mention>();
            }

            if (Mentions.FirstOrDefault(x => x.MentionerId == mention.MentionerId) == null)
            {
                Mentions.Add(mention);
            }
        }
 public void CheckContentForHashtagsAndMentions()
 {
     if (Content.Length > 0)
     {
         string[] contentWords = Content.Split(' ');
         foreach (var word in contentWords)
         {
             if (word.StartsWith('#'))
             {
                 Hashtags.Add(word);
             }
             if (word.StartsWith('@'))
             {
                 Mentions.Add(word);
             }
         }
     }
 }
Пример #5
0
 public void mentionsCallback(List <Post> posts, bool is_deleted = false)
 {
     if (posts != null)
     {
         foreach (Post post in posts)
         {
             if (post == null)
             {
                 continue;
             }
             if (post.machine_only || string.IsNullOrEmpty(post.text))
             {
                 continue;
             }
             if (!post.is_deleted)
             {
                 ApnItem item = new ApnItem(post, this);
                 item.receivingAccount = this;
                 Mentions.Add(item);
                 AppController.Current.sendNotification("App.net " + username + " mentions", item.AuthorName, item.Text, item.Avatar, item);
             }
             else
             {
                 IEnumerable <ApnItem> existing_items = Mentions.Where(item => item.Id.ToString() == post.id);
                 if (existing_items != null)
                 {
                     if (existing_items.Count() > 0)
                     {
                         List <ApnItem> cache = new List <ApnItem>();
                         foreach (ApnItem item in existing_items)
                         {
                             cache.Add(item);
                         }
                         foreach (ApnItem item in cache)
                         {
                             Mentions.Remove(item);
                         }
                         cache = null;
                     }
                 }
             }
         }
     }
 }
Пример #6
0
        void backgroundWorkerMentions_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e != null)
            {
                switch (e.ProgressPercentage)
                {
                case 50:
                    ApnItem item = e.UserState as ApnItem;
                    Mentions.Add(item);
                    if (showNotifications)
                    {
                        AppController.Current.sendNotification("App.net " + username + " mentions", item.AuthorName, item.Text, item.Avatar, item);
                    }
                    break;

                case 99:
                    ApiCallResponse apiCallResponse = e.UserState as ApiCallResponse;
                    streamMarkerMentionsUpdateComplete = true;
                    if (apiCallResponse != null)
                    {
                        if (apiCallResponse.meta != null)
                        {
                            if (apiCallResponse.meta.marker != null)
                            {
                                storeMarkerIdMentions      = apiCallResponse.meta.marker.id;
                                storeMarkerVersionMentions = apiCallResponse.meta.marker.version;
                            }
                        }
                    }
                    if (Mentions.Count > 0)
                    {
                        InitialUpdateForMention = true;
                    }
                    streamMarkerMentionsUpdateComplete = true;
                    break;
                }
            }
        }
Пример #7
0
        void IStreamingHandler.Streaming_StatusArrived(object sender, StatusArrivedEventArgs e)
        {
            StreamingClient c = sender as StreamingClient;

            _dispatcher.BeginInvoke(new EmptyDelegate(delegate() {
                if (!IsIncludeOtherStatus)
                {
                    if (!_client.FriendSet.Contains(e.Status.User.ID))
                    {
                        return;
                    }
                    if (e.Status.InReplyToUserId > 0)
                    {
                        if (!_client.FriendSet.Contains(e.Status.InReplyToUserId))
                        {
                            return;
                        }
                    }
                    if (e.Status.RetweetedStatus != null && e.Status.RetweetedStatus.User != null)
                    {
                        if (e.Status.RetweetedStatus.User.ID == SelfUserID)
                        {
                            return;
                        }
                    }
                }
                e.Status.AccountInfo = this;
                if (IsMention(e.Status))
                {
                    Mentions.Add(e.Status);
                    if (!_mgr.HomeIncludeMentions)
                    {
                        return;
                    }
                }
                HomeTimeline.Add(e.Status);
            }));
        }
Пример #8
0
 /// <summary>
 /// adds a mention to the mentions list
 /// </summary>
 /// <param name="mention"></param>
 public void addMentions(string mention)
 {
     Mentions.Add(mention);
 }