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(); } } }
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; }
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; }