Example #1
0
        public override void Present(GlassService service)
        {
            base.Present(service);

            if (service.GetType() == typeof (StopwatchService))
            {
                if (_card == null)
                {
                    _card = new LiveCard(service, service.GetType().FullName);
                    _renderer = new ChronometerRenderer(service);
                    _card.SetDirectRenderingEnabled(true).SurfaceHolder.AddCallback(_renderer);

                    var mi = new Intent(service, typeof(MenuActivity));
                    var b = new Bundle();
                    b.PutInt("ResourceID", Resource.Menu.stopwatch);
                    mi.PutExtras(b);
                    mi.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);

                    _card.SetAction(PendingIntent.GetActivity(service, 0, mi, 0));
                    _card.Attach(service);

                    _card.Publish(LiveCard.PublishMode.Reveal);
                }
                else
                {
                    _card.Navigate();
                }
            }
        }
Example #2
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (_card == null)
            {
                _card = new LiveCard(this, "theCard");

                _view = new BasicView(this);

                _renderer = new LiveCardRenderer(this);
                _card.SetDirectRenderingEnabled(true).SurfaceHolder.AddCallback(_renderer);
                
                var mi = new Intent(this, typeof (MenuActivity));
                mi.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                _card.SetAction(PendingIntent.GetActivity(this, 0, mi, 0));
                _card.Attach(this);

                _card.Publish(LiveCard.PublishMode.Reveal);

                _renderer.start();
            }
            else
            {
                _card.Navigate();
            }

            return StartCommandResult.Sticky;
        }
Example #3
0
        public override void ServiceDestroyed(GlassService service)
        {
            if (_card != null && _card.IsPublished)
            {
                _card.Unpublish();
                _card = null;
            }

        }
Example #4
0
 public override void OnDestroy()
 {
     if (_card != null && _card.IsPublished)
     {
         _card.Unpublish();
         _card = null;
     }
     base.OnDestroy();
 }
Example #5
0
        public override void OnDestroy()
        {
            if (livecard != null && livecard.IsPublished) {
                _rangeNotifier.DidRangeBeaconsInRegionComplete -= RangingBeaconsInRegion;

                _iBeaconManager.StopRangingBeaconsInRegion (_rangingRegion);
                _iBeaconManager.UnBind (this);

                livecard.Unpublish();
                livecard = null;
            }
            base.OnDestroy();
        }
Example #6
0
        public override void OnDestroy()
        {
            if (livecard != null && livecard.IsPublished)
            {
                _rangeNotifier.DidRangeBeaconsInRegionComplete -= RangingBeaconsInRegion;

                _iBeaconManager.StopRangingBeaconsInRegion(_rangingRegion);
                _iBeaconManager.UnBind(this);

                livecard.Unpublish();
                livecard = null;
            }
            base.OnDestroy();
        }
Example #7
0
        public override void OnDestroy()
        {
            Log.Debug(TAG, "OnDestroy Xamarin Stopwatch");
            if (liveCard != null && liveCard.IsPublished)
            {
                Log.Debug(TAG, "Unpublishing LiveCard");
                if (callback != null)
                {
                    liveCard.SurfaceHolder.RemoveCallback(callback);
                }
                liveCard.Unpublish();
                liveCard = null;
            }

            base.OnDestroy();
        }
Example #8
0
        public override void OnDestroy()
        {
            if (_renderer != null)
            {
                _renderer.stop();
                _renderer = null;
            }

            if (_card != null && _card.IsPublished)
            {
                _card.Unpublish();
                _card = null;
            }

            base.OnDestroy();
        }
Example #9
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (_card == null)
            {
                _card = new LiveCard(Application, "remoteviewservice");
                _remoteViews = new Android.Widget.RemoteViews(PackageName, Resource.Layout.MainLayout);
                _remoteViews.SetTextViewText(Resource.Id.LivecardContent, "HI From Remote View!");
                _card.SetViews(_remoteViews);

                var menuIntent = new Intent(this, typeof(MenuActivity));
                menuIntent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                _card.SetAction(PendingIntent.GetActivity(this, 0, menuIntent, 0));
                _card.Publish(LiveCard.PublishMode.Reveal);
            }

            return StartCommandResult.Sticky;

        }
Example #10
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (livecard == null)
            {
                livecard    = new LiveCard(Application, "beacon");
                remoteViews = new RemoteViews(PackageName, Resource.Layout.LiveCardBeacon);
                remoteViews.SetTextViewText(Resource.Id.LivecardContent, "Finding the monkey...");
                livecard.SetViews(remoteViews);

                // Set up the live card's action with a pending intent
                // to show a menu when tapped
                var menuIntent = new Intent(this, typeof(MenuActivity));
                menuIntent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                livecard.SetAction(PendingIntent.GetActivity(this, 0, menuIntent, 0));
                livecard.Publish(LiveCard.PublishMode.Reveal);
            }
            return(StartCommandResult.Sticky);
        }
Example #11
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (liveCard == null)
            {
                Log.Debug(TAG, "Publishing LiveCard");
                liveCard = timelineManager.CreateLiveCard(LIVE_CARD_ID);

                // Keep track of the callback to remove it before unpublishing.
                callback = new ChronometerDrawer(this);
                liveCard.SetDirectRenderingEnabled(true).SurfaceHolder.AddCallback(callback);

                Intent menuIntent = new Intent(this, typeof(MenuActivity));
                liveCard.SetAction(PendingIntent.GetActivity(this, 0, menuIntent, 0));

                liveCard.Publish(LiveCard.PublishMode.Reveal);
                Log.Debug(TAG, "Done publishing LiveCard");
            }
            else
            {
                // TODO(alainv): Jump to the LiveCard when API is available.
            }

            return(StartCommandResult.Sticky);
        }
Example #12
0
 private bool ensureLiveCard(GlassShowViewModelMessage request)
 {
     if (_liveCard == null)
     {
         _liveCard = new LiveCard(request.SenderAsService, request.SenderAsService.GetType().Name);
         _liveCard.Attach(request.SenderAsService);
         return true;
     }
     return false;
 }
Example #13
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (livecard == null)
            {
                livecard = new LiveCard (Application, "beacon");
                remoteViews = new RemoteViews (PackageName, Resource.Layout.LiveCardBeacon);
                remoteViews.SetTextViewText (Resource.Id.LivecardContent, "Finding the monkey...");
                livecard.SetViews (remoteViews);

                // Set up the live card's action with a pending intent
                // to show a menu when tapped
                var menuIntent = new Intent(this, typeof(MenuActivity));
                menuIntent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                livecard.SetAction(PendingIntent.GetActivity(this, 0, menuIntent, 0));
                livecard.Publish (LiveCard.PublishMode.Reveal);

            }
            return StartCommandResult.Sticky;
        }