Exemple #1
0
        void ConnectGoogleApiClient()
        {
            googleApiClient = new GoogleApiClient.Builder(this)
                              .AddApi(WearableClass.API)
                              .AddConnectionCallbacks(
                async connectionHint =>
            {
                if (Log.IsLoggable(Tag, LogPriority.Info))
                {
                    Log.Info(Tag, "Connected to the Google API client");
                }

                var stepCountOn      = await XFitWatchfaceConfigHelper.ReadStepCountStatus(googleApiClient);
                var stepCountState   = stepCountOn ? "ON" : "OFF";
                var stepCountSetting = new Setting($"Step count\n{stepCountState}", "stepcount", stepCountOn);
                settings             = new Setting[] { stepCountSetting };
                listView.SetAdapter(new ListAdapter(this, settings));
            },
                cause =>
            {
                if (Log.IsLoggable(Tag, LogPriority.Info))
                {
                    Log.Info(Tag, "Connection suspended");
                }
            }
                )
                              .Build();

            googleApiClient.Connect();
        }
        void ConnectGoogleApiClient()
        {
            googleApiClient = new GoogleApiClient.Builder(this)
                              .AddApi(WearableClass.API)
                              .AddConnectionCallbacks(
                async connectionHint =>
            {
                if (Log.IsLoggable(Tag, LogPriority.Info))
                {
                    Log.Info(Tag, "Connected to the Google API client");
                }

                stepCountOn = await XFitWatchfaceConfigHelper.ReadStepCountStatus(googleApiClient);
                UpdateUI();
            },
                cause =>
            {
                if (Log.IsLoggable(Tag, LogPriority.Info))
                {
                    Log.Info(Tag, "Connection suspended");
                }
            }
                )
                              .Build();

            googleApiClient.Connect();
        }
Exemple #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.XFitWatchfaceWearableConfigActivity);
            header = FindViewById <TextView>(Resource.Id.Header);

            listView = FindViewById <WearableListView>(Resource.Id.ColorPicker);
            var content = FindViewById <BoxInsetLayout>(Resource.Id.Content);

            content.ApplyWindowInsets = (v, insets) =>
            {
                if (!insets.IsRound)
                {
                    v.SetPaddingRelative(
                        Resources.GetDimensionPixelSize(Resource.Dimension.ContentPaddingStart),
                        v.PaddingTop,
                        v.PaddingEnd,
                        v.PaddingBottom
                        );
                }
                return(v.OnApplyWindowInsets(insets));
            };

            listView.HasFixedSize = true;

            listView.Click += (object sender, WearableListView.ClickEventArgs e) =>
            {
                var viewHolder     = e.P0;
                var itemViewHolder = viewHolder as ItemViewHolder;

                var state = itemViewHolder.Setting.Value;
                XFitWatchfaceConfigHelper.SaveStepCountStatus(googleApiClient, !state);

                Finish();
            };

            listView.AbsoluteScrollChange += (object sender, WearableListView.AbsoluteScrollChangeEventArgs e) =>
            {
                var scroll         = e.P0;
                var newTranslation = Math.Min(-scroll, 0);
                header.TranslationY = newTranslation;
            };
        }