private void CalcTimeResin(object statusInfo) { try { if (REnv.EndTime >= DateTime.Now) { REnv.CalcResinTime(); REnv.CalcResin(); } else { REnv.TotalCountTime = new(); REnv.OneCountTime = new(); REnv.Resin = REnv.MaxResin; } MainThread.BeginInvokeOnMainThread(RefreshInfo); } catch (Exception ex) { #if DEBUG DependencyService.Get <IToast>().Show(ex.ToString()); #endif } }
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; } }
internal override void ApplyValue() { base.ApplyValue(); if (int.TryParse(SfUpDown.Text, out int inputValue)) { REnv.EndTime = REnv.EndTime.AddSeconds(REnv.OneRestoreInterval * (REnv.Resin - inputValue)); REnv.LastInputTime = DateTime.Now.ToString(AppEnv.DTCulture); REnv.CalcResin(); REnv.SaveValue(); notiManager.UpdateNotisTime(); notiManager.UpdateScheduledNoti <ResinNoti>(); } else { DependencyService.Get <IToast>().Show(AppResources.ValueEdit_ValueError_Message); } }
public void UpdateInfo() { REnv.CalcResin(); REnv.CalcResinTime(); }