修复详情页面视频被删除的闪退问题

This commit is contained in:
zeng 2025-07-09 09:58:08 +08:00
parent 0043d3de2d
commit 103a5ea064
5 changed files with 41 additions and 27 deletions

View File

@ -10,13 +10,11 @@ import UIKit
class SPVideoAPI: NSObject {
///
static func requestVideoDetail(videoId: String?, shortPlayId: String, activityId: String? = nil, completer: ((_ model: SPVideoDetailModel?) -> Void)?) {
static func requestVideoDetail(videoId: String?, shortPlayId: String, activityId: String? = nil, completer: ((_ model: SPVideoDetailModel?, _ code: Int?, _ msg: String?) -> Void)?) {
var parameters: [String : Any] = [
"short_play_id" : shortPlayId
]
// if let videoId = videoId {
// }
parameters["video_id"] = "0"
if let activityId = activityId {
parameters["activity_id"] = activityId
@ -26,9 +24,19 @@ class SPVideoAPI: NSObject {
param.method = .get
param.parameters = parameters
param.isLoding = true
param.isToast = false
SPNetwork.request(parameters: param) { (response: SPNetworkResponse<SPVideoDetailModel>) in
completer?(response.data)
if response.code == SPNetworkCodeSucceed {
} else if response.code == 10014 {
SPToast.show(text: "movia_no_short_found".localized)
} else {
SPToast.show(text: response.msg)
}
completer?(response.data, response.code, response.msg)
}
}

View File

@ -121,10 +121,11 @@ class SPNetwork: NSObject {
DispatchQueue.global().async {
let response: SPNetworkResponse<T> = _deserialize(data: tempData)
var response: SPNetworkResponse<T> = _deserialize(data: tempData)
DispatchQueue.main.async {
if response.code != SPNetworkCodeSucceed {
response.data = nil
if parameters.isToast {
SPToast.show(text: response.msg)
}

View File

@ -398,9 +398,14 @@ extension SPPlayerDetailViewController {
recommandTimer = nil
recommandTimer = Timer.scheduledTimer(timeInterval: 6, target: YYWeakProxy(target: self), selector: #selector(handleRecommandTimer), userInfo: nil, repeats: false)
SPVideoAPI.requestVideoDetail(videoId: videoId, shortPlayId: shortPlayId, activityId: activityId) { [weak self] model in
SPVideoAPI.requestVideoDetail(videoId: videoId, shortPlayId: shortPlayId, activityId: activityId) { [weak self] model, code, msg in
guard let self = self else { return }
if let model = model {
if code == 10014 {
self.navigationController?.popViewController(animated: true)
return
}
guard let model = model else { return }
self.detailModel = model
self.reloadData { [weak self] in
guard let self = self else { return }
@ -424,8 +429,6 @@ extension SPPlayerDetailViewController {
self.scrollToItem(indexPath: .init(row: 0, section: 0), animated: false)
}
}
}
}
}
}

View File

@ -75,8 +75,6 @@ class SPPlayerListViewController: SPViewController {
private(set) lazy var collectionView: SPCollectionView = {
let collectionView = SPCollectionView(frame: .zero, collectionViewLayout: collectionViewLayout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.isPagingEnabled = true
collectionView.showsVerticalScrollIndicator = false
collectionView.showsHorizontalScrollIndicator = false
@ -88,6 +86,7 @@ class SPPlayerListViewController: SPViewController {
deinit {
NotificationCenter.default.removeObserver(self)
self.collectionView.removeFromSuperview()
}
override func viewDidLoad() {
@ -101,6 +100,8 @@ class SPPlayerListViewController: SPViewController {
NotificationCenter.default.addObserver(self, selector: #selector(didBecomeActiveNotification), name: UIApplication.didBecomeActiveNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willResignActiveNotification), name: UIApplication.willResignActiveNotification, object: nil)
collectionView.delegate = self
collectionView.dataSource = self
sp_setupUI()
sp_addActio()

View File

@ -124,6 +124,7 @@
"movia_profile_Bonus" = "Bonus";
"movia_updatenowtitle" = "Discover a new version";
"movia_updatenow" = "Update Now";
"movia_no_short_found" = "No Short Found";
"movia_vip_alert_text_01" = "Short Drama VIP Exclusive";