|
@@ -81,38 +81,58 @@ class CommunityVideoListController: BaseViewController {
|
|
|
}
|
|
|
|
|
|
override func setupViews() {
|
|
|
-
|
|
|
- self.view.addSubview(collectionView)
|
|
|
- let emptyView = DIYEmptyView.empty(with: kImage(name: "default_page_data"), titleStr: nil, detailStr: "当前暂无数据")
|
|
|
- emptyView!.contentViewY = kScaleValue(value: 182)
|
|
|
- collectionView.ly_emptyView = emptyView
|
|
|
- collectionView.ly_startLoading()
|
|
|
+ view.backgroundColor = UIColor.black
|
|
|
+ self.view.addSubview(collectionView)
|
|
|
collectionView.snp.makeConstraints { (make) in
|
|
|
make.top.equalTo(0)
|
|
|
make.left.right.bottom.equalToSuperview()
|
|
|
}
|
|
|
+ if #available(iOS 11.0, *) {
|
|
|
+ UIScrollView.appearance().contentInsetAdjustmentBehavior = .never
|
|
|
+ } else {
|
|
|
+ if self.responds(to: #selector(setter: self.automaticallyAdjustsScrollViewInsets)) {
|
|
|
+ self.automaticallyAdjustsScrollViewInsets = false
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
override func setupData() {
|
|
|
- collectionView.addHeaderWithHeader(withBeginRefresh: true, animation: false) { [weak self] (page) in
|
|
|
- self?.communityVideoListApi()
|
|
|
+ self.communityVideoListApi()
|
|
|
+
|
|
|
+ collectionView.addFooterWithWithHeader(withAutomaticallyRefresh: true) {
|
|
|
+ [weak self] (page) in
|
|
|
+ self?.communityVideoListApi(page:page)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// 视频列表
|
|
|
- func communityVideoListApi() {
|
|
|
- SwiftMoyaNetWorkServiceCommunity.shared().communityVideoListApi(id: contentId ?? 0) {
|
|
|
+ func communityVideoListApi(page:Int = 1) {
|
|
|
+ SwiftMoyaNetWorkServiceCommunity.shared().communityVideoListApi(id: contentId ?? 0, page:page) {
|
|
|
[weak self] (communityVideoListModel) -> (Void) in
|
|
|
let videoListMdl = communityVideoListModel as? CommunityVideoListModel
|
|
|
self?.videoItemList = videoListMdl?.data
|
|
|
self?.collectionView.reloadData()
|
|
|
+
|
|
|
+ if videoListMdl?.pagination?.currentPage ?? 1 <= videoListMdl?.pagination?.totalPages ?? 1 {
|
|
|
+ if videoListMdl?.pagination?.currentPage == 1{
|
|
|
+ self?.videoItemList?.removeAll()
|
|
|
+ }
|
|
|
+ self?.videoItemList = (self?.videoItemList)! + (videoListMdl?.data!)!
|
|
|
+ self?.collectionView.reloadData()
|
|
|
+ if self?.videoItemList?.count ?? 0 >= videoListMdl?.pagination?.total ?? 0 {
|
|
|
+ self?.collectionView.isHiddenFooter(true)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ self?.collectionView.isHiddenFooter(true)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private lazy var collectionView: UICollectionView = {
|
|
|
let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
|
|
|
- collectionView.backgroundColor = kf7f8faColor
|
|
|
+ collectionView.backgroundColor = UIColor.black
|
|
|
collectionView.delegate = self;
|
|
|
collectionView.dataSource = self;
|
|
|
collectionView.isPagingEnabled = true
|
|
@@ -149,9 +169,6 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
let cell = CommunityVideoCoverCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
cell.videoItemMdl = videoItemList?[indexPath.row]
|
|
@@ -201,12 +218,13 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
|
|
|
- return CGSize(width: kScreenWidth, height: 10)
|
|
|
+ return CGSize(width: kScreenWidth, height: 0)
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
|
prePlayCell = cell as? CommunityVideoCoverCollectionCell
|
|
|
self.pauseCurrentVideo()
|
|
|
+ prePlayCell?.playStatusImageView.isHidden = true
|
|
|
}
|
|
|
|
|
|
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
|