public override void OnComplicationActivated(int complicationId, int type, ComplicationManager manager)
        {
            base.OnComplicationActivated(complicationId, type, manager);
            complicationIds.Add(complicationId);

            StartAlarm(App.Context);
        }
        public override void OnComplicationUpdate(int complicationId, int type, ComplicationManager manager)
        {
            Task.Run(async() =>
            {
                ComplicationData complicationData = null;

                if (Settings.WeatherLoaded)
                {
                    weather          = await GetWeather();
                    complicationData = BuildUpdate(type, weather);
                }

                if (complicationData != null)
                {
                    manager.UpdateComplicationData(complicationId, complicationData);
                    UpdateTime = DateTime.Now;
                }
                else
                {
                    // If no data is sent, we still need to inform the ComplicationManager, so
                    // the update job can finish and the wake lock isn't held any longer.
                    manager.NoUpdateRequired(complicationId);
                }

                // Add id to list in case it wasn't before
                if (complicationIds.Count == 0)
                {
                    complicationIds.Add(complicationId);
                    StartAlarm(App.Context);
                }
            });
        }
Example #3
0
        public override void OnComplicationUpdate(int complicationId, int dataType, ComplicationManager complicationManager)
        {
            Log($"OnComplicationUpdate dataType={dataType}");
            var num = new Random((int)Java.Lang.JavaSystem.CurrentTimeMillis()).Next(10, 75);
            ComplicationData complicationData = null;

            switch (dataType)
            {
            case ComplicationData.TypeShortText:
                Log($"OnComplicationUpdate dataType=ShortText");
                complicationData = new ComplicationData.Builder(ComplicationData.TypeShortText)
                                   .SetShortText(ComplicationText.PlainText($"Luck {num}"))
                                   .Build();
                break;

            default:
                Log($"Unexpected complication type {dataType}");
                break;
            }
            if (complicationData != null)
            {
                complicationManager.UpdateComplicationData(complicationId, complicationData);
            }
            else
            {
                complicationManager.NoUpdateRequired(complicationId);
            }
        }