//Random random = new Random(); async void LoadList() { Task.Run(async() => { var entries = StepEntryManager.GetStepEntries(); /*entries.Clear(); * for(int i = 0; i < 31; i++) * { * entries.Add(new StepEntry{ Date = DateTime.Today.AddDays(-i), Steps = random.Next(3000, 11000)}); * }*/ adapter = new HistoryAdapter(this, entries); RunOnUiThread(() => { if (adapter.Count == 0) { FindViewById <LinearLayout> (Resource.Id.main_layout).SetPadding(5, 5, 5, 5); } ; //list.ListView.SetClipToPadding (false); //list.ListView.SetFitsSystemWindows (true); list.SetEmptyText(Resources.GetString(Resource.String.no_history)); //list.ListView.SetPadding(0, 0, 0, Resources.GetDimensionPixelSize(Resource.Dimension.paddingBottom)); list.ListView.Divider = new ColorDrawable(Resources.GetColor(Resource.Color.ab_white)); list.ListView.DividerHeight = 3; list.ListAdapter = adapter; }); }); }
/* * * private void PopUpNotification(int id, string title, string message){ * Notification.Builder mBuilder = * new Notification.Builder (this) * .SetSmallIcon (Resource.Drawable.ic_notification) * .SetContentTitle (title) * .SetContentText (message) * .SetAutoCancel (true); * // Creates an explicit intent for an Activity in your app * Intent resultIntent = new Intent(this, typeof(MainActivity)); * resultIntent.SetFlags(ActivityFlags.NewTask|ActivityFlags.ClearTask); * // The stack builder object will contain an artificial back stack for the * // started Activity. * // This ensures that navigating backward from the Activity leads out of * // your application to the Home screen. * var stackBuilder = Android.App.TaskStackBuilder.Create(this); * // Adds the back stack for the Intent (but not the Intent itself) * //stackBuilder.AddParentStack(); * // Adds the Intent that starts the Activity to the top of the stack * stackBuilder.AddNextIntent(resultIntent); * PendingIntent resultPendingIntent = * stackBuilder.GetPendingIntent( * 0, * PendingIntentFlags.UpdateCurrent * ); * mBuilder.SetContentIntent(resultPendingIntent); * * * * NotificationManager mNotificationManager = * (NotificationManager) GetSystemService(Context.NotificationService); * // mId allows you to update the notification later on. * mNotificationManager.Notify(id, mBuilder.Build()); * } */ private void CrunchDates(bool startup = false) { if (!Utils.IsSameDay) { //save our day from yesterday, we dont' do datetime.adddays(-1) because phone might have been off //for more then 1 day and it would not be correct! var yesterday = Helpers.Settings.CurrentDay; var dayEntry = StepEntryManager.GetStepEntry(yesterday); if (dayEntry == null || dayEntry.Date.DayOfYear != yesterday.DayOfYear) { dayEntry = new StepEntry(); } dayEntry.Date = yesterday; dayEntry.Steps = Helpers.Settings.CurrentDaySteps; Helpers.Settings.CurrentDay = DateTime.Today; Helpers.Settings.CurrentDaySteps = 0; Helpers.Settings.StepsBeforeToday = Helpers.Settings.TotalSteps; StepsToday = 0; try{ StepEntryManager.SaveStepEntry(dayEntry); }catch (Exception ex) { Console.WriteLine("Something horrible has gone wrong attempting to save database entry, it is lost forever :("); } } else if (startup) { StepsToday = Helpers.Settings.TotalSteps - Helpers.Settings.StepsBeforeToday; } }
//Random random = new Random(); async Task LoadList() { Task.Run(async() => { var entries = StepEntryManager.GetStepEntries(); /*entries.Clear(); * for(int i = 0; i < 31; i++) * { * entries.Add(new StepEntry{ Date = DateTime.Today.AddDays(-i), Steps = random.Next(3000, 11000)}); * }*/ var last7 = DateTime.Today.AddDays(-6); var last30 = DateTime.Today.AddDays(-30); weekSteps = monthSteps = Settings.CurrentDaySteps; foreach (var date in entries) { if (date.Date >= last7) { weekSteps += date.Steps; monthSteps += date.Steps; } else if (date.Date >= last30) { monthSteps += date.Steps; } } adapter = new HistoryAdapter(this, entries); RunOnUiThread(() => { if (adapter.Count == 0) { FindViewById <LinearLayout> (Resource.Id.main_layout).SetPadding(5, 5, 5, 5); } list.SetEmptyText(Resources.GetString(Resource.String.no_history)); list.ListView.Divider = new ColorDrawable(Resources.GetColor(Resource.Color.ab_white)); list.ListView.DividerHeight = 3; list.ListAdapter = adapter; list.ListView.SetDrawSelectorOnTop(true); list.ListView.ItemClick += HandleItemClick; SetActionBar(); }); }); }