void OnCoworkingAppeared(object sender, ItemVisibilityEventArgs e)
        {
            if (e.Item != null && GlobalObjectsHelper.AllCoworkings.Count > 0)
            {
                var coworking = e.Item as Coworking;

                if (coworking.DisplayImage == null)
                {
                    if (coworking.Images.Count > 0)
                    {
                        Task.Run(() => LoadImage(coworking));
                    }
                    else
                    {
                        coworking.UpdateDisplayImage(ImageSource.FromFile("Noimage.png"));
                    }
                }


                var index = GlobalObjectsHelper.AllCoworkings.IndexOf(coworking);
                if (index == GlobalObjectsHelper.AllCoworkings.Count - 1)
                {
                    GlobalObjectsHelper.CwSearchOptions.CorrectDates(new TimeSpan(00, 00, 00), new TimeSpan(23, 59, 59));
                    GlobalObjectsHelper.UpdateCoworkings();
                    foreach (var cw in GlobalObjectsHelper.Coworkings)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            coworkings.Add(cw);
                        });
                    }
                    GlobalObjectsHelper.CwSearchOptions.Offset += 10;//GlobalObjectsHelper.Coworkings.Count;
                    //UpdateIndexes();
                    //Task.Run(()=> UpdatePictures());
                    GlobalObjectsHelper.AllCoworkings = coworkings;
                }
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                if (GlobalObjectsHelper.AllCoworkings.Count == 0)
                {
                    NoCoworkings.IsVisible = true;
                }
                else
                {
                    NoCoworkings.IsVisible = false;
                }
            });
        }
        public async void UpdateCoworkingList()
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                Loading.IsVisible = true;
            });

            GlobalObjectsHelper.CwSearchOptions.Limit  = 100;
            GlobalObjectsHelper.CwSearchOptions.Offset = 0;
            GlobalObjectsHelper.CwSearchOptions.Radius = 50;
            GlobalObjectsHelper.CwSearchOptions.CorrectDates(new TimeSpan(00, 00, 00), new TimeSpan(23, 59, 59));

            GlobalObjectsHelper.UpdateCoworkings();
            GlobalObjectsHelper.AllCoworkings = GlobalObjectsHelper.Coworkings;

            AddPins();

            Device.BeginInvokeOnMainThread(() =>
            {
                Loading.IsVisible = false;
            });
        }
        public async void UpdateCoworkingList()
        {
            Device.BeginInvokeOnMainThread(() => {
                coworkings.Clear();
            });
            GlobalObjectsHelper.CwSearchOptions.Limit  = 10;
            GlobalObjectsHelper.CwSearchOptions.Offset = 0;
            GlobalObjectsHelper.CwSearchOptions.CorrectDates(new TimeSpan(00, 00, 00), new TimeSpan(23, 59, 59));
            GlobalObjectsHelper.UpdateCoworkings();

            foreach (var cw in GlobalObjectsHelper.Coworkings)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    coworkings.Add(cw);
                });
            }
            GlobalObjectsHelper.CwSearchOptions.Offset += GlobalObjectsHelper.Coworkings.Count;

            //TODO: Fix it
            //UpdatePictures();

            GlobalObjectsHelper.AllCoworkings = coworkings;
            Device.BeginInvokeOnMainThread(() =>
            {
                Running.IsRunning = false;
                Running.IsVisible = false;
                if (GlobalObjectsHelper.AllCoworkings.Count == 0)
                {
                    NoCoworkings.IsVisible = true;
                }
                else
                {
                    NoCoworkings.IsVisible = false;
                }
            });
        }
Beispiel #4
0
        private void UpdateCoworkingList()
        {
            GlobalObjectsHelper.CwSearchOptions.CorrectDates(new TimeSpan(00, 00, 00), new TimeSpan(23, 59, 59));
            GlobalObjectsHelper.UpdateCoworkings();

            //load pictures
            for (int i = 0; i < GlobalObjectsHelper.Coworkings.Count; i++)
            {
                if (GlobalObjectsHelper.Coworkings[i].Images.Count > 0)
                {
                    var i1 = i;
                    Task.Run(async() =>
                    {
                        LoadImage(i1, GlobalObjectsHelper.Coworkings[i1].Images[0].Id);
                    });

                    /*new Thread(() =>
                     * {
                     *  LoadImage(i1, GlobalObjectsHelper.Coworkings[i1].Images[0].Id);
                     * }).Start();*/
                }
            }
            Navigation.PopAsync();
        }