Commit 7ab40d47 authored by CZ1004's avatar CZ1004

修改bug

parent de98cae7
...@@ -22,7 +22,7 @@ class CompressCompletedViewController : BaseViewController{ ...@@ -22,7 +22,7 @@ class CompressCompletedViewController : BaseViewController{
lazy var animationView : LottieAnimationView = { lazy var animationView : LottieAnimationView = {
let animationView = LottieAnimationView(name: "CompressCompletedLight") let animationView = LottieAnimationView(name: "CompressCompletedLight")
animationView.layer.cornerRadius = 12 animationView.layer.cornerRadius = 12
animationView.backgroundColor = .gray animationView.backgroundColor = .clear
animationView.loopMode = .loop animationView.loopMode = .loop
return animationView return animationView
}() }()
...@@ -344,5 +344,6 @@ class CompressCompletedViewController : BaseViewController{ ...@@ -344,5 +344,6 @@ class CompressCompletedViewController : BaseViewController{
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setUI() setUI()
self.animationView.play(fromProgress: 0, toProgress: 1,loopMode: .playOnce)
} }
} }
...@@ -54,10 +54,12 @@ class HomePhotosDetailViewController : BaseViewController { ...@@ -54,10 +54,12 @@ class HomePhotosDetailViewController : BaseViewController {
// 当前页面选中的 // 当前页面选中的
var selectedModel : [String] = [] { var selectedModel : [String] = [] {
didSet{ didSet{
if self.selectedModel.count == 1{ if self.selectedModel.count == 0{
self.deleteButton.setTitle("Delete \(self.selectedModel.count) Video", for: .normal) self.deleteButton.setTitle("Delete", for: .normal)
}else if self.selectedModel.count == 1{
self.deleteButton.setTitle("Delete \(self.selectedModel.count) Photo", for: .normal)
}else{ }else{
self.deleteButton.setTitle("Delete \(selectedModel.count) Videos", for: .normal) self.deleteButton.setTitle("Delete \(selectedModel.count) Photos", for: .normal)
} }
} }
} }
...@@ -350,9 +352,9 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti ...@@ -350,9 +352,9 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti
} }
if sortType == 0 || sortType == 1 { if sortType == 0 || sortType == 1 {
if sortType == 0 { if sortType == 0 {
assetsWithSize = assetsWithSize.sorted { $0.size > $1.size }
}else{
assetsWithSize = assetsWithSize.sorted { $0.size < $1.size } assetsWithSize = assetsWithSize.sorted { $0.size < $1.size }
}else{
assetsWithSize = assetsWithSize.sorted { $0.size > $1.size }
} }
// 输出排序后的资源信息 // 输出排序后的资源信息
var sources:[String] = [] var sources:[String] = []
......
...@@ -58,6 +58,8 @@ class HomeVideoDetailController :BaseViewController { ...@@ -58,6 +58,8 @@ class HomeVideoDetailController :BaseViewController {
// self.currentHeaderView?.tipBackView.isHidden = true // self.currentHeaderView?.tipBackView.isHidden = true
// self.deleteButton.isHidden = false // self.deleteButton.isHidden = false
if self.selectedModel.count == 1{ if self.selectedModel.count == 1{
self.deleteButton.setTitle("Delete", for: .normal)
} else if self.selectedModel.count == 1{
self.deleteButton.setTitle("Delete \(self.selectedModel.count) Video", for: .normal) self.deleteButton.setTitle("Delete \(self.selectedModel.count) Video", for: .normal)
}else{ }else{
self.deleteButton.setTitle("Delete \(selectedModel.count) Videos", for: .normal) self.deleteButton.setTitle("Delete \(selectedModel.count) Videos", for: .normal)
...@@ -209,7 +211,6 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie ...@@ -209,7 +211,6 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
// 获取视频的图片 // 获取视频的图片
PhotoAndVideoMananger.mananger.getVideoImageByIdent(ident: ident) { image in PhotoAndVideoMananger.mananger.getVideoImageByIdent(ident: ident) { image in
// 点击之后跳转详情页面 // 点击之后跳转详情页面
print("cellCallBack")
let vc = PMShowImgVideoController() let vc = PMShowImgVideoController()
vc.state = .similarVideos vc.state = .similarVideos
vc.currentIdx = 0 vc.currentIdx = 0
...@@ -217,16 +218,31 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie ...@@ -217,16 +218,31 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
dataSource.isSeleted = true dataSource.isSeleted = true
dataSource.id = ident dataSource.id = ident
dataSource.image = image dataSource.image = image
// 表示这个是视频
vc.homeDataSource = [dataSource] vc.homeDataSource = [dataSource]
DispatchQueue.main.async { vc.getVideoURLFromLocalIdentifier(localIdentifier: ident) { url, error in
self.navigationController?.pushViewController(vc, animated: true) if url != nil{
DispatchQueue.main.async {
self.navigationController?.pushViewController(vc, animated: true)
}
}else{
let alert = UIAlertController(title: nil, message: "ICloud video cannot be viewed", preferredStyle: .alert)
self.present(alert, animated: true, completion: nil)
// 2 秒后关闭弹窗
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
alert.dismiss(animated: true, completion: nil)
}
}
} }
} errorHandler: { } errorHandler: {
DispatchQueue.main.async { DispatchQueue.main.async {
let alert = UIAlertController(title: nil, message: "Get Video image failure", preferredStyle: .alert) let alert = UIAlertController(title: nil, message: "Get Video image failure", preferredStyle: .alert)
self.navigationController?.present(alert, animated: true) self.navigationController?.present(alert, animated: true)
// 疫苗之后消失 // 1秒之后消失
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
alert.dismiss(animated: true, completion: nil) alert.dismiss(animated: true, completion: nil)
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
...@@ -382,9 +398,9 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie ...@@ -382,9 +398,9 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
} }
if sortType == 0 || sortType == 1 { if sortType == 0 || sortType == 1 {
if sortType == 0 { if sortType == 0 {
assetsWithSize = assetsWithSize.sorted { $0.size > $1.size }
}else{
assetsWithSize = assetsWithSize.sorted { $0.size < $1.size } assetsWithSize = assetsWithSize.sorted { $0.size < $1.size }
}else{
assetsWithSize = assetsWithSize.sorted { $0.size > $1.size }
} }
// 输出排序后的资源信息 // 输出排序后的资源信息
var sources:[String] = [] var sources:[String] = []
......
...@@ -35,19 +35,22 @@ class PhotoDataManager { ...@@ -35,19 +35,22 @@ class PhotoDataManager {
// 从文件读取 // 从文件读取
func loadFromFileSystem(filename: String = "photosManagerData.json",resultModel:@escaping (_ model:PhotosManagerModel) -> () = {mdoel in}) { func loadFromFileSystem(filename: String = "photosManagerData.json",resultModel:@escaping (_ model:PhotosManagerModel) -> () = {mdoel in}) {
let url = getDocumentsDirectory().appendingPathComponent(filename) // let url = getDocumentsDirectory().appendingPathComponent(filename)
//
// 设计缓存读取 // // 设计缓存读取
do { // do {
let data = try Data(contentsOf: url) // let data = try Data(contentsOf: url)
let decoder = JSONDecoder() // let decoder = JSONDecoder()
let model = try decoder.decode(PhotosManagerModel.self, from: data) // let model = try decoder.decode(PhotosManagerModel.self, from: data)
// resultModel(model)
// } catch {
//
// loadDataFromPhotos { model in
// resultModel(model)
// }
// }
loadDataFromPhotos { model in
resultModel(model) resultModel(model)
} catch {
loadDataFromPhotos { model in
resultModel(model)
}
} }
} }
......
...@@ -192,6 +192,8 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa ...@@ -192,6 +192,8 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
} else if let url = url { } else if let url = url {
DispatchQueue.main.async { DispatchQueue.main.async {
cell.homeResouceUrl = url cell.homeResouceUrl = url
// 表示这个是视频
cell.type = 1
cell.reload() cell.reload()
} }
} }
...@@ -227,8 +229,9 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa ...@@ -227,8 +229,9 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
let fetchOptions = PHFetchOptions() let fetchOptions = PHFetchOptions()
let assets = PHAsset.fetchAssets(withLocalIdentifiers: [localIdentifier], options: fetchOptions) let assets = PHAsset.fetchAssets(withLocalIdentifiers: [localIdentifier], options: fetchOptions)
guard let asset = assets.firstObject, asset.mediaType == .video else { guard let asset = assets.firstObject, asset.mediaType == .video else {
DispatchQueue.main.async {
completion(nil, NSError(domain: "com.example.error", code: 1, userInfo: [NSLocalizedDescriptionKey: "未找到对应视频资源"])) completion(nil, NSError(domain: "com.example.error", code: 1, userInfo: [NSLocalizedDescriptionKey: "未找到对应视频资源"]))
}
return return
} }
...@@ -238,14 +241,20 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa ...@@ -238,14 +241,20 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
PHImageManager.default().requestAVAsset(forVideo: asset, options: options) { (avAsset, audioMix, info) in PHImageManager.default().requestAVAsset(forVideo: asset, options: options) { (avAsset, audioMix, info) in
if let error = info?[PHImageErrorKey] as? Error { if let error = info?[PHImageErrorKey] as? Error {
completion(nil, error) DispatchQueue.main.async {
completion(nil, error)
}
return return
} }
if let urlAsset = avAsset as? AVURLAsset { if let urlAsset = avAsset as? AVURLAsset {
completion(urlAsset.url, nil) DispatchQueue.main.async {
completion(urlAsset.url, nil)
}
} else { } else {
completion(nil, NSError(domain: "CustomErrorDomain", code: -1, userInfo: [NSLocalizedDescriptionKey: "Failed to get video URL"])) DispatchQueue.main.async {
completion(nil, NSError(domain: "CustomErrorDomain", code: -1, userInfo: [NSLocalizedDescriptionKey: "Failed to get video URL"]))
}
} }
} }
} }
......
...@@ -48,6 +48,8 @@ class PhotoAndVideoMananger { ...@@ -48,6 +48,8 @@ class PhotoAndVideoMananger {
var videoAssets:[PHAsset] = [] var videoAssets:[PHAsset] = []
var otherAssets:[PHAsset] = []
var ids:[String] = [] var ids:[String] = []
func setAssets() { func setAssets() {
...@@ -59,15 +61,13 @@ class PhotoAndVideoMananger { ...@@ -59,15 +61,13 @@ class PhotoAndVideoMananger {
let videoAllAssets = PHAsset.fetchAssets(with: .video, options: fetchOptions) let videoAllAssets = PHAsset.fetchAssets(with: .video, options: fetchOptions)
let fetchOptionsS = PHFetchOptions() let fetchOptionsS = PHFetchOptions()
fetchOptionsS.predicate = NSPredicate(format: "mediaSubtypes & %d != 0", PHAssetMediaSubtype.photoScreenshot.rawValue) fetchOptionsS.predicate = NSPredicate(format: "mediaSubtypes == %d", PHAssetMediaSubtype.photoScreenshot.rawValue)
let screenShotAllAssets = PHAsset.fetchAssets(with: .image, options: fetchOptions) let screenShotAllAssets = PHAsset.fetchAssets(with: .image, options: fetchOptionsS)
let photoAssetsArray = photoAllAssets.objects(at: IndexSet(0..<photoAllAssets.count)) let photoAssetsArray = photoAllAssets.objects(at: IndexSet(0..<photoAllAssets.count))
let videoAssetsArray = videoAllAssets.objects(at: IndexSet(0..<videoAllAssets.count)) let videoAssetsArray = videoAllAssets.objects(at: IndexSet(0..<videoAllAssets.count))
let screenShotArray = screenShotAllAssets.objects(at: IndexSet(0..<screenShotAllAssets.count)) let screenShotArray = screenShotAllAssets.objects(at: IndexSet(0..<screenShotAllAssets.count))
let otherArray = photoAssetsArray.filter {!screenShotArray.contains($0) }
let combinedArray = photoAssetsArray + videoAssetsArray let combinedArray = photoAssetsArray + videoAssetsArray
imageAssets = photoAssetsArray imageAssets = photoAssetsArray
...@@ -77,6 +77,8 @@ class PhotoAndVideoMananger { ...@@ -77,6 +77,8 @@ class PhotoAndVideoMananger {
screenShotAssets = screenShotArray screenShotAssets = screenShotArray
allAssets = combinedArray allAssets = combinedArray
otherAssets = otherArray
} }
class func getPrivacy(suc:@escaping callBack<Any> = {text in}) { class func getPrivacy(suc:@escaping callBack<Any> = {text in}) {
...@@ -197,9 +199,9 @@ class PhotoAndVideoMananger { ...@@ -197,9 +199,9 @@ class PhotoAndVideoMananger {
func fetXSScreenShot( resulte:@escaping ([[PHAsset]]) -> Void) { func fetXSScreenShot( resulte:@escaping ([[PHAsset]]) -> Void) {
let fetchOptions = PHFetchOptions() let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "mediaSubtypes & %d != 0", PHAssetMediaSubtype.photoScreenshot.rawValue) fetchOptions.predicate = NSPredicate(format: "mediaSubtypes == %d", PHAssetMediaSubtype.photoScreenshot.rawValue)
let screenshotAssets = PHAsset.fetchAssets(with: .image, options: fetchOptions) let screenshotAssets = PHAsset.fetchAssets(with: .image, options: fetchOptions)
let assetsArray = screenshotAssets.objects(at: IndexSet(0..<allAssets.count)) let assetsArray = screenshotAssets.objects(at: IndexSet(0..<screenshotAssets.count))
DispatchQueue.global().async {[weak self] in DispatchQueue.global().async {[weak self] in
...@@ -788,7 +790,7 @@ class PhotoAndVideoMananger { ...@@ -788,7 +790,7 @@ class PhotoAndVideoMananger {
// MARK: - 处理照片数据------------------------------------------------------- // MARK: - 处理照片数据-------------------------------------------------------
func dealImageAssetData(completionHandler:@escaping ([[String]])->Void){ func dealImageAssetData(completionHandler:@escaping ([[String]])->Void){
var data:[String] = [] var data:[String] = []
for item in self.imageAssets { for item in self.otherAssets {
data.append(item.localIdentifier) data.append(item.localIdentifier)
} }
var finalData : [[String]] = [] var finalData : [[String]] = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment