Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.layoutAdd);
            listPRoduct            = FindViewById <ListView>(Resource.Id.listViewProdottiact);
            listPRoduct.ItemClick += ListPRoduct_ItemClick;
            GroupSel = Intent.GetStringExtra("gruppo");
            try
            {
                listProd = Intent.GetStringArrayExtra("prod").ToList();
            }
            catch (Exception e)
            {
                listProd = new List <string>();
            }
            try
            {
                listURI = Intent.GetStringArrayExtra("uri").ToList();
            }
            catch (Exception e)
            {
                listURI = new List <string>();
            }
            query = Helper.table.Where(s => s[s.Count - 2] == GroupSel).ToList();
            var subGroupList = new List <string>();

            foreach (var row in query)
            {
                subGroupList.Add(row[3]);
            }
            var output = subGroupList
                         .GroupBy(word => word)
                         .OrderByDescending(subgroup => subgroup.Count())
                         .Select(group => group.Key)
                         .ToList();
            var pListSub    = new List <Prodotto>();
            var cultureInfo = Thread.CurrentThread.CurrentCulture;
            var textInfo    = cultureInfo.TextInfo;

            foreach (var subGroup in output)
            {
                var psub = new Prodotto
                {
                    ImageUrl = query.First(list => list[3].Equals(subGroup))[15],
                    Grouop   = query.First(list => list[3].Equals(subGroup))[5],
                    SubGroup = query.First(list => list[3].Equals(subGroup)).Last(),

                    Name          = textInfo.ToTitleCase(query.First(list => list[3].Equals(subGroup)).Last()),
                    QuantityPrice = ""
                };
                pListSub.Add(psub);
            }


            listPRoduct.Adapter = new ProdottoAdapter(pListSub);
            // Create your application here
        }
Example #2
0
        public void GetInSub(List <List <string> > querys)
        {
            CultureInfo ci       = Thread.CurrentThread.CurrentCulture;
            TextInfo    ti       = ci.TextInfo;
            var         listtemp = new List <Prodotto>();

            foreach (var sDirectoryItem in querys)
            {
                var name  = ti.ToLower(sDirectoryItem[5]);
                var ptemp = new Prodotto
                {
                    ImageUrl      = sDirectoryItem[15],
                    Name          = name,
                    QuantityPrice = $"{sDirectoryItem[6]}pz/{sDirectoryItem[12]}€",
                    Grouop        = sDirectoryItem[sDirectoryItem.Count - 2],
                    SubGroup      = sDirectoryItem.Last(),
                    UnitPrice     = sDirectoryItem[12],
                    CodArt        = sDirectoryItem[4]
                };
                listtemp.Add(ptemp);
            }
            listPRoduct.Adapter = new ProdottoAdapter(listtemp);
            subqueryList        = listtemp;
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/catalogo.csv"))
            {
                Helper.GetData();
            }
            BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);

            navigation.SetOnNavigationItemSelectedListener(this);
            listView = FindViewById <ListView>(Resource.Id.listViewMainProd);


            const string permission = Manifest.Permission.ReadExternalStorage;

            if (CheckSelfPermission(permission) != (int)Permission.Granted)
            {
                RequestPermissions(new[] { Manifest.Permission.ReadExternalStorage }, 5);
            }

            var prodArray = Intent.GetStringArrayExtra("prod");
            var uriArray  = Intent.GetStringArrayExtra("uri");

            if (Intent.GetBooleanExtra("first", true))
            {
                SetCodCliFor();
            }
            else
            {
                using (StreamReader stream = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/codclifor.txt"))
                {
                    codclifor = stream.ReadLine();
                }
                var path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment
                                                                                    .DirectoryDownloads).AbsolutePath + "";
                var clienti = Helper.GetClienti(path);
                SupportActionBar.Subtitle = "Cliente:" + clienti.First(list => list[7] == codclifor)[12];
            }
            try
            {
                listURI  = uriArray.ToList();
                listprod = prodArray.ToList();
                var templist  = new List <Prodotto>();
                var finalList = listprod.Zip(listURI, (p, u) => new
                {
                    prodotto = p,
                    uri      = u
                }).ToList();
                CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                TextInfo    textInfo    = cultureInfo.TextInfo;
                foreach (var prod in finalList)
                {
                    var ptemp = new Prodotto();
                    ptemp.ImageUrl = prod.uri;
                    var split = prod.prodotto.Split(';');
                    var namet = query.First(p => p[4] == split[0])[5];
                    namet               = textInfo.ToLower(namet);
                    ptemp.Name          = textInfo.ToTitleCase(namet);
                    ptemp.QuantityPrice = split[1] + '/' + split[2];
                    templist.Add(ptemp);
                }
                listView.Adapter = new ProdottoAdapter(templist);
            }
            catch (Exception)
            {
                listURI  = new List <string>();
                listprod = new List <string>();
            }
            IsPlayServicesAvailable();
            FirebaseMessaging.Instance.SubscribeToTopic("all");
        }