Пример #1
0
        public async void searchStats(string usernameText)
        {
            search.IsEnabled            = false;
            activityIndicator.IsRunning = true;
            var id = await GetDataLogic.GetID(usernameText);

            publicid = id;
            activityIndicator.IsRunning = false;

            if (id.uid == "error")
            {
                await DisplayAlert("Error", "Could not find username: "******"OK");

                search.IsEnabled = true;
                return;
            }
            else if (id.uid == "errornointernet")
            {
                await DisplayAlert("Error", "Could not connect to the Internet. Please check your connection and try again.", "OK");

                search.IsEnabled = true;
                return;
            }
            else
            {
                if (id.platforms.Count > 1)
                {
                    platformselect.ItemsSource = publicid.platforms.ToList();
                    //we have to show alert to choose platform and then call get user stats.
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        if (platformselect.IsFocused)
                        {
                            platformselect.Unfocus();
                        }

                        platformselect.Focus();
                    });
                }
                else
                {
                    //we call it without asking because there is only one platform.
                    var userstats = await GetDataLogic.GetStats(id, 0);

                    await Navigation.PushAsync(new Stats(userstats, favorites));
                }


                var resultsearch = recents.Contains(id.username);
                if (!resultsearch)
                {
                    recents.Add(id.username);
                    DependencyService.Get <IGetLists>().SetRecents(recents);
                }
            }
        }
Пример #2
0
        private async void Platformselect_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (platformselect.SelectedIndex == -1)
            {
                return;
            }
            //the second time it doesnt show the picker and it automatically enters -1... it returns null exception. Has to be investigated.
            var userstats = await GetDataLogic.GetStats(publicid, platformselect.SelectedIndex);

            await Navigation.PushAsync(new Stats(userstats, favorites));
        }