private void setupSQLite() { SQLiteDataHandler.CreateDBSQLite(); if (API_RESULT_LISTMONAN != null && API_RESULT_LISTMONAN.Count > 0) { List <BeanMonAn> listMonAn = new List <BeanMonAn>(); listMonAn = SQLiteDataHandler.BeanMonAn_LoadList(); foreach (BeanMonAn item in API_RESULT_LISTMONAN) { if (String.IsNullOrEmpty(item.SearchData)) // de search { item.SearchData = CmmFunction.RemoveVietNamAccent(item.TenMon) + " " + CmmFunction.RemoveVietNamAccent(item.MieuTa); } if (listMonAn.Any(x => x.MaMon.Equals(item.MaMon))) // da ton tai trong db { BeanMonAn temp = listMonAn.Find(x => x.MaMon.Equals(item.MaMon)); if (temp.Modified != item.Modified) // cap nhat moi { SQLiteDataHandler.BeanMonAn_Update(item); Utilities_DownloadImageFromURL download = new Utilities_DownloadImageFromURL(this); string url = Utilities_API._SiteName + Utilities_API._SiteImageUrl + item.HinhAnh; download.Execute(url); } } else { SQLiteDataHandler.BeanMonAn_Insert(item); Utilities_DownloadImageFromURL download = new Utilities_DownloadImageFromURL(this); string url = Utilities_API._SiteName + Utilities_API._SiteImageUrl + item.HinhAnh; download.Execute(url); } } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource var perms = new string[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage }; ActivityCompat.RequestPermissions(this, perms, 0); SetContentView(Resource.Layout.layouttest); var btnDownload = FindViewById <Button>(Resource.Id.btnDownload); var imageView = FindViewById <ImageView>(Resource.Id.imageView); btnDownload.Click += delegate { Utilities_DownloadImageFromURL download = new Utilities_DownloadImageFromURL(this, imageView); download.Execute("https://images.alphacoders.com/911/911335.jpg"); }; }