protected override void OnDestroy() { base.OnDestroy(); if (this.DoFinish) { m_SetStatusUI.Dispose(); m_SetStatusUI = null; m_UpdateAmplitude.Dispose(); m_UpdateAmplitude = null; SimpleIoc.Default.GetInstance <ITurnOnOffScreen>().TurnOn(); SimpleIoc.Default.GetInstance <ITurnOnOffScreen>().Dispose(); SimpleIoc.Default.GetInstance <ICallNumber>().Dispose(); SimpleIoc.Default.GetInstance <IForceHangup>().Dispose(); SimpleIoc.Default.GetInstance <ReadContacts>().OnFinished -= ReadContactsFinished; MainViewModel babyPhoneViewModel = SimpleIoc.Default.GetInstance <MainViewModel>(); babyPhoneViewModel.PeriodicNotifications -= MainActivity_PeriodicNotifications; babyPhoneViewModel.Dispose(); Button chooseContactButton = FindViewById <Button>(Resource.Id.ChooseContactButton); chooseContactButton.Click -= chooseContactButton_Click; Button startServiceButton = FindViewById <Button>(Resource.Id.ServiceButton); startServiceButton.Click -= startServiceButton_Click; Button noiseLevelButton = FindViewById <Button>(Resource.Id.NoiseLevelButton); noiseLevelButton.Click -= noiseLevelButton_Click; TextView numberToDial = FindViewById <TextView>(Resource.Id.ContactTextView); numberToDial.TextChanged -= numberToDial_TextChanged; TextView noiseLevel = FindViewById <TextView>(Resource.Id.NoiseLevelTextView); noiseLevel.TextChanged -= noiseLevel_TextChanged; SimpleIoc.Default.Reset(); } }
private void InitializeUI() { Settings settings = SimpleIoc.Default.GetInstance <bleissem.babyphone.Settings>(); string setNumber = this.Intent.GetStringExtra(IntentFactory.SetIdToCall); if (!string.IsNullOrWhiteSpace(setNumber)) { settings.NumberToDial = setNumber; } int callType = this.Intent.GetIntExtra(IntentFactory.SetCallType, -1); if (0 < callType) { settings.CallType = (SettingsTable.CallTypeEnum)callType; } { m_UpdateAmplitude = new ExecuteGenericAction <double>((amp) => { TextView textView = FindViewById <TextView>(Resource.Id.AmpTextView); textView.Text = amp.ToString(); }); } { m_SetStatusUI = new ExecuteGenericAction <bool>( (babyphoneSleeps) => { Button startServiceButton = FindViewById <Button>(Resource.Id.ServiceButton); Button chooseContactButton = FindViewById <Button>(Resource.Id.ChooseContactButton); TextView numberToDial = FindViewById <TextView>(Resource.Id.ContactTextView); TextView ampTextView = FindViewById <TextView>(Resource.Id.AmpTextView); Button noiseLevelButton = FindViewById <Button>(Resource.Id.NoiseLevelButton); startServiceButton.Enabled = !babyphoneSleeps; numberToDial.Enabled = !babyphoneSleeps; ampTextView.Enabled = !babyphoneSleeps; chooseContactButton.Enabled = !babyphoneSleeps; noiseLevelButton.Enabled = !babyphoneSleeps; TextView babyPhoneSleepsTextView = FindViewById <TextView>(Resource.Id.StatusTextView); string status = string.Empty; if (babyphoneSleeps) { status = this.ApplicationContext.Resources.GetText(Resource.String.StatusTextSleeping); } else { status = this.ApplicationContext.Resources.GetText(Resource.String.StatusTextNothing); } babyPhoneSleepsTextView.Text = status; }); } { MainViewModel babyViewModel = SimpleIoc.Default.GetInstance <MainViewModel>(); babyViewModel.PeriodicNotifications -= MainActivity_PeriodicNotifications; babyViewModel.PeriodicNotifications += MainActivity_PeriodicNotifications; Button chooseContactButton = FindViewById <Button>(Resource.Id.ChooseContactButton); chooseContactButton.Enabled = false | chooseContactButton.Enabled; chooseContactButton.Click -= chooseContactButton_Click; chooseContactButton.Click += chooseContactButton_Click; Button noiseLevelButton = FindViewById <Button>(Resource.Id.NoiseLevelButton); noiseLevelButton.Click -= noiseLevelButton_Click; noiseLevelButton.Click += noiseLevelButton_Click; Button startServiceButton = FindViewById <Button>(Resource.Id.ServiceButton); startServiceButton.Text = startServiceButton.Text = this.ApplicationContext.Resources.GetText(Resource.String.StartService); startServiceButton.Click -= startServiceButton_Click; startServiceButton.Click += startServiceButton_Click; TextView numberToDial = FindViewById <TextView>(Resource.Id.ContactTextView); numberToDial.Text = settings.NumberToDial; numberToDial.TextChanged -= numberToDial_TextChanged; numberToDial.TextChanged += numberToDial_TextChanged; TextView youreUsing = FindViewById <TextView>(Resource.Id.YouAreUsingTextView); youreUsing.Text = this.ConvertCallType(settings.CallType); TextView noiseLevel = FindViewById <TextView>(Resource.Id.NoiseLevelTextView); noiseLevel.Text = settings.NoiseLevel.ToString(); noiseLevel.TextChanged -= noiseLevel_TextChanged; noiseLevel.TextChanged += noiseLevel_TextChanged; } }