Music_Player3/relax.offline.mp3.music/MP/Common/Base(公用基类)/Controllers/MP_LunchViewController.swift

135 lines
4.9 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// LunchViewController.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/3/27.
//
import UIKit
///
class MP_LunchViewController: UIViewController {
@IBOutlet weak var progressView: MP_Lunch_ProgressView!{
didSet{
progressView.layer.masksToBounds = true
}
}
//
private var timer:CADisplayLink!
//
private lazy var maxTimes:TimeInterval = 6
//
private lazy var currentTimes:TimeInterval = 0
//
private var completionBlock:(() -> Void)?
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .init(hex: "#000000")
timer = CADisplayLink(target: self, selector: #selector(timerActionClick(_ :)))
//
timer.preferredFramesPerSecond = 40
//线
timer.add(to: RunLoop.current, forMode: .common)
//
timer.isPaused = false
// self.completionBlock = {
// DispatchQueue.main.async {
// [weak self] in
// guard let self = self else {return}
// //
// timer.isPaused = true
// //
// accessAppdelegate.switch_positive()
// //
// MPPositive_BrowseLoadViewModel.shared.reloadBrowseLists()
// }
// }
}
deinit {
//
timer.invalidate()
timer = nil
NotificationCenter.default.removeObserver(self)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
//
requestTrackingAuthorization { idfa in
// if let idfa = idfa {
// print("IDFA: \(idfa)")
// StartManager.shared.idfaid = idfa
// print("Stored IDFA: \(StartManager.shared.idfaid ?? "N/A")")
// } else {
// print("IDFA is not available or tracking authorization denied.")
// }
}
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
MP_AnalyticsManager.shared.launch_pvAction()
}
//
@objc fileprivate func timerActionClick(_ link:CADisplayLink) {
if maxTimes > currentTimes {
//
currentTimes += 0.025
let value = currentTimes/maxTimes
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
//
progressView.setProgress(value)
}
}else {
//
timer.isPaused = true
MP_AnalyticsManager.shared.getOpenStatus { [weak self] open in
guard let self = self else {return}
if open {
//ip
MP_NetWorkManager.shared.requestIPInfo { statu in
if statu == true {
//b
print("BLog")
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
//
timer.isPaused = true
//
accessAppdelegate.switch_positive()
//
MPPositive_BrowseLoadViewModel.shared.reloadBrowseLists()
}
}else {
print("ALog")
//A
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
//
timer.isPaused = true
//
accessAppdelegate.switch_aSide()
}
}
}
}else {
print("ALog")
//A
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
//
timer.isPaused = true
//
accessAppdelegate.switch_aSide()
}
}
}
}
}
}