Exemple #1
0
        private void FindUnreadId(int startIdx, TabClass tab)
        {
            if (tab.AllCount == 0)
            {
                tab.OldestUnreadId = -1;
                tab.UnreadCount = 0;
                return;
            }

            int toIdx;
            int stp;
            tab.OldestUnreadId = -1;
            if (_sorter.Order == SortOrder.Ascending)
            {
                if (startIdx == -1)
                {
                    startIdx = 0;
                }
                else
                {
                    if (startIdx > tab.AllCount - 1)
                    {
                        startIdx = tab.AllCount - 1; // 念のため
                    }
                }

                toIdx = tab.AllCount - 1;
                if (toIdx < 0)
                {
                    toIdx = 0; // 念のため
                }

                stp = 1;
            }
            else
            {
                if (startIdx == -1)
                {
                    startIdx = tab.AllCount - 1;
                }

                if (startIdx < 0)
                {
                    startIdx = 0;
                }

                // 念のため
                toIdx = 0;
                stp = -1;
            }

            var posts = tab.IsInnerStorageTabType ? tab.Posts : _statuses;
            for (int i = startIdx; i <= toIdx; i += stp)
            {
                long id = tab.GetId(i);
                if (id > -1 && !posts[id].IsRead)
                {
                    tab.OldestUnreadId = id;
                    break;
                }
            }
        }