NCTrash.swift 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // NCTrash.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 02/10/2018.
  6. // Copyright © 2018 Marino Faggiana. All rights reserved.
  7. //
  8. import Foundation
  9. class NCTrash: UIViewController {
  10. @IBOutlet fileprivate weak var collectionView: UICollectionView!
  11. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  12. var path = ""
  13. var itemHeight: CGFloat = 180
  14. override func viewDidLoad() {
  15. super.viewDidLoad()
  16. }
  17. override func viewWillAppear(_ animated: Bool) {
  18. super.viewWillAppear(animated)
  19. if path == "" {
  20. let userID = (appDelegate.activeUserID as NSString).addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlFragmentAllowed)
  21. path = k_dav + "/trashbin/" + userID! + "/trash/"
  22. }
  23. let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
  24. ocNetworking?.listingTrash(appDelegate.activeUrl, path:path, account: appDelegate.activeAccount, success: { (item) in
  25. NCManageDatabase.sharedInstance.deleteTrash(filePath: self.path)
  26. _ = NCManageDatabase.sharedInstance.addTrashs(item as! [tableTrash])
  27. }, failure: { (message, errorCode) in
  28. print("error " + message!)
  29. })
  30. }
  31. }