private void ResetTimer(Intent intent) { int id = intent.GetIntExtra("NotiId", -1); NotiManager.NotificationType type = (NotiManager.NotificationType)intent.GetIntExtra("NotiType", 0); NotiManager notiManager = type switch { NotiManager.NotificationType.Expedition => new ExpeditionNotiManager(), NotiManager.NotificationType.GatheringItem => new GatheringItemNotiManager(), NotiManager.NotificationType.Gadget => new GadgetNotiManager(), NotiManager.NotificationType.Furnishing => new FurnishingNotiManager(), NotiManager.NotificationType.Gardening => new GardeningNotiManager(), _ => null }; if ((notiManager is null) || (id == -1)) { return; } Noti noti = notiManager.Notis.Find(x => x.NotiId.Equals(id)); NotiScheduleAndroid.Cancel(noti); noti.UpdateTime(); notiManager.SaveNotis(); switch (type) { case NotiManager.NotificationType.Expedition: NotiScheduleAndroid.Schedule <ExpeditionNoti>(noti); break; case NotiManager.NotificationType.GatheringItem: NotiScheduleAndroid.Schedule <GatheringItemNoti>(noti); break; case NotiManager.NotificationType.Gadget: NotiScheduleAndroid.Schedule <GadgetNoti>(noti); break; case NotiManager.NotificationType.Furnishing: NotiScheduleAndroid.Schedule <FurnishingNoti>(noti); break; case NotiManager.NotificationType.Gardening: NotiScheduleAndroid.Schedule <GardeningNoti>(noti); break; default: break; } } }
public override async void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { base.OnUpdate(context, appWidgetManager, appWidgetIds); try { REnv.LoadValues(); if (REnv.IsSyncEnabled) { if (await SyncHelper.Update(SyncHelper.SyncTarget.Resin)) { REnv.SaveValue(); if (Preferences.Get(SettingConstants.NOTI_ENABLED, false)) { var notiManager = new ResinNotiManager(); var notiScheduleAndroid = new NotiScheduleAndroid(); if (notiManager.Notis.Count > 0) { notiManager.UpdateNotisTime(); notiScheduleAndroid.Cancel <ResinNoti>(); notiScheduleAndroid.Schedule <ResinNoti>(); } } } } REnv.CalcResin(); UpdateLayout(context, appWidgetManager, appWidgetIds); } catch { Toast.MakeText(context, Resources.AppResources.ResinWidget_UpdateFail, ToastLength.Short).Show(); } if (isClick) { Toast.MakeText(context, Resources.AppResources.ResinWidget_UpdateComplete, ToastLength.Short).Show(); isClick = false; } }