Browse Source

打开webp 功能

jsonwang 3 years ago
parent
commit
b02e3b37bc

+ 13 - 13
BFFramework/Classes/Categorys/UIView+Ext.swift

@@ -6,7 +6,7 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
-//import KingfisherWebP
+import KingfisherWebP
 import UIKit
 
 // MARK: - UIView的分类扩展
@@ -414,10 +414,10 @@ extension UIImageView {
             BFLog(message: "设置按钮网络图片地址为空")
             return
         }
-//        kf.setImage(with: URL(string: url!), placeholder: placeholder, options: url?.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-//
-//        }) { _, _, _, _ in
-//        }
+        kf.setImage(with: URL(string: url!), placeholder: placeholder, options: url?.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
+
+        }) { _, _, _, _ in
+        }
     }
 
     /// 展示加载中动画
@@ -466,19 +466,19 @@ extension UIButton {
             BFLog(message: "设置按钮网络图片地址为空")
             return
         }
-//        kf.setImage(with: URL(string: url!), for: .normal, placeholder: placeholder, options: url?.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-//
-//        }) { _, _, _, _ in
-//        }
+        kf.setImage(with: URL(string: url!), for: .normal, placeholder: placeholder, options: url?.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
+
+        }) { _, _, _, _ in
+        }
     }
 
     /// UIButton加载网络背景图片
     /// - Parameters:
     ///   - url: 网络url
      public func setNetBackgroundImage(url: String, placeholder: UIImage = UIImage(named: "placehold_image")!) {
-//        kf.setBackgroundImage(with: URL(string: url), for: .normal, placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-//
-//        }) { _, _, _, _ in
-//        }
+        kf.setBackgroundImage(with: URL(string: url), for: .normal, placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
+
+        }) { _, _, _, _ in
+        }
     }
 }

+ 1 - 1
BFFramework/Classes/Enums/Enums.swift

@@ -28,7 +28,7 @@ enum PQVIDEOPAGETYPE {
 // MARK: - 视频播放状态
 
 /// 视频播放状态
-enum PQVIDEO_PLAY_STATUS {
+public enum PQVIDEO_PLAY_STATUS {
     case PQVIDEO_PLAY_STATUS_LOADING // 加载中
     case PQVIDEO_PLAY_STATUS_BEGIN // 开始播放
     case PQVIDEO_PLAY_STATUS_END // 播放结束

+ 4 - 1
BFFramework/Classes/PModels/PQVideoListModel.swift

@@ -126,8 +126,11 @@ public class PQVideoListModel: PQBaseModel {
     public var autoType: autoType? // autoType 自动动作的类型
     // add by ak 发布视频来源类型
     public var videoFromScene: videoFromScene = .UploadNormal
+    
+    //视频的分类
+    public var categoryName:String = ""
 
-    override init(jsonDict: [String: Any]) {
+    override public init(jsonDict: [String: Any]) {
         super.init(jsonDict: jsonDict)
 
         if jsonDict.keys.contains("videoPath") {

+ 5 - 5
BFFramework/Classes/PModels/editDarftModels/PQEditVisionTrackMaterialsModel.swift

@@ -13,7 +13,7 @@
 
 import Foundation
 import Kingfisher
-//import KingfisherWebP
+import KingfisherWebP
 import Photos
 
 import ObjectMapper
@@ -246,10 +246,10 @@ class PQEditVisionTrackMaterialsModel: PQEditBaseModel {
                 if fileIsExists(filePath: documensDirectory + locationPath) {
                     fileData = try! Data(contentsOf: URL(fileURLWithPath: documensDirectory + locationPath))
                 }
-//                if fileData != nil && (fileData?.count ?? 0) > 0 && fileData?.isWebPFormat ?? false {
-//                    BFLog(message: "这个资源为web!")
-//                    coverImage = WebPProcessor.default.process(item: ImageProcessItem.data(fileData!), options: [.onlyLoadFirstFrame, .scaleFactor(1)])
-//                }
+                if fileData != nil && (fileData?.count ?? 0) > 0 && fileData?.isWebPFormat ?? false {
+                    BFLog(message: "这个资源为web!")
+                    coverImage = WebPProcessor.default.process(item: ImageProcessItem.data(fileData!), options: [.onlyLoadFirstFrame, .scaleFactor(1)])
+                }
             }
 
             return coverImage

+ 4 - 4
BFFramework/Classes/PQGPUImage/akfilters/PQImageFilter.swift

@@ -8,7 +8,7 @@
 
 import Foundation
 import Kingfisher
-//import KingfisherWebP
+import KingfisherWebP
 import UIKit
 
 open class PQImageFilter: PQBaseFilter {
@@ -63,9 +63,9 @@ open class PQImageFilter: PQBaseFilter {
                 if FileManager.default.fileExists(atPath: filePath) {
                     // 有可能是 WEBP
                     let fileData: Data = try! Data(contentsOf: URL(fileURLWithPath: filePath))
-//                    if fileData.count != 0, fileData.isWebPFormat {
-//                        newImage = WebPProcessor.default.process(item: ImageProcessItem.data(fileData), options: [.onlyLoadFirstFrame, .scaleFactor(1)])
-//                    }
+                    if fileData.count != 0, fileData.isWebPFormat {
+                        newImage = WebPProcessor.default.process(item: ImageProcessItem.data(fileData), options: [.onlyLoadFirstFrame, .scaleFactor(1)])
+                    }
                 } else { FilterLog(message: "文件不存在") }
             }
         }

+ 4 - 4
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointMaterialDetailController.swift

@@ -7,7 +7,7 @@
 //
 
 import Kingfisher
-//import KingfisherWebP
+import KingfisherWebP
 import UIKit
 
 class PQStuckPointMaterialDetailController: PQBaseViewController {
@@ -228,9 +228,9 @@ class PQStuckPointMaterialDetailController: PQBaseViewController {
                 if coverImage == nil {
                     // 有可能是 WEBP
                     let fileData: Data = try! Data(contentsOf: URL(fileURLWithPath: documensDirectory + (materialData?.locationPath)!))
-//                    if fileData.count != 0, fileData.isWebPFormat {
-//                        coverImage = WebPProcessor.default.process(item: ImageProcessItem.data(fileData), options: [.onlyLoadFirstFrame, .scaleFactor(1)])
-//                    }
+                    if fileData.count != 0, fileData.isWebPFormat {
+                        coverImage = WebPProcessor.default.process(item: ImageProcessItem.data(fileData), options: [.onlyLoadFirstFrame, .scaleFactor(1)])
+                    }
                 }
                 preImageView.image = coverImage
                 materialData?.coverImageUI = coverImage

+ 14 - 15
BFFramework/Classes/Utils/PQCommonMethodUtil.swift

@@ -11,8 +11,7 @@ import Alamofire
 import Foundation
 import KeychainAccess
 import Kingfisher
-//import KingfisherWebP
-//import NXFramework_Swift
+import KingfisherWebP
 import Photos
 import RealmSwift
 import Toast_Swift
@@ -99,17 +98,17 @@ public func cIPHONE_X() -> Bool {
 ///   - url: 网络url
 ///   - mainView: 需要加载的视图
 public func netImage(url: String, mainView: Any, placeholder: UIImage = UIImage(named: "placehold_image")!) {
-//    if mainView is UIImageView {
-//        (mainView as! UIImageView).kf.setImage(with: URL(string: url), placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-//
-//        }) { _, _, _, _ in
-//        }
-//    } else if mainView is UIButton {
-//        (mainView as! UIButton).kf.setImage(with: URL(string: url), for: .normal, placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-//
-//        }) { _, _, _, _ in
-//        }
-//    }
+    if mainView is UIImageView {
+        (mainView as! UIImageView).kf.setImage(with: URL(string: url), placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
+
+        }) { _, _, _, _ in
+        }
+    } else if mainView is UIButton {
+        (mainView as! UIButton).kf.setImage(with: URL(string: url), for: .normal, placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
+
+        }) { _, _, _, _ in
+        }
+    }
 }
 
 /** 获取Kingfisher缓存的图片的data */
@@ -150,8 +149,8 @@ public func commonParams() -> [String: Any] {
         "versionCode": versionCode,
         "system": systemName + " " + systemVersion,
         "systemVersion": systemName + " " + systemVersion,
-        "appType": "13",
-        "appId": "1509463838",
+        "appType": "15",
+        "appId": "1570572849",
         "machineCode": getMachineCode(),
         "networkType": networkStatus(),
         "ipAddress": ipAddress(),