NCActivityIndicator.swift 897 B

1234567891011121314151617181920212223242526
  1. //
  2. // SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. //
  5. import UIKit
  6. @objcMembers class NCActivityIndicator: MDCActivityIndicator {
  7. override func willMove(toWindow newWindow: UIWindow?) {
  8. // Debounce the original implementation of the MDCActivityIndicator
  9. // When showing a view animated, willMove(toWindow:) is called twice, therefore
  10. // we debounce it so that the animation does not start from the beginning again
  11. if newWindow == nil {
  12. DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
  13. if self.window == nil {
  14. // Still not moved to a window, so we stop the animation
  15. super.willMove(toWindow: nil)
  16. }
  17. }
  18. } else {
  19. super.willMove(toWindow: newWindow)
  20. }
  21. }
  22. }