修复详情页面视频被删除的闪退问题
This commit is contained in:
parent
0043d3de2d
commit
103a5ea064
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -398,33 +398,36 @@ 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 {
|
||||
self.detailModel = model
|
||||
self.reloadData { [weak self] in
|
||||
guard let self = self else { return }
|
||||
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 }
|
||||
|
||||
if let indexPath = indexPath, indexPath.row < (model.episodeList?.count ?? 0) {
|
||||
self.scrollToItem(indexPath: indexPath, animated: false)
|
||||
|
||||
if let indexPath = indexPath, indexPath.row < (model.episodeList?.count ?? 0) {
|
||||
self.scrollToItem(indexPath: indexPath, animated: false)
|
||||
|
||||
} else if let videoInfo = self.detailModel?.video_info {
|
||||
var row: Int?
|
||||
self.detailModel?.episodeList?.enumerated().forEach({
|
||||
if $1.id == videoInfo.id {
|
||||
row = $0
|
||||
}
|
||||
})
|
||||
if let row = row {
|
||||
self.scrollToItem(indexPath: .init(row: row, section: 0), animated: false)
|
||||
} else {
|
||||
self.scrollToItem(indexPath: .init(row: 0, section: 0), animated: false)
|
||||
} else if let videoInfo = self.detailModel?.video_info {
|
||||
var row: Int?
|
||||
self.detailModel?.episodeList?.enumerated().forEach({
|
||||
if $1.id == videoInfo.id {
|
||||
row = $0
|
||||
}
|
||||
})
|
||||
if let row = row {
|
||||
self.scrollToItem(indexPath: .init(row: row, section: 0), animated: false)
|
||||
} else {
|
||||
self.scrollToItem(indexPath: .init(row: 0, section: 0), animated: false)
|
||||
}
|
||||
} else {
|
||||
self.scrollToItem(indexPath: .init(row: 0, section: 0), animated: false)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user