Ejemplo n.º 1
0
        protected override void CreateDisplayToLoad(RankingsScope tab)
        {
            lastRequest?.Cancel();

            if (Header.Current.Value == RankingsScope.Spotlights)
            {
                LoadDisplay(new SpotlightsLayout
                {
                    Ruleset = { BindTarget = ruleset }
                });
                return;
            }

            var request = createScopedRequest();

            lastRequest = request;

            if (request == null)
            {
                LoadDisplay(Empty());
                return;
            }

            request.Success += () => Schedule(() => LoadDisplay(createTableFromResponse(request)));
            request.Failure += _ => Schedule(() => LoadDisplay(Empty()));

            api.Queue(request);
        }
        private void loadNewContent()
        {
            loading.Show();

            cancellationToken?.Cancel();
            lastRequest?.Cancel();

            if (Scope.Value == RankingsScope.Spotlights)
            {
                loadContent(new SpotlightsLayout
                {
                    Ruleset = { BindTarget = ruleset }
                });
                return;
            }

            var request = createScopedRequest();

            lastRequest = request;

            if (request == null)
            {
                loadContent(null);
                return;
            }

            request.Success += () => Schedule(() => loadContent(createTableFromResponse(request)));
            request.Failure += _ => Schedule(() => loadContent(null));

            api.Queue(request);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Force a re-request for data from the API.
        /// </summary>
        protected void PerformFetch()
        {
            request?.Cancel();

            request          = CreateRequest();
            request.Success += response => Schedule(() => OnSuccess(response));

            API.Queue(request);
        }
Ejemplo n.º 4
0
        private void onUserChanged(ValueChangedEvent <User> e)
        {
            loadCancellation?.Cancel();
            retrievalRequest?.Cancel();

            VisiblePages = 0;
            ItemsContainer.Clear();

            if (e.NewValue != null)
            {
                showMore();
            }
        }
Ejemplo n.º 5
0
        private void onUserChanged(ValueChangedEvent <APIUser> e)
        {
            loadCancellation?.Cancel();
            retrievalRequest?.Cancel();

            CurrentPage = null;
            ItemsContainer.Clear();

            if (e.NewValue != null)
            {
                showMore();
                SetCount(GetCount(e.NewValue));
            }
        }
 private void onLoadStarted()
 {
     loading.Show();
     request?.Cancel();
     cancellationToken?.Cancel();
     cancellationToken = new CancellationTokenSource();
 }
Ejemplo n.º 7
0
        private void updateSearch()
        {
            queryChangedDebounce?.Cancel();

            if (!IsLoaded)
            {
                return;
            }

            Users = null;
            clearPanels();
            loading.Hide();
            getUsersRequest?.Cancel();

            if (api?.IsLoggedIn != true)
            {
                return;
            }

            switch (Header.Tabs.Current.Value)
            {
            case SocialTab.Friends:
                var friendRequest = new GetFriendsRequest();     // TODO filter arguments?
                friendRequest.Success    += updateUsers;
                api.Queue(getUsersRequest = friendRequest);
                break;

            default:
                var userRequest = new GetUsersRequest();     // TODO filter arguments!
                userRequest.Success      += response => updateUsers(response.Select(r => r.User));
                api.Queue(getUsersRequest = userRequest);
                break;
            }
            loading.Show();
        }
Ejemplo n.º 8
0
        protected void UpdateScores()
        {
            // don't display any scores or placeholder until the first Scores_Set has been called.
            // this avoids scope changes flickering a "no scores" placeholder before initialisation of song select is finished.
            if (!scoresLoadedOnce)
            {
                return;
            }

            getScoresRequest?.Cancel();
            getScoresRequest = null;

            pendingUpdateScores?.Cancel();
            pendingUpdateScores = Schedule(() =>
            {
                if (api?.IsLoggedIn != true)
                {
                    PlaceholderState = PlaceholderState.NotLoggedIn;
                    return;
                }

                PlaceholderState = PlaceholderState.Retrieving;
                loading.Show();

                getScoresRequest = FetchScores(scores => Schedule(() =>
                {
                    Scores           = scores;
                    PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
                }));

                if (getScoresRequest == null)
                {
                    return;
                }

                getScoresRequest.Failure += e => Schedule(() =>
                {
                    if (e is OperationCanceledException)
                    {
                        return;
                    }

                    PlaceholderState = PlaceholderState.NetworkFailure;
                });

                api.Queue(getScoresRequest);
            });
        }
Ejemplo n.º 9
0
        private void loadNewContent()
        {
            loading.Show();

            cancellationToken?.Cancel();
            lastRequest?.Cancel();

            var request = createScopedRequest();

            lastRequest = request;

            if (request == null)
            {
                loadTable(null);
                return;
            }

            request.Success += () => loadTable(createTableFromResponse(request));
            request.Failure += _ => loadTable(null);

            api.Queue(request);
        }