|
@@ -466,6 +466,44 @@ class WSSResourcePickerController: MTViewController {
|
|
|
loadPhotoAsset(coverImage: cover, phAsset: model.asset)
|
|
|
}
|
|
|
|
|
|
+ func loadPhotoAsset(coverImage: UIImage, phAsset: PHAsset, targetWidth: CGFloat = kOJSScreenWidth) {
|
|
|
+ if let manager = TZImageManager.default() {
|
|
|
+ assetRequestID = manager.getPhotoWith(phAsset, photoWidth: targetWidth, completion: { [weak self] (originalImage: UIImage?, _: [AnyHashable: Any]?, isDegraded: Bool) in
|
|
|
+ guard let nextIndex = self?.getNextNeedSelectIndex(),
|
|
|
+ let nextModel = self?.selectModels.safeObject(atIndex: nextIndex) else { return }
|
|
|
+ self?.assetRequestID = 0
|
|
|
+ if isDegraded == false, let img = originalImage {
|
|
|
+ nextModel.setPhotoAsset(cover: coverImage, image: img, original: phAsset)
|
|
|
+ self?.refreshState()
|
|
|
+ self?.successSelectOneResource()
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if self?.isPageShowing == true {
|
|
|
+ if originalImage == nil {
|
|
|
+ showHud(withOnlyText: "读取资源失败,稍后重试")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }, progressHandler: { [weak self] percent, err, _, _ in
|
|
|
+ if self?.isPageShowing == true {
|
|
|
+ DispatchQueue.main.async(execute: {
|
|
|
+ if percent > 0.0 && percent < 1.0 {
|
|
|
+ showProgressHud(progress: Float(percent), status: "iCloud下载中")
|
|
|
+ } else {
|
|
|
+ hideHud()
|
|
|
+ }
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ showHud(withOnlyText: err!.localizedDescription)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }, networkAccessAllowed: true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// 成功选择一个资源:视频或者图片
|
|
|
func successSelectOneResource() {
|
|
|
//
|
|
@@ -651,43 +689,6 @@ private extension WSSResourcePickerController {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- func loadPhotoAsset(coverImage: UIImage, phAsset: PHAsset) {
|
|
|
- if let manager = TZImageManager.default() {
|
|
|
- assetRequestID = manager.getOriginalPhoto(with: phAsset, progressHandler: { [weak self] percent, err, _, _ in
|
|
|
- if self?.isPageShowing == true {
|
|
|
- DispatchQueue.main.async(execute: {
|
|
|
- if percent > 0.0 && percent < 1.0 {
|
|
|
- showProgressHud(progress: Float(percent), status: "iCloud下载中")
|
|
|
- } else {
|
|
|
- hideHud()
|
|
|
- }
|
|
|
-
|
|
|
- if err != nil {
|
|
|
- showHud(withOnlyText: err!.localizedDescription)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }, newCompletion: { [weak self] (originalImage: UIImage?, _: [AnyHashable: Any]?, isDegraded: Bool) in
|
|
|
- guard let nextIndex = self?.getNextNeedSelectIndex(),
|
|
|
- let nextModel = self?.selectModels.safeObject(atIndex: nextIndex) else { return }
|
|
|
- self?.assetRequestID = 0
|
|
|
- if isDegraded == false, let img = originalImage {
|
|
|
- nextModel.setPhotoAsset(cover: coverImage, image: img, original: phAsset)
|
|
|
- self?.refreshState()
|
|
|
- self?.successSelectOneResource()
|
|
|
-
|
|
|
- } else {
|
|
|
- if self?.isPageShowing == true {
|
|
|
- if originalImage == nil {
|
|
|
- showHud(withOnlyText: "读取资源失败,稍后重试")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
func refreshConfirmBarItemState() {
|
|
|
topTipLabel.text = topTipMessage()
|
|
|
/// 大于一个视频,才可以进行下一步
|