예제 #1
0
        public ResinTimerPage()
        {
            InitializeComponent();

            BindingContext = this;

            REnv.OneCountTime   = new();
            REnv.TotalCountTime = new();

            REnv.LoadValues();

            if (Device.RuntimePlatform is not Device.UWP)
            {
                _buttonPressTimer = new(500)
                {
                    AutoReset = false
                };
                _buttonPressTimer.Elapsed += delegate
                {
                    _isRunQuickCalc = true;

                    if (Preferences.Get(SettingConstants.QUICKCALC_VIBRATION, true))
                    {
                        Vibration.Vibrate(100);
                    }

                    QuickCalc();
                };
            }

            if (REnv.IsSyncEnabled)
            {
                _ = SyncData();
            }
        }
예제 #2
0
        public ResinNoti(int resin)
        {
            NotiId   = Resin = resin;
            Interval = (REnv.MaxResin - Resin) * REnv.OneRestoreInterval;

            try
            {
                NotiTime = REnv.EndTime.AddSeconds(-Interval);
            }
            catch (Exception)
            {
                REnv.LoadValues();

                NotiTime = REnv.EndTime.AddSeconds(-Interval);
            }
        }
예제 #3
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;
            }
        }
예제 #4
0
 public ResinHomeItem()
 {
     REnv.LoadValues();
 }