示例#1
0
        async private void ShowCompetitionList()
        {
            if ((CrossConnectivity.Current.IsConnected == false))
            {
                var alertResult = await DisplayAlert(Constants.internetAlertTittle, Constants.internetAlertMessage, null, Constants.internetButton);

                if (!alertResult)
                {
                    MasterDetailSideMenucs.CreateMasterPage();
                    await Navigation.PushModalAsync(MasterDetailSideMenucs.MasterDetailPage);
                }
            }
            else
            {
                List <Dog> dogsList = await dogManager.GetTopThreeDogsByTotalWalk();

                List <Competition> topThreeList = new List <Competition>();
                int counter = 1;
                foreach (Dog dog in dogsList)
                {
                    Competition c = new Competition();
                    c.Dog = dog;
                    Image medal = new Image();

                    if (counter == 1)
                    {
                        medal.Source = ImageSource.FromFile("firstPlace.png");
                    }
                    else if (counter == 2)
                    {
                        medal.Source = ImageSource.FromFile("secondPlace.png");
                    }
                    else
                    {
                        medal.Source = ImageSource.FromFile("thirdPlace.png");
                    }
                    c.Index = medal;
                    counter++;

                    Image image = new Image();

                    if (dog.ImageD != null)
                    {
                        image.Source = ImageSource.FromStream(() => Utils.ImageStream.ConvertStringToStream(dog.ImageD));
                    }
                    else
                    {
                        image.Source = ImageSource.FromFile("Dog.png");
                    }
                    c.DogImage = image;

                    topThreeList.Add(c);
                }
                BindingContext = topThreeList;
            }
        }
示例#2
0
        async private void GetTripsList(string owner, string dogName)
        {
            if ((CrossConnectivity.Current.IsConnected == false))
            {
                var alertResult = await DisplayAlert(Constants.internetAlertTittle, Constants.internetAlertMessage, null, Constants.internetButton);

                if (!alertResult)
                {
                    MasterDetailSideMenucs.CreateMasterPage();
                    await Navigation.PushModalAsync(MasterDetailSideMenucs.MasterDetailPage);
                }
            }
            else
            {
                List <Trips> listOfTrips = await tripsManager.GetTripsByDogAndOwner(owner, dogName);

                if (listOfTrips != null)
                {
                    searchBar.IsVisible = true;
                    //grouping the list according to date
                    groupedData =
                        listOfTrips.OrderByDescending(trip => trip.Date)
                        .GroupBy(trip => trip.Date)
                        .Select(trip => new ObservableGroupCollection <string, Trips>(trip))
                        .ToList();

                    BindingContext = new ObservableCollection <ObservableGroupCollection <string, Trips> >(groupedData);

                    indicator.IsVisible = false;
                    indicator.IsRunning = false;
                }
                else
                {
                    indicator.IsVisible = false;
                    indicator.IsRunning = false;
                    var alertResult = await DisplayAlert("Oops!", "There are no recorded walks.", null, "Ok");

                    if (!alertResult)
                    {
                        MasterDetailSideMenucs.CreateMasterPage();
                        await Navigation.PushModalAsync(MasterDetailSideMenucs.MasterDetailPage);
                    }
                }
            }
        }