void SwitchToMode(bool animated) { var b = View.Bounds; var oldView = docsView; var oldPreview = docsPreview; if (oldView != null) { oldView.SortChanged -= HandleSortChanged; oldView.SelectedDocuments.CollectionChanged -= HandleSelectedDocumentsChanged; oldView.RenameRequested -= HandleRenameRequested; if (ios9 && oldPreview != null) { UnregisterForPreviewingWithContext(oldPreview); } } var newView = viewMode == DocumentsViewMode.List ? (IDocumentsView) new DocumentListView(b) : (IDocumentsView) new DocumentThumbnailsView(b); docsView = newView; docsView.IsSyncing = IsSyncing; docsView.Items = items; docsView.Sort = DocumentAppDelegate.Shared.Settings.DocumentsSort; docsView.SortChanged += HandleSortChanged; docsView.SelectedDocuments.CollectionChanged += HandleSelectedDocumentsChanged; docsView.RenameRequested += HandleRenameRequested; var longPress = new UILongPressGestureRecognizer(HandleLongPress) { MinimumPressDuration = 0.5, }; View = (UIView)newView; View.AddGestureRecognizer(longPress); if (ios9) { docsPreview = RegisterForPreviewingWithDelegate(this, View); } }
void SwitchToMode (bool animated) { var b = View.Bounds; var oldView = docsView; var oldPreview = docsPreview; if (oldView != null) { oldView.SortChanged -= HandleSortChanged; oldView.SelectedDocuments.CollectionChanged -= HandleSelectedDocumentsChanged; oldView.RenameRequested -= HandleRenameRequested; if (ios9 && oldPreview != null) { UnregisterForPreviewingWithContext (oldPreview); } } var newView = viewMode == DocumentsViewMode.List ? (IDocumentsView)new DocumentListView (b) : (IDocumentsView)new DocumentThumbnailsView (b); docsView = newView; docsView.IsSyncing = IsSyncing; docsView.Items = items; docsView.Sort = DocumentAppDelegate.Shared.Settings.DocumentsSort; docsView.SortChanged += HandleSortChanged; docsView.SelectedDocuments.CollectionChanged += HandleSelectedDocumentsChanged; docsView.RenameRequested += HandleRenameRequested; var longPress = new UILongPressGestureRecognizer (HandleLongPress) { MinimumPressDuration = 0.5, }; View = (UIView)newView; View.AddGestureRecognizer (longPress); if (ios9) { docsPreview = RegisterForPreviewingWithDelegate (this, View); } }