protected override void OnDisappearing() { base.OnDisappearing(); _updateTimer?.Change(Timeout.Infinite, Timeout.Infinite); _updateTimer?.Dispose(); NotiManager.SaveNotis(); }
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; } } }