Ejemplo n.º 1
0
        /// <summary>
        /// 元ツイート等の追加
        /// </summary>
        private async void SetStatus()
        {
            // 元ツイートの取得
            var mainStatus = await AccountTokens.ShowStatusAsync(this.TimelineModel.TokenSuffix, this.Id);

            if (mainStatus == null)
            {
                return;
            }

            var mainProperties = new TimelineItemProperties(this.TimelineModel, mainStatus, StatusType.IndividualMain);

            this.Statuses.Add(mainProperties);

            // リプライ先がある場合ProgressRingを追加
            if (mainStatus.InReplyToStatusId != null)
            {
                this.Statuses.Insert(0, new TimelineItemProperties(this.TimelineModel, LoadingType.ReadMoreReplies, mainStatus.InReplyToStatusId));
            }

            // 返信を取得するProgressRingを追加
            this.Statuses.Add(new TimelineItemProperties(this.TimelineModel, LoadingType.ReadMoreRepliesToMainStatus, new SearchRepliesProperties()
            {
                Id         = mainStatus.Id,
                ScreenName = mainStatus.User.ScreenName,
                MaxId      = null,
                SinceId    = mainStatus.Id + 1
            }));
        }
 /// <summary>
 /// 初期化
 /// </summary>
 /// <param name="id">ツイートID</param>
 private async void Initialize(long id)
 {
     this.Initialize(await AccountTokens.ShowStatusAsync(this.TimelineModel.TokenSuffix, id));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// リプライ先を読み込む
        /// </summary>
        /// <param name="id">リプライ先ツイートID</param>
        public async void ReadMoreReplies(long?id)
        {
            if (this.IsLoadingReplies)
            {
                return;
            }

            this.IsLoadingReplies = true;

            while (true)
            {
                if (this.IsLoadingRepliesToMainStatus)
                {
                    await Task.Run(() =>
                    {
                        System.Threading.Thread.Sleep(3000);
                    });
                }
                else
                {
                    break;
                }
            }

            long?replyId = id;

            for (int i = 0; i < 10; i++)
            {
                if (replyId == null)
                {
                    this.Statuses.First().LoadingProperties.Visibility = Visibility.Collapsed;
                    break;
                }

                StatusResponse mainStatusReplyStatus = null;
                try
                {
                    mainStatusReplyStatus = await AccountTokens.ShowStatusAsync(this.TimelineModel.TokenSuffix, (long)replyId);
                }
                catch (Exception e)
                {
                    DebugConsole.Write(e);
                    this.Statuses.First().LoadingProperties.Visibility = Visibility.Collapsed;
                    break;
                }

                if (mainStatusReplyStatus == null)
                {
                    this.Statuses.First().LoadingProperties.Visibility = Visibility.Collapsed;
                    break;
                }

                var mainStatusReplyStatusProperties = new TimelineItemProperties(this.TimelineModel, mainStatusReplyStatus, StatusType.IndividualOther);
                this.Statuses.Insert(1, mainStatusReplyStatusProperties);
                replyId = mainStatusReplyStatus.InReplyToStatusId;
            }

            this.Statuses.RemoveAt(0);

            if (replyId != null)
            {
                this.Statuses.Insert(0, new TimelineItemProperties(this.TimelineModel, LoadingType.ReadMoreRepliesButton, replyId));
            }

            this.IsLoadingReplies = false;
        }