VLCMediaData+VLCDragAndDrop.swift 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*****************************************************************************
  2. * VLCMediaData+VLCDragAndDrop.swift
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2017 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Carola Nitz <caro # videolan.org>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. import Foundation
  13. @available(iOS 11.0, *)
  14. extension VLCMediaDataSource: VLCDragAndDropManagerDelegate {
  15. func dragAndDropManagerRequestsFile(manager: VLCDragAndDropManager, atIndexPath indexPath: IndexPath) -> AnyObject? {
  16. if !(indexPath.row < numberOfFiles()) {
  17. return nil
  18. }
  19. return object(at: UInt(indexPath.row))
  20. }
  21. func dragAndDropManagerInsertItem(manager: VLCDragAndDropManager, item: NSManagedObject, atIndexPath indexPath: IndexPath) {
  22. if item as? MLLabel != nil && indexPath.row < numberOfFiles() {
  23. removeObject(at: UInt(indexPath.row))
  24. }
  25. insert(item, at: UInt(indexPath.row))
  26. }
  27. func dragAndDropManagerDeleteItem(manager: VLCDragAndDropManager, atIndexPath indexPath: IndexPath) {
  28. if !(indexPath.row < numberOfFiles()) {
  29. return
  30. }
  31. removeObject(at: UInt(indexPath.row))
  32. }
  33. func dragAndDropManagerCurrentSelection(manager: VLCDragAndDropManager) -> AnyObject? {
  34. return currentSelection()
  35. }
  36. func dragAndDropManagerRemoveFileFromFolder(manager: VLCDragAndDropManager, file: NSManagedObject) {
  37. return removeMediaObject(fromFolder: file)
  38. }
  39. }