public async override void OnStart() { base.OnStart(); LayoutInflater inflater = Activity.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; if (inflater != null) { DateTime lastDataRefresh = await Model.RefreshData(); RefreshTimestamp.Text = lastDataRefresh.ToLongTimeString(); ProductsCollection = Model.GetProducts(); Adapter = new Products.Model.ProductsListAdapter(ProductsCollection, inflater); ProductsList.Adapter = Adapter; ProductsList.ItemClick += OnProductClick; } // Timer for adding new dummy product // Just for testing purpose Timer timer = new Timer(1 * 1000); timer.Elapsed += (object sender, ElapsedEventArgs e) => { Activity.RunOnUiThread(() => { ProductsCollection.Add(new ProductEntity { Name = $"Product Timer {e.SignalTime}", Price = 100 }); }); }; timer.AutoReset = true; timer.Start(); Timer timer2 = new Timer(5 * 1000); timer2.Elapsed += (object sender, ElapsedEventArgs e) => { Activity.RunOnUiThread(() => { int i = 0; foreach (ProductEntity product in ProductsCollection) { product.Name = $"Test {i + 1}"; i++; } }); }; timer2.Start(); }
public async override void OnStart() { base.OnStart(); LayoutInflater inflater = Activity.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; if (inflater != null) { DateTime lastDataRefresh = await Model.RefreshData(); RefreshTimestamp.Text = lastDataRefresh.ToLongTimeString(); Adapter = new Products.Model.ProductsListAdapter(Model.GetProducts(), inflater); ProductsList.Adapter = Adapter; ProductsList.ItemClick += OnProductClick; } }