private void OutputListLayoutReset() { //var table = db.Table<Time>().OrderBy(t => t.SavedTime); /*if (currentUser == null) * return; * var table = await client.GetTable<RegisteredTime>().Where(t => t.TimeUserId == currentUser.Id).OrderBy(t => t.SavedTime).ThenBy(t => t.createdAt).ToEnumerableAsync();*/ var table = registeredTimesDB.Table <Time>().OrderByDescending(t => t.SavedTime).ThenByDescending(t => t.CreatedTime).ToList(); outputContainer.RemoveAllViews(); outputContainer.AddView(listButtonsGrid); foreach (Time t in table) { if (Math.Abs(DateTime.Now.DayOfYear - t.SavedTime.DayOfYear + 365 * (DateTime.Now.Year - t.SavedTime.Year)) < 14) { AddTimeToOutputList(t); } } if (outputContainer.ChildCount == 1) { listButtonsGrid.FindViewById <Button>(Resource.Id.resetAllButton).Enabled = false; } else { listButtonsGrid.FindViewById <Button>(Resource.Id.resetAllButton).Enabled = true; } //db.Close(); }
void SetMainPage() { //FOR TESTING PURPOSES new Thread(() => { DataBase.CreateItems(); GeneralInfo.FillDatas("softsam"); }).Start(); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); drawer.AddDrawerListener(toggle); toggle.SyncState(); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); var header = navigationView.GetHeaderView(0); TextView lblName = header.FindViewById <TextView>(Resource.Id.lblUserName); TextView lblemail = header.FindViewById <TextView>(Resource.Id.lblUserEmail); if (GeneralInfo.UserConnected) { lblName.Text = GeneralInfo.customerAccount.UserName; lblemail.Text = GeneralInfo.customerAccount.EMail; Toast.MakeText(this, "User connected...", ToastLength.Short); } else { lblName.Text = "No User"; lblemail.Text = "No User"; Toast.MakeText(this, "User did not connected...", ToastLength.Short); } navigationView.SetNavigationItemSelectedListener(this); CoordinatorLayout appBarMain = FindViewById <CoordinatorLayout>(Resource.Id.appBarMain); RelativeLayout contentMainLayout = appBarMain.FindViewById <RelativeLayout>(Resource.Id.contentMain); ScrollView scrollViewContent = contentMainLayout.FindViewById <ScrollView>(Resource.Id.gridContentInc); GridLayout gridLayout = scrollViewContent.FindViewById <GridLayout>(Resource.Id.gridContent); LinearLayout _template = gridLayout.FindViewById <LinearLayout>(Resource.Id.basicCart); mainLayout = gridLayout; template = _template; connection = DataBase.CheckConnection(); var products = connection.Table <Product>(); CreateItems(products); }