Music_Player3/relax.offline.mp3.music/MP/Common/Base(公用基类)/Controllers/MP_LunchViewController.swift
2024-06-05 15:28:33 +08:00

136 lines
4.8 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 = 20
//线
timer.add(to: RunLoop.current, forMode: .common)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
[weak self] in
guard let self = self else {return}
requestTrackingAuthorization { idfa in
if let idfa = idfa {
print("用户同意授权-idfa:\(idfa)")
}
}
}
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")
self.completionBlock = {
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
self.completionBlock = {
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
//
timer.isPaused = true
//
accessAppdelegate.switch_aSide()
}
}
}
}
}else {
print("ALog")
//A
completionBlock = {
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
//
timer.isPaused = true
//
accessAppdelegate.switch_aSide()
}
}
}
}
//
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 viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
MP_AnalyticsManager.shared.launch_pvAction()
}
//
@objc fileprivate func timerActionClick(_ link:CADisplayLink) {
if maxTimes > currentTimes {
//
currentTimes += 0.05
let value = currentTimes/maxTimes
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
//
progressView.setProgress(value)
}
}else {
if completionBlock != nil {
completionBlock!()
}
}
}
}