Пример #1
0
 public void OnConnected(Bundle bundle)
 {
     DataLayerListenerService.LOGD(Tag, "OnConnected(): Successfully connected to Google API client");
     WearableClass.DataApi.AddListener(googleApiClient, this);
     WearableClass.MessageApi.AddListener(googleApiClient, this);
     WearableClass.NodeApi.AddListener(googleApiClient, this);
 }
Пример #2
0
        public async void OnDataChanged(DataEventBuffer dataEvents)
        {
            DataLayerListenerService.LOGD(Tag, "OnDatachanged() : " + dataEvents);

            IList events = FreezableUtils.FreezeIterable(dataEvents);

            dataEvents.Release();
            foreach (var ev in events)
            {
                var e = ((Java.Lang.Object)ev).JavaCast <IDataEvent> ();
                if (e.Type == DataEvent.TypeChanged)
                {
                    String path = e.DataItem.Uri.Path;
                    if (DataLayerListenerService.ImagePath.Equals(path))
                    {
                        DataMapItem dataMapItem = DataMapItem.FromDataItem(e.DataItem);
                        Asset       photo       = dataMapItem.DataMap.GetAsset(DataLayerListenerService.ImageKey);
                        Bitmap      bitmap      = await LoadBitmapFromAsset(googleApiClient, photo);

                        handler.Post(() => {
                            DataLayerListenerService.LOGD(Tag, "Setting background image..");
                            layout.SetBackgroundDrawable(new BitmapDrawable(Resources, bitmap));
                        });
                    }
                    else if (DataLayerListenerService.CountPath.Equals(path))
                    {
                        DataLayerListenerService.LOGD(Tag, "Data Chaged for CountPath");
                        GenerateEvent("DataItem Changed", e.DataItem.ToString());
                    }
                    else
                    {
                        DataLayerListenerService.LOGD(Tag, "Unrecognized path: " + path);
                    }
                }
                else if (e.Type == DataEvent.TypeDeleted)
                {
                    GenerateEvent("DataItem Changed", e.DataItem.ToString());
                }
                else
                {
                    DataLayerListenerService.LOGD("Unknown data event type", "Type = " + e.Type);
                }
            }
        }
Пример #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            handler = new Handler();
            DataLayerListenerService.LOGD(Tag, "OnCreate");
            SetContentView(Resource.Layout.main_activity);
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);
            dataItemList = (ListView)FindViewById(Resource.Id.dataItem_list);
            introText    = (TextView)FindViewById(Resource.Id.intro);
            layout       = FindViewById(Resource.Id.layout);

            // Stores data events received by the local broadcaster.
            dataItemListAdapter  = new DataItemAdapter(this, Android.Resource.Layout.SimpleListItem1);
            dataItemList.Adapter = dataItemListAdapter;

            googleApiClient = new GoogleApiClient.Builder(this)
                              .AddApi(WearableClass.API)
                              .AddConnectionCallbacks(this)
                              .AddOnConnectionFailedListener(this)
                              .Build();
        }
Пример #4
0
 public void OnConnectionFailed(Android.Gms.Common.ConnectionResult result)
 {
     DataLayerListenerService.LOGD(Tag, "OnConnectionFailed(): Failed to connect, with result: " + result);
 }
Пример #5
0
 public void OnConnectionSuspended(int p0)
 {
     DataLayerListenerService.LOGD(Tag, "OnConnectionSuspended(): Connection to Google API clinet was suspended");
 }
Пример #6
0
 public void OnMessageReceived(IMessageEvent ev)
 {
     DataLayerListenerService.LOGD(Tag, "OnMessageReceived: " + ev);
     GenerateEvent("Message", ev.ToString());
 }