示例#1
0
        private void OnStepsChange(object sender, MeasureEventArgs e)
        {
            if (_lastStepTimestamp == null)
            {
                _lastStepTimestamp = DateTime.Now;
            }
            if (!_gotFirstMeasurement)
            {
                _gotFirstMeasurement = true;

                HideSpinner();
            }

            _stepsBuffer++;
        }
示例#2
0
        private void OnHeartRateChange(object sender, MeasureEventArgs e)
        {
            double average;
            double upperLimit;
            double lowerLimit;

            if (_beatsBuffer.Count > 0)
            {
                average    = _beatsBuffer.Average();
                upperLimit = average * 1.3f;
                lowerLimit = average / 1.3f;

                if (e.Measure > upperLimit || e.Measure < lowerLimit)
                {
                    return;
                }
            }

            _beatsBuffer.Enqueue(e.Measure);
            SaveActivity(e.Measure, "beatsPerMinute").NoAwait();

            if (!_gotFirstMeasurement)
            {
                _gotFirstMeasurement = true;

                LoadHeartAnimation(Resource.Drawable.heart_animation);
                HideSpinner();
            }

            RunOnUiThread(() => {
                AnimationDrawable heartRateAnimation;

                heartRateAnimation   = (AnimationDrawable)_heartRateIcon.Icon;
                _heartRateLabel.Text = e.Measure.ToString();

                if (!heartRateAnimation.IsRunning)
                {
                    heartRateAnimation.Start();
                }
            });
        }