Example #1
0
        /// <summary>
        /// Receives data from handheld; this isn't really used, but is handy for connection tests and such
        /// </summary>
        /// <param name="dataEvents"></param>
        public void OnDataChanged(DataEventBuffer dataEvents)
        {
            debugLog("Data changed");
            dataStatusHandler.updateStatus("Data changed");
            var dataEvent = Enumerable.Range(0, dataEvents.Count)
                            .Select(i => JavaObjectExtensions.JavaCast <IDataEvent>(dataEvents.Get(i)))
                            .FirstOrDefault(x => x.Type == DataEvent.TypeChanged && x.DataItem.Uri.Path.Equals(TestDataPath));

            if (dataEvent == null)
            {
                return;
            }
            else
            {
                var    dataMapItem = DataMapItem.FromDataItem(dataEvent.DataItem);
                var    map         = dataMapItem.DataMap;
                string message     = dataMapItem.DataMap.GetString("Message");
                debugLog("Test data actually received! message: " + message);
            }
        }
Example #2
0
        /// <summary>
        /// inits the activity and asks the screen to stay on
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            handler = new Handler();
            SetContentView(Resource.Layout.main_activity);
            //TODO: Find out if keeping the screen on really is necessary
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);
            debugLog("App Launched");

            dataPoints = new Queue <HeartDataPoint>();
            accuracies = new string[3];

            setUpPermissions();

            setUpViews();

            setUpSensors();

            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);

            swipeRefreshLayout.Refresh += delegate(object sender, System.EventArgs e)
            {
                swipeRefreshLayout.Refreshing = true;

                //Toast.MakeText(this, "Reconnecting", ToastLength.Short).Show();
                if (!googleApiClient.IsConnected && !googleApiClient.IsConnecting)
                {
                    sensorStatusHandler.updateStatus("Connecting");
                    googleApiClient.Connect();
                }


                swipeRefreshLayout.Refreshing = false;
            };


            googleApiClient = new GoogleApiClient.Builder(this)
                              .AddApi(WearableClass.API)
                              .AddConnectionCallbacks(this)
                              .AddOnConnectionFailedListener(this)
                              .Build();
        }
Example #3
0
 /// <summary>
 /// if not currently connecting the app will try connecting to handheld
 /// </summary>
 protected override void OnResume()
 {
     base.OnResume();
     debugLog("App Resumed");
     if (!googleApiClient.IsConnected && !googleApiClient.IsConnecting)
     {
         googleApiClient.Connect();
         connectionStatusHandler.updateStatus("Connecting");
         debugLog("Connecting");
         WearableClass.DataApi.AddListener(googleApiClient, this);
     }
     //connectionTextView.Visibility = ViewStates.Visible;
 }