private void DataSetWS_GetPeriodicDataCompleted(object sender, MobileAppPozitiv.GetPeriodicDataCompletedEventArgs e) { if (e.Error == null) { if (e.Cancelled) { } else { int itemCount = 0; JObject jsonPeriodicDataResult = JObject.Parse(e.Result); JProperty jItemCount; if ((jItemCount = jsonPeriodicDataResult.Property("ItemCount")) != null) { itemCount = (int)jItemCount.Value; } Log.Info(typeof(AppReceiverAlarm).Name, "Update task count. {0} - count {1}", DateTime.UtcNow, itemCount); ShortcutBadger.ApplyCount(context, itemCount); } } else { Log.Error(typeof(AppPeriodic).Name, "Error update task count. {0}", DateTime.UtcNow); } }
protected override void SetBadgeNumberInternal(int badgeNumber) { if (_appContext != null) { var result = ShortcutBadger.ApplyCount(_appContext, badgeNumber); Logger.Debug($"Badge count {badgeNumber} was" + (!result ? "NOT" : string.Empty) + "set"); } }
private void Button_Click(object sender, System.EventArgs e) { if (int.TryParse(_numInput.Text, out int badgeCount)) { bool success = ShortcutBadger.ApplyCount(this, badgeCount); Toast.MakeText(ApplicationContext, "Set count=" + badgeCount + ", success=" + success, ToastLength.Short) .Show(); } else { Toast.MakeText(ApplicationContext, "Error input", ToastLength.Short) .Show(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); var editText = FindViewById <EditText>(Resource.Id.badgeValue); var button = FindViewById <Button>(Resource.Id.updateButton); button.Click += delegate { var count = int.Parse(editText.Text); ShortcutBadger.ApplyCount(this, count); }; }
public override void OnCreate() { base.OnCreate(); if (ShortcutBadger.IsBadgeCounterSupported(this)) { if (MainActivity.isActivityActive) { badgeCount = 0; } else { badgeCount += 1; } ShortcutBadger.ApplyCount(this, badgeCount); } }
public void UpdateList() { items = new List <DataGroups>(); DataSetWS dataSetWS = new DataSetWS(); string AllowGroupsResult = string.Empty; try { AllowGroupsResult = dataSetWS.GetGroups(); } catch (Exception e) { mContext.RunOnUiThread(() => { Toast.MakeText(mContext, e.Message, ToastLength.Long).Show(); return; }); return; } JObject jsonResult = JObject.Parse(AllowGroupsResult); items.Add(new DataGroups() { Name = "Главная страница", Description = "Новости", Image = Resource.Drawable.Main, Ref = "", ItemCount = String.Empty }); items.Add(new DataGroups() { Name = "Сообщения", Description = "", Image = Resource.Drawable.Messages, Ref = "", ItemCount = String.Empty }); int totalItemCount = 0; foreach (JObject Group in jsonResult["Data"]) { string Name = (string)(Group.Property("Name").Value); string Ref = (string)(Group.Property("Ref").Value); string ItemCount = Group.Property("ItemCount") == null ? String.Empty : (string)(Group.Property("ItemCount").Value); totalItemCount += Group.Property("ItemCount") == null ? 0 : Convert.ToInt16((string)(Group.Property("ItemCount").Value)); int imageId = 0; switch (Name) { case "Задачи": imageId = Resource.Drawable.Tasks; break; case "Справочники": imageId = Resource.Drawable.Directories; break; case "Документы": imageId = Resource.Drawable.Documents; break; case "Обработки": imageId = Resource.Drawable.DataProcessor; break; case "Отчеты": imageId = Resource.Drawable.Reports; break; case "Прочее": imageId = Resource.Drawable.Other; break; } items.Add(new DataGroups() { Name = Name, Description = "", Image = imageId, Ref = Ref, ItemCount = ItemCount }); } ShortcutBadger.ApplyCount(mContext, totalItemCount); }
/// <summary> /// Set the badge number /// </summary> /// <param name="number">the badge number</param> public void SetBadge(int number) { ShortcutBadger.ApplyCount(Forms.Context, number); }
protected override void OnStart() { base.OnStart(); isActivityActive = true; ShortcutBadger.ApplyCount(this, 0); }