protected override void OnCreate(Bundle bundle) { //SetTheme(Resource.Style.Theme_Custom); base.OnCreate(bundle); //#if DEBUG // var vmPolicy = new StrictMode.VmPolicy.Builder(); // StrictMode.SetVmPolicy(vmPolicy.DetectActivityLeaks().PenaltyLog().Build()); //#endif try { _needWeatherUpdate = true; if (bundle == null) { Log.Debug("OnCreate"); } //SetTitle(Resource.String.WeatherTitle); SetContentView(Resource.Layout.activity_main); _menu = FindViewById(Resource.Id.tlbMenu); _drawerLayout = FindViewById <DrawerLayout>(Resource.Id.viewDrawerLayout); _progressBar = FindViewById <ProgressBar>(Resource.Id.spLoading); _txtLocation = FindViewById <TextView>(Resource.Id.txtLocation); _txtLocation?.SetOnClickListener(new ClickListener(view => { if (_tooltipWindow != null && !_tooltipWindow.IsDisposed && !_tooltipWindow.IsTooltipShown && (_tooltipWindow.TooltipText?.Length > 0 || _tooltipWindow.TooltipTextFormatted?.Length() > 0)) { _tooltipWindow.ShowToolTip(view); } })); CheckActionAppwidGetConfigure(Intent); _imgAlert = FindViewById <ImageView>(Resource.Id.imgAlert); SetAlertInvisible(); _menuFragment = CreateMenuFragment(); _contentFragment = CreateContentFragment(); using (var ft = FragmentManager.BeginTransaction()) { ft.Replace(Resource.Id.viewMenu, _menuFragment); ft.Replace(Resource.Id.viewContent, _contentFragment); ft.Commit(); } _cancellationTokenSource = new CancellationTokenSource(); } catch (Exception ex) { Log.Error(ex); } }
protected override void OnDestroy() { try { UnsubscribeEvents(); if (_cancellationTokenSource != null) { _cancellationTokenSource.Cancel(); _cancellationTokenSource.Dispose(); _cancellationTokenSource = null; } _selectedWidgetId = null; _widgetId = null; _serviceConnection?.Dispose(); _serviceConnection = null; _serviceReceiver?.Dispose(); _serviceReceiver = null; if (_menuFragment != null) { _menuFragment.OptionMenuClickHandler = null; } _menuFragment?.Dispose(); _menuFragment = null; _contentFragment?.Dispose(); _contentFragment = null; TooltipWindowDispose(); } catch (Exception ex) { Log.Debug(ex); } AppSettings.GcCollect(); //HARDCODE: base.OnDestroy(); AppSettings.GcCollect(true, Log); //HARDCODE: }
private WeatherContentFragment CreateContentFragment() { var fragment = new WeatherContentFragment(); return(fragment); }