public async Task SetDetailItem(MotionActivityQuery newDetailItem)
        {
            if (detailItem != newDetailItem)
            {
                detailItem = newDetailItem;
            }

            configureView();

            currentSteps    = 0;
            currentActivity = "n/a";
            activityDataManager.StopStepUpdates();
            activityDataManager.StopMotionUpdates();
            await activityDataManager.QueryAsync(detailItem);

            TableView.ReloadData();

            if (detailItem.IsToday)
            {
                activityDataManager.StartStepUpdates((stepCount) => {
                    currentSteps   = stepCount;
                    var indexPaths = new NSIndexPath [] { NSIndexPath.FromRowSection(0, 1) };
                    TableView.ReloadRows(indexPaths, UITableViewRowAnimation.None);
                });
                activityDataManager.StartMotionUpdates((type) => {
                    var indexPaths = new NSIndexPath [] { NSIndexPath.FromRowSection(4, 0) };
                    TableView.ReloadRows(indexPaths, UITableViewRowAnimation.None);
                });
            }
        }
		public async Task SetDetailItem (MotionActivityQuery newDetailItem)
		{
			if (detailItem != newDetailItem)
				detailItem = newDetailItem;

			configureView ();

			currentSteps = 0;
			currentActivity = "n/a";
			activityDataManager.StopStepUpdates ();
			activityDataManager.StopMotionUpdates ();
			await activityDataManager.QueryAsync (detailItem);

			TableView.ReloadData ();

			if (detailItem.IsToday) {
				activityDataManager.StartStepUpdates ((stepCount) => {
					currentSteps = stepCount;
					var indexPaths = new NSIndexPath [] { NSIndexPath.FromRowSection (0, 1) };
					TableView.ReloadRows (indexPaths, UITableViewRowAnimation.None);
				});
				activityDataManager.StartMotionUpdates ((type) => {
					var indexPaths = new NSIndexPath [] { NSIndexPath.FromRowSection (4, 0) };
					TableView.ReloadRows (indexPaths, UITableViewRowAnimation.None);
				});
			}
		}
Esempio n. 3
0
        async Task refreshDays()
        {
            if (dataManager == null)
            {
                dataManager = new ActivityDataManager();
            }

            if (ActivityDataManager.CheckAvailability())
            {
                var authorized = await dataManager.CheckAuthorizationAsync();

                DispatchQueue.MainQueue.DispatchAsync(() => {
                    if (authorized)
                    {
                        NSDate date = NSDate.Now;
                        motionActivityQueries.Clear();
                        for (int i = 0; i < 7; ++i)
                        {
                            var query = MotionActivityQuery.FromDate(date, -i);
                            motionActivityQueries.Add(query);
                            TableView.ReloadData();
                        }
                    }
                    else
                    {
                        new UIAlertView("M7 not authorized", "Please enable Motion Activity for this application", null, "Cancel", null).Show();
                    }
                });
            }
            else
            {
                new UIAlertView("M7 not available", "No activity or step counting is available", null, "Cancel", null).Show();
            }
        }
Esempio n. 4
0
 public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
 {
     if (segue.Identifier == "showDetail")
     {
         var indexPath             = TableView.IndexPathForSelectedRow;
         MotionActivityQuery query = motionActivityQueries [indexPath.Row];
         (segue.DestinationViewController as AAPLDetailViewController).SetDetailItem(query);
     }
 }
Esempio n. 5
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewCell cell = tableView.DequeueReusableCell((NSString)"Cell", indexPath);

            MotionActivityQuery query = motionActivityQueries[indexPath.Row];

            cell.TextLabel.Text = query.Description;
            return(cell);
        }
		public async Task QueryAsync (MotionActivityQuery query)
		{
			reset ();
			await queryHistoricalDataAsync (query.StartDate, query.EndDate);
		}
Esempio n. 7
0
 public async Task QueryAsync(MotionActivityQuery query)
 {
     reset();
     await queryHistoricalDataAsync(query.StartDate, query.EndDate);
 }