2 커밋 fa3854eb06 ... d32823ef3b

작성자 SHA1 메시지 날짜
  zhongbaojian d32823ef3b fix:下架模板的处理 5 년 전
  zhongbaojian a222a24754 如果当前播放的不是刚刚下载好得模板,不进行页面跳转 5 년 전

+ 0 - 4
SuperShow.xcodeproj/project.pbxproj

@@ -238,7 +238,6 @@
 		A80751BB228E634000E5DDEB /* WSSCreativeTemplateConstant.swift in Sources */ = {isa = PBXBuildFile; fileRef = A80751BA228E634000E5DDEB /* WSSCreativeTemplateConstant.swift */; };
 		A80F294B228D6029006A1C7C /* WSSTemplateEditTextEditorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A80F294A228D6029006A1C7C /* WSSTemplateEditTextEditorView.swift */; };
 		A80F8ECF230E3BD70084B290 /* WSSCoolVoiceCutVideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A80F8ECE230E3BD70084B290 /* WSSCoolVoiceCutVideoViewController.swift */; };
-		A817F3C323016C2200505DC9 /* WSSVideoScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A817F3C023016C2200505DC9 /* WSSVideoScrollView.swift */; };
 		A8214FD322533F7700D2DD37 /* OJARequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8214FD222533F7700D2DD37 /* OJARequest.swift */; };
 		A8214FD522533FBC00D2DD37 /* OJARequestBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8214FD422533FBC00D2DD37 /* OJARequestBody.swift */; };
 		A8214FD72253400900D2DD37 /* OJANetworkConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8214FD62253400900D2DD37 /* OJANetworkConfig.swift */; };
@@ -892,7 +891,6 @@
 		A80751BA228E634000E5DDEB /* WSSCreativeTemplateConstant.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WSSCreativeTemplateConstant.swift; sourceTree = "<group>"; };
 		A80F294A228D6029006A1C7C /* WSSTemplateEditTextEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WSSTemplateEditTextEditorView.swift; sourceTree = "<group>"; };
 		A80F8ECE230E3BD70084B290 /* WSSCoolVoiceCutVideoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WSSCoolVoiceCutVideoViewController.swift; sourceTree = "<group>"; };
-		A817F3C023016C2200505DC9 /* WSSVideoScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WSSVideoScrollView.swift; sourceTree = "<group>"; };
 		A8214FD222533F7700D2DD37 /* OJARequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OJARequest.swift; sourceTree = "<group>"; };
 		A8214FD422533FBC00D2DD37 /* OJARequestBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OJARequestBody.swift; sourceTree = "<group>"; };
 		A8214FD62253400900D2DD37 /* OJANetworkConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OJANetworkConfig.swift; sourceTree = "<group>"; };
@@ -2119,7 +2117,6 @@
 				A8409724226DC594008F3E47 /* WSSShareCollectionCell.xib */,
 				A8409719226DBCA8008F3E47 /* WSSShareView.swift */,
 				A8DEC85922F13DAD00BFDFF6 /* WSSVideoLoadingView.swift */,
-				A817F3C023016C2200505DC9 /* WSSVideoScrollView.swift */,
 				A8287DCD22A5197200A127FC /* WSSWifiChangeAlert.swift */,
 				A8287DD122A519AA00A127FC /* WSSWifiChangeAlertView.xib */,
 			);
@@ -3684,7 +3681,6 @@
 				A8E6499E2307E32A00D8D5B5 /* WSSVideoPresetModel.swift in Sources */,
 				A8E649982307DC9600D8D5B5 /* WSSVideoPresetViewController.swift in Sources */,
 				A8D6E9AE22DF231A0000FB24 /* WSSVideoProgressView.swift in Sources */,
-				A817F3C323016C2200505DC9 /* WSSVideoScrollView.swift in Sources */,
 				A8CA2D652282851E0040AF1C /* WSSVideoSecondsView.swift in Sources */,
 				A8CA2D6A2282B9550040AF1C /* WSSVideoThumbnailView.swift in Sources */,
 				A8069E4223226C0F001A2ABF /* WSSVoiceTryListenView.swift in Sources */,

+ 17 - 3
SuperShow/UI/Recommend/Views/WSSRecommendCell.swift

@@ -21,6 +21,7 @@ class WSSRecommendCell: UITableViewCell {
     var shareActionHandle: ((WSSCommonTemplateModel?) -> Void)?
     var currentIndexPath: IndexPath = IndexPath(row: 0, section: 0)
     var downloadRequest: WSSAPICreativeTemplateDownload?
+    var shouldJumpPageHandle: ((WSSCommonTemplateModel?) -> Bool)?
 
     func addVideoView(_ view: UIView) {
         videoContainView.removeAllSubViews()
@@ -338,7 +339,10 @@ extension WSSRecommendCell {
                 /// 统计下载模板
                 WSSStatisticManager.countTemplateEvent(templateId: templateModel.templateId, eventType: .download)
                 /// 下载音乐
-                downloadMusic(withModel: musicModel)
+                DispatchQueue.global().async { [weak self] in
+                    self?.downloadMusic(withModel: musicModel)
+                }
+                
             }
         } else {
             /// 创意模板
@@ -348,7 +352,12 @@ extension WSSRecommendCell {
             DispatchQueue.global().async { [weak self] in
                 self?.jumpCreavieTemplateEditViewControllerHandler(sourcePath: sourcePath, templateID: Int64(templatedID), completedBlock: { filePath, finished in
                     DispatchQueue.main.async {
-                        if finished, let filePath = filePath {
+                        var isJump: Bool = true
+                        if let handle = self?.shouldJumpPageHandle {
+                            isJump = handle(templateModel)
+                        }
+
+                        if finished && isJump, let filePath = filePath {
                             /// 统计使用模板
                             WSSStatisticManager.countTemplateEvent(templateId: templatedID, eventType: .useTemplate)
                             OJAJumpManager.jumpToCreativeTemplatePicker(templateModel: templateModel,
@@ -531,8 +540,13 @@ fileprivate extension WSSRecommendCell {
         } else {
             videoInfos = setupOldVideoInfosHandle(withMusicModel: musicModel, musicAsset: musicAsset)
         }
+        
+        var isJump:Bool = true
+        if let handle = self.shouldJumpPageHandle {
+            isJump = handle(self.templateModel)
+        }
 
-        if let videoInfos = videoInfos {
+        if let videoInfos = videoInfos, isJump == true {
             OJAJumpManager.jumpToTemplateSpotImagePicker(videoInfos: videoInfos, templateModel: templateModel, music: musicAsset, navigation: OJAJumpManager.getCurrentNavigationController())
         }
     }

+ 12 - 0
SuperShow/UI/Recommend/Views/WSSRecommendVideoView.swift

@@ -193,6 +193,18 @@ class WSSRecommendVideoView: WSSBaseView {
         cell.shareActionHandle = { [unowned self] model in
             self.shareActionHandle?(model)
         }
+        cell.shouldJumpPageHandle = { [unowned self] model in
+            if let m = model {
+                if let currentModel = self.currentShowingItem()?.templateModel {
+                    return m.templateId == currentModel.templateId
+                }
+
+                return true
+            } else {
+                return true
+            }
+        }
+
         return cell
     }
 

+ 0 - 351
SuperShow/UI/Recommend/Views/WSSVideoScrollView.swift

@@ -1,351 +0,0 @@
-//
-//  WSSVideoScrollView.swift
-//  ScrollDemo
-//
-//  Created by zhongbaojian on 2019/8/12.
-//  Copyright © 2019 zhongbaojian. All rights reserved.
-//
-
-import UIKit
-
-class WSSVideoScrollView: UIView {
-    // MARK: - Public
-
-    var datas: [WSSCommonTemplateModel] = [] {
-        didSet {
-            reloadData()
-        }
-    }
-
-    var changePageHanle: ((_ current: Int, _ last: Int) -> Void)?
-    var playActionHandle: ((WSSCommonTemplateModel?, Bool) -> Void)?
-    var albumActionHandle: ((WSSCommonTemplateModel?) -> Void)?
-    var shareActionHandle: ((WSSCommonTemplateModel?) -> Void)?
-    var headerRefreshHandle: (() -> Void)?
-    var footerRefreshHandle: (() -> Void)?
-
-    override init(frame: CGRect) {
-        super.init(frame: frame)
-
-        bottomItem.isHidden = true
-        bottomItem.y = -1.0 * frame.height
-
-        addSubview(container)
-        container.addSubview(topItem)
-        container.addSubview(midItem)
-        container.addSubview(bottomItem)
-
-        itemViews.append(bottomItem)
-        itemViews.append(topItem)
-        itemViews.append(midItem)
-    }
-
-    required init?(coder aDecoder: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-
-    func currentShowingItem() -> WSSRecommendCell {
-        return itemViews[1]
-    }
-
-    func lastShowItem() -> WSSRecommendCell? {
-        return lastItemView
-    }
-
-    func triggerHeaderRefresh() {
-        container.mj_header.beginRefreshing()
-        reset()
-    }
-
-    func endHeaderRefresh() {
-        if container.mj_header.isRefreshing {
-            container.mj_header.endRefreshing()
-        }
-    }
-
-    func endFooterRefresh(isNoMore: Bool) {
-        if isNoMore {
-            container.mj_footer.endRefreshingWithNoMoreData()
-        } else {
-            container.mj_footer.endRefreshing()
-            container.mj_footer.resetNoMoreData()
-        }
-
-        container.contentInset = UIEdgeInsets.zero
-
-        if let preModel = self.datas.safeObject(atIndex: self.currentIndex + 1), let last = self.itemViews.last {
-            last.isHidden = false
-            last.setup(withVideoModel: preModel)
-        }
-    }
-
-    func reset() {
-        currentIndex = 0
-        lastIndex = 0
-        lastItemView = nil
-
-        bottomItem.isHidden = true
-        bottomItem.y = -1.0 * frame.height
-
-        topItem.y = 0.0
-        midItem.y = container.height
-
-        itemViews[0] = bottomItem
-        itemViews[1] = topItem
-        itemViews[2] = midItem
-    }
-
-    // MARK: - Private
-
-    fileprivate var currentIndex: Int = 0
-    fileprivate var lastIndex: Int = 0
-    fileprivate var startDragPointY: CGFloat = 0.0
-    fileprivate var itemViews: [WSSRecommendCell] = []
-    fileprivate var lastItemView: WSSRecommendCell?
-
-    fileprivate lazy var container: UIScrollView = {
-        let scroller: UIScrollView = UIScrollView(frame: self.bounds)
-        scroller.delegate = self
-        scroller.contentSize = self.bounds.size
-        scroller.isPagingEnabled = true
-        scroller.showsVerticalScrollIndicator = false
-        scroller.showsHorizontalScrollIndicator = false
-        scroller.delaysContentTouches = false
-
-        if #available(iOS 11.0, *) {
-            scroller.contentInsetAdjustmentBehavior = .never
-        } else {
-            scroller.contentInset = UIEdgeInsets.zero
-        }
-        scroller.mj_header = WSSRefreshHeader(refreshingBlock: { [weak self] in
-            self?.headerRefreshHandle?()
-        })
-        scroller.mj_footer = FVRefreshFooter(refreshingBlock: { [weak self] in
-            self?.footerRefreshHandle?()
-        })
-
-        return scroller
-    }()
-
-    fileprivate lazy var topItem: WSSRecommendCell = {
-        let cell = self.createRecommendCell()
-        cell.y = 0.0
-        cell.tag = 1001
-        return cell
-    }()
-
-    fileprivate lazy var midItem: WSSRecommendCell = {
-        let cell = self.createRecommendCell()
-        cell.y = self.container.height
-        cell.tag = 1002
-        return cell
-    }()
-
-    fileprivate lazy var bottomItem: WSSRecommendCell = {
-        let cell = self.createRecommendCell()
-        cell.tag = 1003
-        return cell
-    }()
-
-    private func reloadData() {
-        let contentHeight: CGFloat = container.height * CGFloat(datas.count)
-        container.contentSize = CGSize(width: container.width, height: contentHeight)
-
-        WSSLog("🐱🐱🐱: 刷新一次: \(datas.count) +++ \(currentIndex) +++ \(itemViews.map({ ($0.tag, $0.isHidden) }))")
-
-        for item in datas.enumerated() {
-            let model = item.element
-            if item.offset == currentIndex {
-                let target = itemViews[1]
-                target.isHidden = false
-                target.setup(withVideoModel: model)
-            } else if item.offset == currentIndex + 1 {
-                let target = itemViews[2]
-                target.isHidden = false
-                target.setup(withVideoModel: model)
-            } else if item.offset == currentIndex - 1 {
-                let target = itemViews[0]
-                target.isHidden = false
-                target.setup(withVideoModel: model)
-            } else {
-                continue
-            }
-        }
-    }
-
-    fileprivate func changeSort(isUp: Bool) {
-        if isUp {
-            if let first = self.itemViews.first {
-                first.y = first.y + 3 * container.height
-
-                let mid = itemViews[1]
-                let bottom = itemViews[2]
-                itemViews[0] = mid
-                itemViews[1] = bottom
-                itemViews[2] = first
-            }
-        } else {
-            if let last = self.itemViews.last {
-                last.y = last.y - 3 * container.height
-
-                let first = itemViews[0]
-                let second = itemViews[1]
-                itemViews[0] = last
-                itemViews[1] = first
-                itemViews[2] = second
-            }
-        }
-    }
-
-    fileprivate func createRecommendCell() -> WSSRecommendCell {
-        let cell: WSSRecommendCell = WSSRecommendCell.ojs_loadFromNib()
-        cell.frame = container.bounds
-        cell.videoPlayButton.isSelected = false
-        cell.playActionHandle = { [unowned self] model, flag in
-            self.playActionHandle?(model, flag)
-        }
-        cell.albumActionHandle = { [unowned self] model in
-            self.albumActionHandle?(model)
-        }
-        cell.shareActionHandle = { [unowned self] model in
-            self.shareActionHandle?(model)
-        }
-        return cell
-    }
-
-    override func layoutSubviews() {
-        super.layoutSubviews()
-
-        if #available(iOS 11.0, *) {
-            //
-        } else {
-            container.contentInset = UIEdgeInsets.zero
-        }
-    }
-
-    fileprivate func scrollItem(to index: Int, isChangePage: Bool) {
-        WSSLog("🐱: 当前页 >>> \(index)")
-
-        lastIndex = currentIndex
-        lastItemView = itemViews[1]
-        currentIndex = Int(index)
-
-        let delta = currentIndex - lastIndex
-        if delta < 0 {
-            // 向下 -1
-            let preIndex = currentIndex - 1
-            if let model = self.datas.safeObject(atIndex: preIndex), let last = self.itemViews.last {
-                last.isHidden = false
-                last.setup(withVideoModel: model)
-                last.currentIndexPath = IndexPath(row: preIndex, section: 0)
-                changeSort(isUp: false)
-
-//                WSSLog("🐱: 向下 >>> 000")
-
-            } else {
-                if currentIndex == 0 {
-                    // 第一项了,还是需要移动一下,但是隐藏
-                    if let last = self.itemViews.last {
-                        last.isHidden = true
-                        changeSort(isUp: false)
-
-//                        WSSLog("🐱: 向下 >>> 111")
-                    }
-                } else {
-//                    WSSLog("🐱: 向下 >>> 222")
-                }
-            }
-
-        } else if delta > 0 {
-            // 向上 +1
-            let preIndex = currentIndex + 1
-            if let model = self.datas.safeObject(atIndex: preIndex), let first = self.itemViews.first {
-                first.isHidden = false
-                first.setup(withVideoModel: model)
-                first.currentIndexPath = IndexPath(row: preIndex, section: 0)
-                changeSort(isUp: true)
-
-//                WSSLog("🐱: 向上 >>> 000")
-
-            } else {
-                if currentIndex == datas.count - 1 {
-                    // 最后一项,还是需要移动一下,但是隐藏
-                    if let first = self.itemViews.first {
-                        first.isHidden = true
-                        changeSort(isUp: true)
-
-//                        WSSLog("🐱: 向上 >>> 111")
-                    }
-                } else {
-//                    WSSLog("🐱: 向上 >>> 222")
-                }
-            }
-
-        } else {
-            // 不变
-
-//            WSSLog("🐱: 不变")
-
-            if let currentModel = self.datas.safeObject(atIndex: currentIndex), let targetModel = self.currentShowingItem().templateModel {
-//                WSSLog("🐱: 不变 》》》》 \(currentModel.templateId) ++++ \(targetModel.templateId)")
-
-                if currentModel.templateId != targetModel.templateId {
-                    // 位置不对
-                    if let targetIndex = self.datas.firstIndex(where: { $0.templateId == targetModel.templateId }) {
-                        let tmpDelta = currentIndex - targetIndex
-                        changeSort(isUp: tmpDelta < 0)
-                    }
-                }
-            }
-        }
-
-        if let lastModel = self.datas.safeObject(atIndex: self.lastIndex) {
-            lastModel.selected = false
-        }
-        if let currentModel = self.datas.safeObject(atIndex: self.currentIndex) {
-            currentModel.selected = true
-        }
-
-        if isChangePage {
-            changePageHanle?(currentIndex, lastIndex)
-        }
-
-//        WSSLog("🐱🐱🐱: \(self.itemViews.map({ ($0.tag, $0.isHidden) }))")
-    }
-}
-
-// MARK: -
-
-extension WSSVideoScrollView: UIScrollViewDelegate {
-    func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        //
-    }
-
-    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
-        startDragPointY = scrollView.contentOffset.y
-    }
-
-    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
-        //
-    }
-
-    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
-        //
-        let index = scrollView.contentOffset.y / container.height
-        scrollItem(to: Int(index), isChangePage: false)
-    }
-
-    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
-        //
-        let index = scrollView.contentOffset.y / container.height
-        scrollItem(to: Int(index), isChangePage: true)
-
-//        WSSLog("🐱: 停止滚动++++++++++++++++++++++")
-    }
-
-    func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
-        //
-//        let index = scrollView.contentOffset.y / container.height
-//        WSSLog("🐱\(#function): 当前页 >>> \(Int(index))")
-    }
-}

+ 6 - 1
SuperShow/UI/Template/Views/WSSTemplateCollectionCell.swift

@@ -16,7 +16,12 @@ class WSSTemplateCollectionCell: WSSBaseCollectionCell {
         didSet {
             if let m = model {
                 coverImageView.backgroundColor = OJSColor(hexRGBValue: 0x4B4B55)
-                coverImageView.ojs_setImage(withUrl: m.cover, placeholder: R.image.home_template_cover_placeholder())
+
+                if m.isPublish {
+                    coverImageView.ojs_setImage(withUrl: m.cover, placeholder: R.image.home_template_cover_placeholder())
+                } else {
+                    coverImageView.image = R.image.template_unavailable()
+                }
                 nameLabel.text = m.name
 
                 self.tagView.setupFeeType(m.feeType, price: m.price)