Example #1
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (categoryItems.ContainsKey(item.ItemId))
            {
                AppData.Categories.ForEach(x => {
                    x.Selected = false;
                });

                if (categoryItems[item.ItemId] != null)
                {
                    categoryItems[item.ItemId].Selected = true;
                }
                CatalogListAdapter.UpdateCatalog();
            }
            switch (item.ItemId)
            {
            /*case Android.Resource.Id.Home:
             *  if (viewPager == null) { return true; }
             *  if (viewPager.CurrentItem == 0)
             *  {
             *      drawerLayout.OpenDrawer(Android.Support.V4.View.GravityCompat.Start);
             *  }
             *  else
             *  {
             *      viewPager.SetCurrentItem(0, true);
             *  }
             *
             *  return true;*/
            case Resource.Id.action_filter:

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
Example #2
0
        private async void LoadData()
        {
            await AppData.GetInstance().UpdateData();

            InvalidateOptionsMenu();
            adapter = new CatalogListAdapter(this, AppData.Products);
            catalogListView.Adapter = adapter;
        }
        private void UpdateData()
        {
            var discount = AppData.CurrentCart.DiscountFor(product);
            var price    = AppData.CurrentCart.PriceFor(product);
            var quantity = AppData.CurrentCart.QuantityFor(product);

            TextView       productDiscount = FindViewById <TextView>(Resource.Id.detailProductSale);
            TextView       productValue    = FindViewById <TextView>(Resource.Id.detailProductPrice);
            TextView       itemCountText   = FindViewById <TextView>(Resource.Id.detailQuantity);
            RelativeLayout discountLayout  = FindViewById <RelativeLayout>(Resource.Id.detailSaleLayout);

            itemCountText.Text        = string.Format("{0} UN", quantity);
            discountLayout.Visibility = discount <= 0.0 ? ViewStates.Invisible : ViewStates.Visible;
            productDiscount.Text      = String.Format("↓{0:0.0}%", discount).Replace(".", ",");
            productValue.Text         = price.ToString("C", CultureInfo.CreateSpecificCulture("pt-BR"));

            RunOnUiThread(() =>
            {
                MainActivity.UpdateBuyButton();
                //FragmentCart.UpdateCart();
                CatalogListAdapter.UpdateCatalog();
            });
        }
Example #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            SupportActionBar.SetTitle(Resource.String.catalog);

            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);


            SetConfig();


            catalogListView = FindViewById <ListView>(Resource.Id.catalog_list_view);
            buyButton       = FindViewById <Button>(Resource.Id.buyBtn);

            catalogListView.OnItemClickListener = this;

            adapter = new CatalogListAdapter(this, AppData.Products);
            catalogListView.Adapter = adapter;

            buyButton.Click += BuyBtn_Click;

            LoadData();
        }
Example #5
0
 public CatalogListAdapter(Activity context, List <Product> inpLists) : base()
 {
     this.myContext = context;
     curLists       = inpLists;
     instance       = this;
 }