void RefreshTables() { FindViewById <Button>(Resource.Id.raSelectDateB).Text = SelectedDate.Date.ToLongDateString(); if (SelectedDate.Date <= DateTimeOffset.Now.Date) { RouteSearchItems = new List <RouteSearchItem>(); RoutePharmacyAdapter = new RoutePharmacyAdapter(this, RouteSearchItems); PharmacyTable.Adapter = RoutePharmacyAdapter; } else { //var sw = new SDiag.Stopwatch(); //sw.Start(); var routeItemsPharmacies = MainDatabase.GetEarlyPerfomedRouteItems(SelectedDate).Select(ri => ri.Pharmacy); RouteSearchItems = RouteSearchItemsSource.Where(rsi => !routeItemsPharmacies.Contains(rsi.UUID)).ToList(); //sw.Stop(); //SDiag.Debug.WriteLine(@"RouteSearchItems (ms): {0}, routeItemsPharmacies (cnt): {1}", sw.ElapsedMilliseconds, routeItemsPharmacies.Count()); RoutePharmacyAdapter = new RoutePharmacyAdapter(this, RouteSearchItems); PharmacyTable.Adapter = RoutePharmacyAdapter; for (int i = 0; i < RouteSearchItems.Count; i++) { RoutePharmacyAdapter.ChangeVisibility(i, true); } } RouteTable.RemoveAllViews(); foreach (var item in MainDatabase.GetRouteItems(SelectedDate).OrderBy(ri => ri.Order)) { var row = LayoutInflater.Inflate(Resource.Layout.RouteItem, RouteTable, false); var pharmacy = MainDatabase.GetEntityOrNull <Pharmacy>(item.Pharmacy); if (pharmacy == null) { row.FindViewById <TextView>(Resource.Id.riPharmacyTV).Text = "<аптека не найдена>"; } else { row.FindViewById <TextView>(Resource.Id.riPharmacyTV).Text = pharmacy.GetName(); } int position = RouteSearchItems.FindIndex(rsi => string.Compare(rsi.UUID, item.Pharmacy) == 0); if (position != -1) { RoutePharmacyAdapter.ChangeVisibility(position, false); } //row.FindViewById<TextView>(Resource.Id.riPharmacyTV).Text // = string.Format("({0}) {1}", position, MainDatabase.GetEntity<Pharmacy>(item.Pharmacy).GetName()); row.SetTag(Resource.String.Position, position); row.SetTag(Resource.String.RouteItemUUID, item.UUID); row.SetTag(Resource.String.PharmacyUUID, item.Pharmacy); row.SetTag(Resource.String.RouteItemOrder, item.Order); row.FindViewById <TextView>(Resource.Id.riOrderTV).Text = (item.Order + 1).ToString(); var delImage = row.FindViewById <ImageView>(Resource.Id.riDeleteIV); var now = DateTime.Now; if (SelectedDate > new DateTimeOffset(now.Year, now.Month, now.Day, 0, 0, 0, new TimeSpan(0, 0, 0))) { delImage.Click += RowDelete_Click; delImage.Visibility = ViewStates.Visible; } else { delImage.Visibility = ViewStates.Gone; } row.LongClick += Row_LongClick; row.Drag += Row_Drag; RouteTable.AddView(row); } }