123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- //
- // File.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/7/26.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import Foundation
- class MJRefreshManager: NSObject {
- //MARK: - tableView
- class func hiddenHeaderWithFooter(tableView : UITableView?) {
- if tableView?.mj_footer != nil {
- tableView?.endFooterRefresh()
- }
- if tableView?.mj_header != nil {
- tableView?.endHeaderRefresh()
- }
- tableView?.ly_endLoading()
- }
-
- class func hiddenHeaderWithFooterNONetWork(tableView : UITableView?) {
- DIYEmptyView.emptyNoDataActionTableView(tableView: tableView, btnClickBlock: {
- [weak tableView] in
- tableView?.mj_header.beginRefreshing()
- })
- if tableView?.mj_footer != nil {
- tableView?.endFooterRefresh()
- }
- if tableView?.mj_header != nil {
- tableView?.endHeaderRefresh()
- }
- tableView?.ly_endLoading()
- }
-
- class func hiddenHeaderWithFooterNOData(tableView : UITableView?) {
- DIYEmptyView.emptyNoDataTableView(tableView: tableView,imageStr: .one,detailStr: .one)
- if tableView?.mj_footer != nil {
- tableView?.endFooterRefresh()
- }
- if tableView?.mj_header != nil {
- tableView?.endHeaderRefresh()
- }
- tableView?.ly_endLoading()
- }
-
- class func hiddenHeaderWithFooter(tableView:UITableView?,loadingStatus:SwiftMoyaNetWorkManagerLoadingStatus) {
- if tableView?.mj_footer != nil {
- tableView?.isHiddenFooter(true)
- }
- if loadingStatus == .noData {
- MJRefreshManager.hiddenHeaderWithFooterNOData(tableView: tableView)
- }else if loadingStatus == .noNetwork {
- MJRefreshManager.hiddenHeaderWithFooterNONetWork(tableView: tableView)
- }
- }
-
-
- class func hiddenHeaderWithFooter(tableView : UITableView?,pagination : PaginationModel?) {
-
- if tableView?.mj_header != nil {
- tableView?.endHeaderRefresh()
- }
- if tableView?.mj_footer != nil {
- tableView?.endFooterRefresh()
- }
- if pagination?.total == 0 {
- if tableView?.mj_footer != nil {
- tableView?.isHiddenFooter(true)
- }
- }else {
- if pagination?.currentPage ?? 1 >= pagination?.totalPages ?? 1 {
- tableView?.mj_footer.isHidden = false
- if tableView?.mj_footer != nil {
- tableView?.endFooterNoMoreData()
- tableView?.mj_footer.pullingPercent = 1
- }
- }
- }
- tableView?.ly_endLoading()
- }
-
-
- //MARK: - collectionView
- class func hiddenHeaderWithFooter(collectionView : UICollectionView?) {
- if collectionView?.mj_header != nil {
- collectionView?.endHeaderRefresh()
- }
- if collectionView?.mj_footer != nil {
- collectionView?.endFooterRefresh()
- }
- collectionView?.ly_endLoading()
- }
-
- class func hiddenHeaderWithFooterNONetWork(collectionView : UICollectionView?) {
- DIYEmptyView.emptyNoDataActionCollectionView(collectionView: collectionView, btnClickBlock: {
- [weak collectionView] in
- collectionView?.mj_header.beginRefreshing()
- })
- if collectionView?.mj_header != nil {
- collectionView?.endHeaderRefresh()
- }
- if collectionView?.mj_footer != nil {
- collectionView?.endFooterRefresh()
- }
- collectionView?.ly_endLoading()
- }
-
- class func hiddenHeaderWithFooterNOData(collectionView : UICollectionView?) {
- DIYEmptyView.emptyNoDataCollectionView(collectionView: collectionView)
- if collectionView?.mj_header != nil {
- collectionView?.endHeaderRefresh()
- }
- if collectionView?.mj_footer != nil {
- collectionView?.endFooterRefresh()
- }
- collectionView?.ly_endLoading()
- }
-
- class func hiddenHeaderWithFooter(collectionView:UICollectionView?,loadingStatus:SwiftMoyaNetWorkManagerLoadingStatus) {
- if collectionView?.mj_footer != nil {
- collectionView?.isHiddenFooter(true)
- }
- if loadingStatus == .noData {
- MJRefreshManager.hiddenHeaderWithFooterNOData(collectionView: collectionView)
- }else if loadingStatus == .noNetwork {
- MJRefreshManager.hiddenHeaderWithFooterNONetWork(collectionView: collectionView)
- }
- }
-
- class func hiddenHeaderWithFooter(collectionView : UICollectionView?,pagination : PaginationModel?) {
- if collectionView?.mj_header != nil {
- collectionView?.endHeaderRefresh()
- }
- if collectionView?.mj_footer != nil {
- collectionView?.endFooterRefresh()
- }
-
- if pagination?.total == 0 {
- if collectionView?.mj_footer != nil {
- collectionView?.isHiddenFooter(true)
- }
- }else {
- if pagination?.currentPage ?? 1 >= pagination?.totalPages ?? 1 {
- collectionView?.mj_footer.isHidden = false
- if collectionView?.mj_footer != nil {
- collectionView?.endFooterNoMoreData()
- collectionView?.mj_footer.pullingPercent = 1
- }
- }
- }
- collectionView?.ly_endLoading()
- }
- }
|