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

            UnregisterReceiver(timerBraodcast);
            timerBraodcast.TimerStarted      -= Receiver_TimeStarted;
            timerBraodcast.TimeChanged       -= Receiver_TimeChanged;
            timerBraodcast.CountdownFinished -= Receiver_CountdownFinished;
            timerBraodcast.Dispose();
            timerBraodcast = null;
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            var themeId = Preferences.Get("theme", 0);

            if (themeId > 0)
            {
                SetTheme(themeId);
            }

            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            #region bind controls
            rootLayout          = FindViewById <RelativeLayout>(Resource.Id.rootLayout);
            more                = FindViewById <ImageButton>(Resource.Id.more);
            more.Click         += More_Click;
            water               = FindViewById <ImageView>(Resource.Id.water);
            wave1               = FindViewById <ImageView>(Resource.Id.wave1);
            wave2               = FindViewById <ImageView>(Resource.Id.wave2);
            wave3               = FindViewById <ImageView>(Resource.Id.wave3);
            wave4               = FindViewById <ImageView>(Resource.Id.wave4);
            remainingPercentTxt = FindViewById <TextView>(Resource.Id.remainingPercentTxt);
            timerPrev           = FindViewById <TextView>(Resource.Id.timerPrev);
            timerCurr           = FindViewById <TextView>(Resource.Id.timerCurr);
            timerNext           = FindViewById <TextView>(Resource.Id.timerNext);
            timerLayout         = FindViewById <RelativeLayout>(Resource.Id.timerLayout);
            timerCurr.Post(() =>
            {
                timerTextHeight = timerCurr.Height;
            });
            timerLayout.RemoveAllViews();
            reset        = FindViewById <Button>(Resource.Id.reset);
            reset.Click += Reset_Click;
            originalText = reset.Text;
            #endregion

            #region build animators
            waterAnimator = new WaterAnimator(water, wave1, wave2, wave3, wave4, Resources);
            water.Post(() =>
            {
                waterAnimator.Build();
            });
            beatAnimator = new BeatAnimator(remainingPercentTxt);
            beatAnimator.Build();
            #endregion

            #region  initialize services
            timerService   = new Intent(this, typeof(TimerService));
            timerBraodcast = new TimerBroadcastReceiver();
            timerBraodcast.TimerStarted      += Receiver_TimeStarted;
            timerBraodcast.TimeChanged       += Receiver_TimeChanged;
            timerBraodcast.CountdownFinished += Receiver_CountdownFinished;
            RegisterReceiver(timerBraodcast, new IntentFilter("com.kudchikarsk.remindme.timer"));
            #endregion

            var start = Intent.GetBooleanExtra("start", false);
            if (start)
            {
                StartTimerService();
                reset.Text = originalText;
            }
        }