public override async void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); ProgressDialog progress = new ProgressDialog(Activity); progress.SetMessage("Wait while loading..."); progress.SetCancelable(false); // disable dismiss by tapping outside of the dialog progress.Show(); var connection = await this._connection.CheckConnection(); if (!connection.IsSuccess) { } else { var connections = await this._connection.CheckConnection(); if (!connections.IsSuccess) { } else { var products = await _catalogDataService.GetAllCatalogAsync(); await baseService.InsertObject("CatalogData", products, DateTimeOffset.Now.AddMinutes(10)); if (products != null) { foreach (var be in products) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } mAdapter = new AdapterReciclerHome(tableItems); mRecyclerView.SetAdapter(mAdapter); } } } // To dismiss the dialog progress.Dismiss(); progress.SetCancelable(true); }
private async void LoadDetailProduct(int idProduct, string nameProduct) { var connection = await this._connection.CheckConnection(); if (!connection.IsSuccess) { } else { var products = await _catalogDataService.GetAllCatalogAsync(); await baseService.InsertObject("nameProduct", products, DateTimeOffset.Now.AddMinutes(10)); if (products != null) { foreach (var be in products) { if (be.Id == idProduct) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } } mAdapter = new AdapterReciclerDetail(this, tableItems); mRecyclerView.SetAdapter(mAdapter); } } }
private async void GetProductListCategory(int idCategoria, string nameCategoria) { textView = FindViewById <TextView>(Resource.Id.TextTitle); listView = FindViewById <ListView>(Resource.Id.ListCategory); textView.Text = nameCategoria; var connection = await this._connection.CheckConnection(); if (!connection.IsSuccess) { var categoryCached = await baseService.GetFromCache <List <Products> >(nameCategoria); if (categoryCached != null) { foreach (var be in categoryCached) { if (be.Category_id == idCategoria) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } listView.Adapter = new CatalogoScreenAdapter(this, tableItems); listView.ItemClick += OnListItemClick; } Toast.MakeText(this, "NoConnection ", ToastLength.Short).Show(); } else { Toast.MakeText(this, "NoConnection ", ToastLength.Short).Show(); } } else { var categoryCached = await baseService.GetFromCache <List <Products> >(nameCategoria); if (categoryCached != null) { foreach (var be in categoryCached) { if (be.Category_id == idCategoria) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } listView.Adapter = new CatalogoScreenAdapter(this, tableItems); listView.ItemClick += OnListItemClick; } } else { var products = await _catalogDataService.GetAllCatalogAsync(); await baseService.InsertObject(nameCategoria, products, DateTimeOffset.Now.AddMinutes(10)); if (products != null) { foreach (var be in products) { if (be.Category_id == idCategoria) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } listView.Adapter = new CatalogoScreenAdapter(this, tableItems); listView.ItemClick += OnListItemClick; } } else { Toast.MakeText(this, "NoConnection Server ", ToastLength.Short).Show(); } } } }
public override async void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); ProgressDialog progress = new ProgressDialog(Activity); progress.SetMessage("Aguarde carregando..."); progress.SetCancelable(false); // disable dismiss by tapping outside of the dialog progress.Show(); var connection = await this._connection.CheckConnection(); if (!connection.IsSuccess) { var catalogCached = await baseService.GetFromCache <List <Products> >("CatalogData"); if (catalogCached != null) { if (catalogCached != null) { foreach (var be in catalogCached) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } list.Adapter = new CatalogoScreenAdapter(Activity, tableItems); } } } else { var catalogCached = await baseService.GetFromCache <List <Products> >("CatalogData"); if (catalogCached != null) { if (catalogCached != null) { foreach (var be in catalogCached) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } list.Adapter = new CatalogoScreenAdapter(Activity, tableItems); } } else { var products = await _catalogDataService.GetAllCatalogAsync(); await baseService.InsertObject("CatalogData", products, DateTimeOffset.Now.AddMinutes(10)); if (products != null) { foreach (var be in products) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } list.Adapter = new CatalogoScreenAdapter(Activity, tableItems); } } } // To dismiss the dialog progress.Dismiss(); progress.SetCancelable(true); }
public override async void OnActivityCreated(Bundle savedInstanceState) { var connection = await this._connection.CheckConnection(); if (!connection.IsSuccess) { var categoryCached = await baseService.GetFromCache <List <Products> >(this.v2); if (categoryCached != null) { foreach (var be in categoryCached) { if (be.Category_id == this.v1) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } listView.Adapter = new CatalogoScreenAdapter(Activity, tableItems); listView.ItemClick += OnListItemClick; } Toast.MakeText(Activity, "NoConnection ", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "NoConnection ", ToastLength.Short).Show(); } } else { var categoryCached = await baseService.GetFromCache <List <Products> >(this.v2); if (categoryCached != null) { foreach (var be in categoryCached) { if (be.Category_id == this.v1) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } listView.Adapter = new CatalogoScreenAdapter(Activity, tableItems); listView.ItemClick += OnListItemClick; } } else { var products = await _catalogDataService.GetAllCatalogAsync(); await baseService.InsertObject(this.v2, products, DateTimeOffset.Now.AddMinutes(10)); if (products != null) { foreach (var be in products) { if (be.Category_id == this.v1) { tableItems.Add(new Products { Id = be.Id, Price = be.Price, Name = be.Name, Description = be.Description, Category_id = be.Category_id, Photo = be.Photo }); } listView.Adapter = new CatalogoScreenAdapter(Activity, tableItems); listView.ItemClick += OnListItemClick; } } else { Toast.MakeText(Activity, "NoConnection Server ", ToastLength.Short).Show(); } } } }