private void OnDispose() { UnsubscribeEvents(); _root = null; _currentParent = null; _doNotCancel = false; _selectedItem = null; _documentsProvider?.Dispose(); _documentsProvider = null; _previousParents?.Clear(); _previousParents = null; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_file_browser); //Toolbar will now take on default actionbar characteristics var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = string.Empty; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); try { _showCreateFolderMenu = false; _orderBy = FileDocumentItemSortOrders.Default; // documents provider _documentsProvider = new FileDocumentsProvider(); _documentsProvider.AttachInfo(this, CreateProviderInfo(string.Format("{0}.{1}", AppSettings.AppPackageName, _documentsProvider.GetType().Name.ToLower()))); //HARDCODE: // root GetRoot(); if (string.IsNullOrEmpty(_root?.DocumentId)) { throw new ArgumentNullException(nameof(_root)); } // stack _previousParents = new Stack <string>(); // start parameters var displayName = Intent.GetStringExtra(Intent.ExtraTitle); var mimeType = Intent.Type; var isCategoryOpenable = Intent.Categories?.Contains(Intent.CategoryOpenable) == true; var action = Intent?.Action; // end parameters var statusBar = FindViewById(Resource.Id.statusBar); _imgNewFileName = FindViewById <ImageView>(Resource.Id.imgNewFileName); _txtNewFileName = FindViewById <EditText>(Resource.Id.txtNewFileName); _btnAction = FindViewById <Button>(Resource.Id.btnAction); _viewProgressbar = FindViewById(Resource.Id.toolbarProgress); switch (action) { case Intent.ActionCreateDocument: _showCreateFolderMenu = true; if (_imgNewFileName != null) { _imgNewFileName.SetImageResource(Resource.Drawable.ic_file); _imgNewFileName.Visibility = ViewStates.Visible; } if (_txtNewFileName != null) { _txtNewFileName.Text = displayName ?? string.Empty; _txtNewFileName.Visibility = ViewStates.Visible; } if (_btnAction != null) { _btnAction.SetText(Resource.String.Save); _btnAction.LayoutParameters.Width = ViewGroup.LayoutParams.WrapContent; } _mimeType = mimeType; _isCategoryOpenable = isCategoryOpenable; break; case Intent.ActionOpenDocumentTree: _isActionOpenDocumentTree = true; _showCreateFolderMenu = true; if (_imgNewFileName != null) { _imgNewFileName.Visibility = ViewStates.Gone; } if (_txtNewFileName != null) { _txtNewFileName.Visibility = ViewStates.Gone; } if (_btnAction != null) { _btnAction.LayoutParameters.Width = ViewGroup.LayoutParams.MatchParent; } break; default: if (statusBar != null) { statusBar.Visibility = ViewStates.Gone; } _imgNewFileName?.Dispose(); _imgNewFileName = null; _txtNewFileName?.Dispose(); _txtNewFileName = null; _btnAction?.Dispose(); _btnAction = null; _mimeType = mimeType; _isCategoryOpenable = isCategoryOpenable; break; } if (savedInstanceState == null) { var searchQuery = Intent.GetStringExtra(ExtraSearchQuery); var taskType = string.IsNullOrEmpty(searchQuery) ? FileBrowserFragment.DocumentTaskTypes.QueryChildDocuments : FileBrowserFragment.DocumentTaskTypes.QuerySearchDocuments; ReplaceFragment(isAdd: true, useCustomAnimation: false, taskType: taskType, query: searchQuery); } } catch (Exception ex) { Log.Error(ex); Toast.MakeText(this, GetString(Resource.String.InternalError), AppSettings.ToastLength).Show(); } }