示例#1
0
        public async Task <List <QrListModel> > GetCachedQrsAndLogos()
        {
            var retievedList = new List <QrListModel>();
            var sdQrPath     = $"{Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + Constants.myQrCardsOfflineCache}";
            var sdLogoPath   = $"{Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + Constants.myQrCardsOfflineLogoCache}";

            if (!Directory.Exists(sdQrPath) || !Directory.Exists(sdLogoPath))
            {
                return(retievedList);
            }
            var listQRs   = Directory.GetFiles(sdQrPath, "*");
            var listLogos = Directory.GetFiles(sdLogoPath, "*");

            try
            {
                //var gfjhg = listQRs.Where(x => x == (sdQrPath + 0 + ".jpeg"));
                //var kfgjfgk = listQRs.Single(item => item.Contains(0 + ".jpeg"));
                var    listCardObj = databaseMethods.GetCardNamesWithUrlAndIdAndPersonData();
                Bitmap tempQrBitmap, tempLogoBitmap;
                if (listQRs.Length > 0)
                {
                    for (int i = 0; i < listQRs.Length; i++)
                    {
                        tempQrBitmap   = BitmapFactory.DecodeFile(sdQrPath + "/" + i + ".jpeg");
                        tempLogoBitmap = BitmapFactory.DecodeFile(sdLogoPath + "/" + i + ".jpeg");
                        retievedList.Add(new QrListModel
                        {
                            QrImage   = tempQrBitmap,
                            LogoImage = tempLogoBitmap,
                            Id        = listCardObj[i].card_id,
                            Url       = listCardObj[i].card_url,
                            Person    = new CardsPCL.Models.Person
                            {
                                firstName = listCardObj[i].PersonName,
                                lastName  = listCardObj[i].PersonSurname
                            }
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                return(retievedList);
            }
            return(retievedList);
        }