コード例 #1
0
        protected override void OnDisappearing()
        {
            base.OnDisappearing();

            _calcTimer?.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
            _calcTimer?.Dispose();

            REnv.SaveValue();
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
ファイル: ResinSimpleEdit.cs プロジェクト: URK96/ResinTimer
        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);
            }
        }
コード例 #4
0
        private void ApplyButtonClicked(object sender, EventArgs e)
        {
            if (CurrentPage.Title == AppResources.EditPage_TabTime_Title)
            {
                REnv.ManualApplyType = REnv.ApplyType.Time;
            }
            else if (CurrentPage.Title == AppResources.EditPage_TabResin_Title)
            {
                REnv.ManualApplyType = REnv.ApplyType.Resin;
            }

            switch (REnv.ManualApplyType)
            {
            case REnv.ApplyType.Time:
                SetTimeValue();
                break;

            case REnv.ApplyType.Resin:
                SetResinValue();
                break;

            default:
                break;
            }

            REnv.LastInputTime = DateTime.Now.ToString(AppEnv.DTCulture);

            CalcRemainTime();

            REnv.SaveValue();

            if (Preferences.Get(SettingConstants.NOTI_ENABLED, false))
            {
                ResinNotiManager notiManager = new();

                notiManager.UpdateNotisTime();
                notiManager.UpdateScheduledNoti <ResinNoti>();
            }

            Navigation.PopAsync();
        }