|
@@ -31,6 +31,8 @@ class CommunityVideoListController: BaseViewController {
|
|
|
|
|
|
private var prePlayCell: CommunityVideoCoverCollectionCell?
|
|
|
|
|
|
+ private var videoListMdl: CommunityVideoListModel?
|
|
|
+
|
|
|
deinit {
|
|
|
if observe != nil {
|
|
|
NotificationCenter.default.removeObserver(observe!)
|
|
@@ -113,9 +115,11 @@ class CommunityVideoListController: BaseViewController {
|
|
|
override func setupData() {
|
|
|
self.communityVideoListApi()
|
|
|
|
|
|
- collectionView.addFooterWithWithHeader(withAutomaticallyRefresh: false) {
|
|
|
+ collectionView.addFooterWithWithHeader(withAutomaticallyRefresh: true) {
|
|
|
[weak self] (page) in
|
|
|
- self?.communityVideoListApi(page:page)
|
|
|
+ if page <= self?.videoListMdl?.pagination?.totalPages ?? 1 {
|
|
|
+ self?.communityVideoListApi(page:page)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -326,20 +330,22 @@ extension CommunityVideoListController {
|
|
|
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?.videoListMdl = communityVideoListModel as? CommunityVideoListModel
|
|
|
+ self?.videoItemList = self?.videoListMdl?.data
|
|
|
self?.collectionView.reloadData()
|
|
|
|
|
|
- if videoListMdl?.pagination?.currentPage ?? 1 <= videoListMdl?.pagination?.totalPages ?? 1 {
|
|
|
- if videoListMdl?.pagination?.currentPage == 1{
|
|
|
+ if self?.videoListMdl?.pagination?.currentPage ?? 1 <= self?.videoListMdl?.pagination?.totalPages ?? 1 {
|
|
|
+ if self?.videoListMdl?.pagination?.currentPage == 1{
|
|
|
self?.videoItemList?.removeAll()
|
|
|
}
|
|
|
- self?.videoItemList = (self?.videoItemList)! + (videoListMdl?.data!)!
|
|
|
+ self?.videoItemList = (self?.videoItemList)! + (self?.videoListMdl?.data!)!
|
|
|
self?.collectionView.reloadData()
|
|
|
- if self?.videoItemList?.count ?? 0 >= videoListMdl?.pagination?.total ?? 0 {
|
|
|
+ if self?.videoListMdl?.pagination?.currentPage ?? 1 >= self?.videoListMdl?.pagination?.totalPages ?? 1 {
|
|
|
+ self?.collectionView.endFooterNoMoreData()
|
|
|
self?.collectionView.isHiddenFooter(true)
|
|
|
}
|
|
|
}else {
|
|
|
+ self?.collectionView.endFooterNoMoreData()
|
|
|
self?.collectionView.isHiddenFooter(true)
|
|
|
}
|
|
|
|