Exemple #1
0
        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
            }
        }
Exemple #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;
            }
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
 public void UpdateInfo()
 {
     REnv.CalcResin();
     REnv.CalcResinTime();
 }