Esempio n. 1
0
        private async Task GetProducts()
        {
            StaticMethods.ShowLoader();
            Task.Factory.StartNew(
                // tasks allow you to use the lambda syntax to pass wor
                () =>
            {
                _listProduct = WebService.GetAllProductList();
                long h       = 0;
            }).ContinueWith(async
                            t =>
            {
                try
                {
                    TransformProducts();
                    _items = new ProductItemsList(_listProduct);
                    //flowlistview1.FlowItemsSource = _items.Items;
                    //_items.Items[0].isEnableListview = true;
                }
                catch (Exception ex)
                {
                }


                StaticMethods.DismissLoader();
            }, TaskScheduler.FromCurrentSynchronizationContext()
                            );
        }
Esempio n. 2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            alreadyLoaded = true;

            flowlistviewViewCellGrid1.FlowColumnMinWidth = App.ScreenWidth / 2;

            flowlistviewViewCellGrid1.FlowItemTapped += (sender, e) =>
            {
                Handle_FlowItemTapped(sender, e);
            };
            searchBar.SearchButtonPressed += SearchBar_SearchButtonPressed;


            if ((ReferenceEquals(_listProduct, null)) && (isFirstLoad || !flag))
            {
                GetProducts().Wait();
            }
            else if (!ReferenceEquals(_listProduct, null))
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    if (flag)
                    {
                        TransformProducts();
                        _items = new ProductItemsList(_listProduct);
                        flowlistviewViewCellGrid1.FlowItemsSource = _items.Items;
                    }
                });
            }

            btnLoadMore.Clicked += BtnLoadMore_Clicked;
            //flowlistview1.FlowItemAppearing += Flowlistview1_FlowItemAppearing;

            MessagingCenter.Subscribe <object, string>(this, "PopCurrentPage", (sender, msg) =>

            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    App.Current.MainPage = new NavigationPage(new RegistrationPage());
                });
            });
        }
Esempio n. 3
0
        private async Task SearchProducts(string searchText)
        {
            StaticMethods.ShowLoader();
            Task.Factory.StartNew(
                // tasks allow you to use the lambda syntax to pass wor
                () =>
            {
                _listProduct = WebService.SearchProduct(searchText);
                long h       = 0;
            }).ContinueWith(async
                            t =>
            {
                try
                {
                    if (!ReferenceEquals(_listProduct, null))
                    {
                        if (_listProduct.Count > 0)
                        {
                            TransformProducts();
                            _items = new ProductItemsList(_listProduct);
                        }
                        else
                        {
                            DisplayAlert("Alert!", "No bike found!", "Ok");
                        }
                    }
                    else
                    {
                        DisplayAlert("Alert!", "No bike found!", "Ok");
                    }
                }
                catch (Exception ex)
                {
                }


                StaticMethods.DismissLoader();
            }, TaskScheduler.FromCurrentSynchronizationContext()
                            );
        }
        private async Task GetProducts()
        {
            StaticMethods.ShowLoader();
            Task.Factory.StartNew(
                // tasks allow you to use the lambda syntax to pass wor
                () =>
            {
                _listProduct = WebService.GetAllProductList();
            }).ContinueWith(async
                            t =>
            {
                try
                {
                    string imgData = string.Empty;
                    if (_listProduct != null)
                    {
                        for (int i = 0; i < _listProduct.Count; i++)
                        {
                            _listProduct[i].columnWidth = itemWidth;

                            for (int j = 0; j < _listProduct[i].list.Count; j++)
                            {
                                if (_listProduct[i].list.Count <= 2)
                                {
                                    _listProduct[i].listviewHeight = itemWidth - 10;
                                }
                                else if (_listProduct[i].list.Count == 4)
                                {
                                    _listProduct[i].listviewHeight = (itemWidth * 2) - 20;
                                }
                                else
                                {
                                    _listProduct[i].listviewHeight = (itemWidth * 3) - 30;
                                }

                                if (_listProduct[i].list[j].listing_type == "product")
                                {
                                    if (_listProduct[i].list[j].add_to_top == "1")
                                    {
                                        _listProduct[i].list[j].isTopEnable = true;
                                        _listProduct[i].list[j].borderColor = "Red";
                                    }
                                    else
                                    {
                                        _listProduct[i].list[j].isTopEnable = false;
                                        _listProduct[i].list[j].borderColor = "Silver";
                                    }
                                    if (!string.IsNullOrEmpty(_listProduct[i].list[j].product_image))
                                    {
                                        imgData = _listProduct[i].list[j].product_image;
                                    }
                                    _listProduct[i].list[j].width       = itemWidth - 15;
                                    _listProduct[i].list[j].imageHeight = itemWidth - 50;
                                    var array = imgData.Split(',');
                                    if (array != null)
                                    {
                                        _listProduct[i].list[j].product_image = Constants.ImageUrl + array[0];
                                    }
                                }
                                else
                                {
                                    _listProduct[i].list[j].product_image = _listProduct[i].list[j].advertisement_img;
                                    _listProduct[i].list[j].imageHeight   = itemWidth - 20;
                                    _listProduct[i].list[j].width         = itemWidth - 15;
                                    _listProduct[i].list[j].borderColor   = "Silver";
                                }
                            }
                        }
                        _items = new ProductItemsList(_listProduct);
                        flowlistviewViewCellGrid.ItemsSource = _items.Items;
                    }
                }
                catch (Exception ex)
                {
                }


                StaticMethods.DismissLoader();
            }, TaskScheduler.FromCurrentSynchronizationContext()
                            );
        }