示例#1
0
        protected async Task <bool> DoRegularLoadAsync(bool fullLoad)
        {
            int loadCount = IncrementalLoadMax - ReserveSize;

            ITableQueryAsync <Card> tableQuery =
                Db.Table <Card>()
                .Where(
                    c =>
                    c.PracticeState == PracticeState.New &&
                    !Objects.Select(o => o.Id).Contains(c.Id))
                .Take(loadCount);

            if (!fullLoad)
            {
                tableQuery = tableQuery.ShallowLoad(LazyLoader);
            }

            tableQuery = Random ? tableQuery.OrderByRand() : tableQuery.OrderBy(c => c.Due);

            int loadedCount = await AddItemsAsync(tableQuery).ConfigureAwait(false);

            if (loadedCount < loadCount)
            {
                Status = ReviewStatus.MoveNextEndOfStore;
            }

            else if (fullLoad)
            {
                FurtherLoadedIndex = loadedCount - 1;
            }

            return(loadedCount > 0);
        }
示例#2
0
        protected async Task <bool> DoFirstLoadAsync()
        {
            int totalLoadCount   = NewCardsLeft + IncrementalLoadMax;
            int fullLoadCount    = Math.Min(totalLoadCount, IncrementalFurtherLoadMax);
            int shallowLoadCount = totalLoadCount - fullLoadCount;

            ITableQueryAsync <Card> tableQuery =
                Db.Table <Card>().Where(c => c.PracticeState == PracticeState.New).Take(fullLoadCount);

            tableQuery = Random ? tableQuery.OrderByRand() : tableQuery.OrderBy(c => c.Due);

            // Fully load up to IncrementalFurtherLoadMax items
            int loadedCount = await AddItemsAsync(tableQuery).ConfigureAwait(false);

            FurtherLoadedIndex = loadedCount - 1;

            if (shallowLoadCount > 0 && loadedCount == fullLoadCount)
            {
                tableQuery =
                    Db.Table <Card>()
                    .ShallowLoad(LazyLoader)
                    .Where(
                        c =>
                        c.PracticeState == PracticeState.New &&
                        !Objects.Select(o => o.Id).Contains(c.Id))
                    .Take(shallowLoadCount);

                tableQuery = Random ? tableQuery.OrderByRand() : tableQuery.OrderBy(c => c.Due);

                loadedCount += await AddItemsAsync(tableQuery).ConfigureAwait(false);
            }

            if (loadedCount < totalLoadCount)
            {
                Status = ReviewStatus.MoveNextEndOfStore;
            }

            return(loadedCount > 0);
        }