Commit 96dd0303 authored by CZ1004's avatar CZ1004

修改

parent 06ce2ebf
...@@ -64,6 +64,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -64,6 +64,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
} }
} }
func getHomeCacheData(){
// 首页有7个数据源
PhotoAndVideoMananger.mananger.setAssets()
}
var dataArrayDu : [[AssetModel]] = [] var dataArrayDu : [[AssetModel]] = []
......
...@@ -320,7 +320,19 @@ extension CompressController:WaterfallMutiSectionDelegate,UICollectionViewDataSo ...@@ -320,7 +320,19 @@ extension CompressController:WaterfallMutiSectionDelegate,UICollectionViewDataSo
if self.selectedModel.count == 0 { if self.selectedModel.count == 0 {
return return
} }
if HomePayModel.share.isNoAd == false {
HomePayViewController.show {
self.jumpToNextPage()
}
}else {
self.jumpToNextPage()
}
}
func jumpToNextPage(){
// 先将值传到下一个页面 // 先将值传到下一个页面
let vc : CompressQualityController = CompressQualityController() let vc : CompressQualityController = CompressQualityController()
vc.model = self.selectedModel vc.model = self.selectedModel
......
...@@ -69,6 +69,24 @@ class HomeInfoViewController:BaseViewController { ...@@ -69,6 +69,24 @@ class HomeInfoViewController:BaseViewController {
guard let self else {return} guard let self else {return}
// 删除缓存数据 // 删除缓存数据
PhotoDataManager.manager.removeDataWhenDeleteInPage(data: array as! [AssetModel]) PhotoDataManager.manager.removeDataWhenDeleteInPage(data: array as! [AssetModel])
// 更新下ids
PhotoDataManager.manager.loadFromFileSystem(resultModel: {[weak self] model in
DispatchQueue.main.async {
if self?.type == .duplicates {
self?.ids = model.titleModelArray[0].assets
}
if self?.type == .similar {
self?.ids = model.titleModelArray[1].assets
}
if self?.type == .SimilarVideos {
self?.ids = model.otherModelArray[1].assets
}
if self?.type == .similarScreenshots {
self?.ids = model.otherModelArray[3].assets
}
}
})
self.tablewView.deleteModel() self.tablewView.deleteModel()
} }
} }
......
...@@ -379,6 +379,17 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti ...@@ -379,6 +379,17 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti
@objc func deleteButtonAction(){ @objc func deleteButtonAction(){
if HomePayModel.share.isNoAd == false {
HomePayViewController.show {
self.deleteAction()
}
}else {
self.deleteAction()
}
}
func deleteAction(){
// 删除当前选择 // 删除当前选择
let allIdent = self.selectedModel.map{ $0.localIdentifier } let allIdent = self.selectedModel.map{ $0.localIdentifier }
let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: allIdent, options: nil) let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: allIdent, options: nil)
...@@ -387,24 +398,42 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti ...@@ -387,24 +398,42 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti
}){ success, error in }){ success, error in
if(success){ if(success){
print("删除文件成功") print("删除文件成功")
// 移除当前总数据源的数据 self.updateCurrentPageWhenDeleteAny()
for item in self.selectedModel {
// 移除当前数据
self.resourceData.removeAll{ $0.localIdentifier == item.localIdentifier }
}
PhotoDataManager.manager.removeDataWhenDeleteInPage(data: self.selectedModel)
}else { }else {
if let error = error { if let error = error {
print("删除文件时出错: \(error.localizedDescription)") print("删除文件时出错: \(error.localizedDescription)")
} }
} }
// 更新页面 }
}
func updateCurrentPageWhenDeleteAny(){
for item in self.selectedModel {
// 移除当前数据
self.resourceData.removeAll{ $0.localIdentifier == item.localIdentifier }
// 更新下头部数量
DispatchQueue.main.async { DispatchQueue.main.async {
self.clearSelected() if self.currentHeaderView != nil {
self.collectionView.reloadSections(IndexSet(integer: 0)) self.currentHeaderView?.countLabel.text = "\(self.resourceData.count) Photos"
}
} }
} }
// 清理下缓存数据
PhotoDataManager.manager.removeDataWhenDeleteInPage(data: self.selectedModel)
// 给首页发通知,数据删除
let dataUpdated = Notification.Name("DataUpdatedNotification")
NotificationCenter.default.post(name: dataUpdated, object: nil, userInfo: nil)
// 更新页面
DispatchQueue.main.async {
UIView.transition(with: self.collectionView, duration: 0.3, options: .transitionCrossDissolve, animations: {
self.collectionView.reloadData()
}, completion: nil)
}
} }
......
...@@ -49,14 +49,7 @@ class HomeVideoDetailController :BaseViewController { ...@@ -49,14 +49,7 @@ class HomeVideoDetailController :BaseViewController {
var selectedModel : [AssetModel] = [] { var selectedModel : [AssetModel] = [] {
didSet{ didSet{
DispatchQueue.main.async { [self] in DispatchQueue.main.async { [self] in
if self.selectedModel.count == 0 { if self.selectedModel.count != 0 {
// self.deleteButton.isHidden = true
// self.headerHeight = 168
// self.currentHeaderView?.tipBackView.isHidden = false
}else{
// self.headerHeight = 90
// self.currentHeaderView?.tipBackView.isHidden = true
// self.deleteButton.isHidden = false
if self.selectedModel.count == 1{ if self.selectedModel.count == 1{
self.deleteButton.setTitle("Delete", for: .normal) self.deleteButton.setTitle("Delete", for: .normal)
} else if self.selectedModel.count == 1{ } else if self.selectedModel.count == 1{
...@@ -296,6 +289,7 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie ...@@ -296,6 +289,7 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "HomeVideoDetailCustomHeaderView", for: indexPath) as! HomeVideoDetailCustomHeaderView let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "HomeVideoDetailCustomHeaderView", for: indexPath) as! HomeVideoDetailCustomHeaderView
// 记录当前的 headerView // 记录当前的 headerView
currentHeaderView = header currentHeaderView = header
header.sizeLabel.text = "\(self.resourceData.count) Videos"
header.sortCallback = {[weak self] in header.sortCallback = {[weak self] in
guard let self else {return} guard let self else {return}
let sortView = CompressSortView(frame: self.view.bounds) let sortView = CompressSortView(frame: self.view.bounds)
...@@ -327,6 +321,16 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie ...@@ -327,6 +321,16 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
@objc func deleteButtonAction(){ @objc func deleteButtonAction(){
if HomePayModel.share.isNoAd == false {
HomePayViewController.show {
self.deleteAction()
}
}else {
self.deleteAction()
}
}
func deleteAction(){
// 删除当前选择 // 删除当前选择
let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: self.selectedModel.map{$0.localIdentifier}, options: nil) let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: self.selectedModel.map{$0.localIdentifier}, options: nil)
PHPhotoLibrary.shared().performChanges ({ PHPhotoLibrary.shared().performChanges ({
...@@ -335,24 +339,42 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie ...@@ -335,24 +339,42 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
if(success){ if(success){
print("删除文件成功") print("删除文件成功")
// 移除当前总数据源的数据 // 移除当前总数据源的数据
for item in self.selectedModel { self.updateCurrentPageWhenDeleteAny()
self.resourceData.removeAll{ $0.localIdentifier == item.localIdentifier }
}
PhotoDataManager.manager.removeDataWhenDeleteInPage(data: self.selectedModel)
}else { }else {
if let error = error { if let error = error {
print("删除文件时出错: \(error.localizedDescription)") print("删除文件时出错: \(error.localizedDescription)")
} }
} }
// 更新页面
}
}
func updateCurrentPageWhenDeleteAny(){
for item in self.selectedModel {
// 移除当前数据
self.resourceData.removeAll{ $0.localIdentifier == item.localIdentifier }
// 更新下头部数量
DispatchQueue.main.async { DispatchQueue.main.async {
self.clearSelected() if self.currentHeaderView != nil {
self.collectionView.reloadSections(IndexSet(integer: 0)) self.currentHeaderView?.sizeLabel.text = "\(self.resourceData.count) Videos"
}
} }
} }
// 清理下缓存数据
PhotoDataManager.manager.removeDataWhenDeleteInPage(data: self.selectedModel)
// 给首页发通知,数据删除
let dataUpdated = Notification.Name("DataUpdatedNotification")
NotificationCenter.default.post(name: dataUpdated, object: nil, userInfo: nil)
// 更新页面
DispatchQueue.main.async {
UIView.transition(with: self.collectionView, duration: 0.3, options: .transitionCrossDissolve, animations: {
self.collectionView.reloadData()
}, completion: nil)
}
} }
......
...@@ -360,45 +360,6 @@ class HomeViewController:BaseViewController { ...@@ -360,45 +360,6 @@ class HomeViewController:BaseViewController {
self?.homeView?.collectionView.reloadData() self?.homeView?.collectionView.reloadData()
} }
}) })
// if let userInfo = notification.userInfo {
// let type : PhotsFileType = userInfo["type"] as! PhotsFileType
// let deleteIndex : [Int] = (userInfo["deleteIndex"] as? [Int])!
// for item in deleteIndex {
// switch type {
// case .duplicates :
// self.homeView?.model?.titleModelArray.first?.assets.remove(at: item)
// break
// case .similar :
// self.homeView?.model?.titleModelArray[1].assets.remove(at: item)
// break
// case .similarScreenshots:
// self.homeView?.model?.otherModelArray[1].assets.remove(at: item)
// break
// case .SimilarVideos:
// self.homeView?.model?.titleModelArray[3].assets.remove(at: item)
// break
// case .videos:
// break
// case .screenshots:
// break
// case .Other:
// break
// }
// }
// // 更新缓存数据
// if self.homeView?.model != nil{
// PhotoDataManager.manager.saveToFileSystem(model: (self.homeView?.model)!)
// }
// DispatchQueue.main.async {
// self.homeView?.collectionView.reloadData()
// }
//
//
// } else {
// print("接收到数据更新通知,但没有携带额外信息")
// }
} }
} }
...@@ -196,17 +196,9 @@ class HomeInfoView :UIView{ ...@@ -196,17 +196,9 @@ class HomeInfoView :UIView{
} }
models[i].smodels = models[i].smodels?.filter { !($0.isSeleted ?? false) } models[i].smodels = models[i].smodels?.filter { !($0.isSeleted ?? false) }
} }
var modelRecordDelete : [Int] = []
for index in modelRecord {
if models[index].smodels!.count < 2 {
models.remove(at: index)
modelRecordDelete.append(index)
}
}
// 更新下首页数据以及缓存数据 // 更新下首页数据以及缓存数据
let dataUpdated = Notification.Name("DataUpdatedNotification") let dataUpdated = Notification.Name("DataUpdatedNotification")
let userInfo = ["type": self.type as Any,"deleteIndex" : modelRecordDelete] as [String : Any] NotificationCenter.default.post(name: dataUpdated, object: nil, userInfo: nil)
NotificationCenter.default.post(name: dataUpdated, object: nil, userInfo: userInfo)
DispatchQueue.main.async {[weak self] in DispatchQueue.main.async {[weak self] in
......
...@@ -49,7 +49,7 @@ class HomeVideoDetailCustomHeaderView : UICollectionReusableView { ...@@ -49,7 +49,7 @@ class HomeVideoDetailCustomHeaderView : UICollectionReusableView {
}() }()
lazy var sizeLabel :UILabel = { lazy var sizeLabel :UILabel = {
let label = UILabel() let label = UILabel()
label.text = "1.02 GB" label.text = "0 Videos"
label.textAlignment = .left label.textAlignment = .left
label.textColor = UIColor(red: 0, green: 0.51, blue: 1, alpha: 1) label.textColor = UIColor(red: 0, green: 0.51, blue: 1, alpha: 1)
label.font = UIFont.systemFont(ofSize: 14, weight: .regular) label.font = UIFont.systemFont(ofSize: 14, weight: .regular)
......
...@@ -257,6 +257,7 @@ extension HomeView:WaterfallMutiSectionDelegate,UICollectionViewDataSource,UICol ...@@ -257,6 +257,7 @@ extension HomeView:WaterfallMutiSectionDelegate,UICollectionViewDataSource,UICol
return cell return cell
case 1: case 1:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeOtherCollectionCell.identifier, for: indexPath) as! HomeOtherCollectionCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeOtherCollectionCell.identifier, for: indexPath) as! HomeOtherCollectionCell
cell.imageView.image = UIImage()
cell.playImageView.isHidden = true cell.playImageView.isHidden = true
cell.mediaType = 0 cell.mediaType = 0
if indexPath.row == 0 || indexPath.row == 3{ if indexPath.row == 0 || indexPath.row == 3{
......
...@@ -34,32 +34,56 @@ class PhotoDataManager { ...@@ -34,32 +34,56 @@ class PhotoDataManager {
func removeDataWhenDeleteInPage(data:[AssetModel]){ func removeDataWhenDeleteInPage(data:[AssetModel]){
// 将所有的数据遍历删除
PhotoDataManager.manager.loadFromFileSystem(resultModel: {[weak self] model in PhotoDataManager.manager.loadFromFileSystem(resultModel: {[weak self] model in
guard let self else {return}
// 删除视频和图片和截图缓存 // 删除视频和图片和截图缓存
var size :Double = 0.0
for index in 0..<model.otherModelArray.count { for index in 0..<model.otherModelArray.count {
// 如果是视频、截图、其他
if index == 0 || index == 2 || index == 4 { if index == 0 || index == 2 || index == 4 {
var array = model.otherModelArray[index].assets.first var array = model.otherModelArray[index].assets.first
for item in data { if array != nil {
array = array?.filter { $0.localIdentifier != item.localIdentifier } for item in data {
array!.removeAll{ $0.localIdentifier == item.localIdentifier }
}
var finalyVideoData : [[AssetModel]] = []
finalyVideoData.append(array!)
// 计算下size
for assModel in array! {
size = size + Double(assModel.assetSize)
}
model.otherModelArray[index].assets = finalyVideoData
// 处理完成保存下当前数据
self.saveToFileSystem(model: model)
} }
var finalyVideoData : [[AssetModel]] = []
finalyVideoData.append(array!)
model.otherModelArray[index].assets = finalyVideoData
}else{ }else{
// 删除相似截图和相似视频的缓存 // 删除相似截图和相似视频的缓存
let array = model.otherModelArray[index].assets
var finalyVideoData : [[AssetModel]] = [] var finalyVideoData : [[AssetModel]] = []
let array = model.otherModelArray[index].assets
for item in data { for modelData in array {
for modelData in array { var tempArray = modelData
var tempArray = modelData // 移除所有包含的
tempArray = tempArray.filter { $0.localIdentifier != item.localIdentifier } for item in data {
if tempArray.count >= 2 { tempArray.removeAll{$0.localIdentifier == item.localIdentifier}
finalyVideoData.append(tempArray) }
// 移除之后,如果大于2,表明还是一组相似内容
if tempArray.count >= 2 {
finalyVideoData.append(tempArray)
// 计算下size
for assModel in tempArray {
size = size + Double(assModel.assetSize)
} }
} }
} }
model.otherModelArray[index].assets = finalyVideoData model.otherModelArray[index].assets = finalyVideoData
model.otherModelArray[index].allFileSize = size
// 处理完成保存下
self.saveToFileSystem(model: model)
} }
} }
...@@ -68,47 +92,49 @@ class PhotoDataManager { ...@@ -68,47 +92,49 @@ class PhotoDataManager {
var size :Double = 0.0 var size :Double = 0.0
var finalyVideoData : [[AssetModel]] = [] var finalyVideoData : [[AssetModel]] = []
let array = model.titleModelArray[index].assets let array = model.titleModelArray[index].assets
for item in data {
for modelData in array { for modelData in array {
var tempArray = modelData var tempArray = modelData
tempArray = tempArray.filter { $0.localIdentifier != item.localIdentifier } for item in data {
if tempArray.count >= 2 { tempArray.removeAll{$0.localIdentifier == item.localIdentifier}
finalyVideoData.append(tempArray) }
}else{ if tempArray.count >= 2 {
// 计算下size finalyVideoData.append(tempArray)
for assModel in tempArray { // 计算下size
size = size + Double(assModel.assetSize) for assModel in tempArray {
} size = size + Double(assModel.assetSize)
} }
} }
} }
model.titleModelArray[index].assets = finalyVideoData model.titleModelArray[index].assets = finalyVideoData
model.titleModelArray[index].allFileSize = size model.titleModelArray[index].allFileSize = size
// 计算size self.saveToFileSystem(model: model)
} }
self?.saveToFileSystem(model: model)
}) })
// 将磁盘中存的内容也删除 // 将磁盘中存的内容也删除
var allImageUpdateLocation : [String] = UserDefaults.standard.object(forKey: "allImageUpdateLocationDate") as! [String] let allImageUpdateLocation : [String] = UserDefaults.standard.object(forKey: "allImageUpdateLocationDate") as! [String]
var tempArray = allImageUpdateLocation
for item in data{ for item in data{
allImageUpdateLocation = allImageUpdateLocation.filter { $0 != item.localIdentifier } tempArray.removeAll{$0 == item.localIdentifier}
} }
UserDefaults.standard.set(allImageUpdateLocation, forKey: "allImageUpdateLocationDate") UserDefaults.standard.set(tempArray, forKey: "allImageUpdateLocationDate")
var screenshotUpdateLocation : [String] = UserDefaults.standard.object(forKey: "screenshotUpdateLocationDate") as! [String] var screenshotUpdateLocation : [String] = UserDefaults.standard.object(forKey: "screenshotUpdateLocationDate") as! [String]
var tempArraySC = screenshotUpdateLocation
for item in data{ for item in data{
screenshotUpdateLocation = screenshotUpdateLocation.filter { $0 != item.localIdentifier } tempArraySC.removeAll{$0 == item.localIdentifier}
} }
UserDefaults.standard.set(screenshotUpdateLocation, forKey: "screenshotUpdateLocationDate") UserDefaults.standard.set(tempArraySC, forKey: "screenshotUpdateLocationDate")
// 删除更新中的数据
for item in data{
screenshotUpdateLocation.removeAll{$0 == item.localIdentifier}
}
// 将单利中的数据也删除 // 将单利中的数据也删除
for item in data { for item in data {
Singleton.shared.resourceModel.removeAll{ $0.ident == item.localIdentifier } Singleton.shared.resourceModel.removeAll{ $0.ident == item.localIdentifier }
} }
} }
// 从文件读取 // 从文件读取
...@@ -169,9 +195,9 @@ class PhotoDataManager { ...@@ -169,9 +195,9 @@ class PhotoDataManager {
PhotoAndVideoMananger.mananger.calculateTotalSize(of: PhotoAndVideoMananger.mananger.getPHAsssetwithIDs(ids: dataArray1)!,progress: { fileSiez, index in PhotoAndVideoMananger.mananger.calculateTotalSize(of: PhotoAndVideoMananger.mananger.getPHAsssetwithIDs(ids: dataArray1)!,progress: { fileSiez, index in
// 不做处理 // 不做处理
}, completion: { fileSize,index in }, completion: { fileSize,index in
model1.assets = data1 // model1.assets = data1
model1.allFileSize = Double(fileSize) // model1.allFileSize = Double(fileSize)
PhotoDataManager.manager.saveToFileSystem(model: allModel) // PhotoDataManager.manager.saveToFileSystem(model: allModel)
let dataUpdated = Notification.Name("HomeDupImageResourceUpdate") let dataUpdated = Notification.Name("HomeDupImageResourceUpdate")
NotificationCenter.default.post(name: dataUpdated, object: nil) NotificationCenter.default.post(name: dataUpdated, object: nil)
......
...@@ -13,7 +13,7 @@ class HomeOtherCollectionCell: UICollectionViewCell { ...@@ -13,7 +13,7 @@ class HomeOtherCollectionCell: UICollectionViewCell {
// MARK: - Properties // MARK: - Properties
static let identifier = "HomeOtherCollectionCellID" static let identifier = "HomeOtherCollectionCellID"
private let imageView: UIImageView = { public let imageView: UIImageView = {
let iv = UIImageView() let iv = UIImageView()
iv.contentMode = .scaleAspectFill iv.contentMode = .scaleAspectFill
iv.clipsToBounds = true iv.clipsToBounds = true
......
...@@ -11,6 +11,7 @@ import UIKit ...@@ -11,6 +11,7 @@ import UIKit
import Vision import Vision
import CoreML import CoreML
import HXPhotoPicker import HXPhotoPicker
import CryptoKit
enum SoureceType { enum SoureceType {
case Photo case Photo
...@@ -677,9 +678,9 @@ class PhotoAndVideoMananger { ...@@ -677,9 +678,9 @@ class PhotoAndVideoMananger {
// 图片请求选项 // 图片请求选项
let imageRequestOptions = PHImageRequestOptions() let imageRequestOptions = PHImageRequestOptions()
imageRequestOptions.isSynchronous = true imageRequestOptions.isSynchronous = true
imageRequestOptions.deliveryMode = .highQualityFormat imageRequestOptions.deliveryMode = .fastFormat
// 缓存没有再去加载下 // 缓存没有再去加载下
PHImageManager.default().requestImage(for: asset, targetSize: CGSizeMake(400, 400), contentMode: .aspectFit, options: imageRequestOptions) {image, info in PHImageManager.default().requestImage(for: asset, targetSize: CGSizeMake(100, 100), contentMode: .aspectFit, options: imageRequestOptions) {image, info in
if image != nil { if image != nil {
// 存入缓存 // 存入缓存
self.imageCache.setObject(image!, forKey: asset.localIdentifier as NSString) self.imageCache.setObject(image!, forKey: asset.localIdentifier as NSString)
...@@ -699,7 +700,7 @@ class PhotoAndVideoMananger { ...@@ -699,7 +700,7 @@ class PhotoAndVideoMananger {
// 图片请求选项 // 图片请求选项
let imageRequestOptions = PHImageRequestOptions() let imageRequestOptions = PHImageRequestOptions()
imageRequestOptions.isSynchronous = true imageRequestOptions.isSynchronous = true
imageRequestOptions.deliveryMode = .highQualityFormat imageRequestOptions.deliveryMode = .fastFormat
var groupDuplicateAssets :[[AssetModel]] = [] var groupDuplicateAssets :[[AssetModel]] = []
...@@ -712,14 +713,10 @@ class PhotoAndVideoMananger { ...@@ -712,14 +713,10 @@ class PhotoAndVideoMananger {
} }
for (currentIndex, currentAsset) in tempAssets.enumerated() { for (currentIndex, currentAsset) in tempAssets.enumerated() {
// 去重 // 去重
let uniqueArray = saveFinisedArray.reduce(into: [String]()) { result, element in let mySet = Set(saveFinisedArray)
if !result.contains(element) { saveFinisedArray = Array(mySet)
result.append(element)
}
}
saveFinisedArray = uniqueArray
// 判断是否已经处理过了 // 判断是否已经处理过了
if saveFinisedArray.contains(currentAsset.localIdentifier){ if saveFinisedArray.contains(currentAsset.localIdentifier){
continue continue
...@@ -736,7 +733,6 @@ class PhotoAndVideoMananger { ...@@ -736,7 +733,6 @@ class PhotoAndVideoMananger {
if image1 == nil { if image1 == nil {
continue continue
} }
let nextIndex = currentIndex + 1 let nextIndex = currentIndex + 1
if nextIndex <= tempAssets.count { if nextIndex <= tempAssets.count {
for changeIndex in nextIndex..<tempAssets.count { for changeIndex in nextIndex..<tempAssets.count {
...@@ -750,15 +746,26 @@ class PhotoAndVideoMananger { ...@@ -750,15 +746,26 @@ class PhotoAndVideoMananger {
continue continue
} }
let isSamilar : Double = OpenCVWrapper.compareImageSimilarity(image1, withImage2: image2) let isSamilar : Double = OpenCVWrapper.compareImageSimilarity(image1, withImage2: image2)
if isSamilar > 0.9999 { if isSamilar > 0.9999 {
currentDuplicateGroup.append(AssetModel(localIdentifier: changeAsset.localIdentifier, assetSize: self.findAssetSize(asset: changeAsset), createDate: changeAsset.creationDate!)) currentDuplicateGroup.append(AssetModel(localIdentifier: changeAsset.localIdentifier, assetSize: self.findAssetSize(asset: changeAsset), createDate: changeAsset.creationDate!))
saveFinisedArray.append(currentAsset.localIdentifier) saveFinisedArray.append(currentAsset.localIdentifier)
saveFinisedArray.append(changeAsset.localIdentifier)
if type == 0 {
UserDefaults.standard.set(saveFinisedArray , forKey: "allImageUpdateLocationDate")
}else{
UserDefaults.standard.set(saveFinisedArray, forKey: "screenshotUpdateLocationDate")
}
continue continue
} }
if isSamilar > 0.9995 && isSamilar < 0.9999{ if isSamilar > 0.85 && isSamilar < 0.999{
currentSimilarGroup.append(AssetModel(localIdentifier: changeAsset.localIdentifier, assetSize: self.findAssetSize(asset: changeAsset), createDate: changeAsset.creationDate!)) currentSimilarGroup.append(AssetModel(localIdentifier: changeAsset.localIdentifier, assetSize: self.findAssetSize(asset: changeAsset), createDate: changeAsset.creationDate!))
saveFinisedArray.append(currentAsset.localIdentifier) saveFinisedArray.append(currentAsset.localIdentifier)
saveFinisedArray.append(changeAsset.localIdentifier)
if type == 0 {
UserDefaults.standard.set(saveFinisedArray , forKey: "allImageUpdateLocationDate")
}else{
UserDefaults.standard.set(saveFinisedArray, forKey: "screenshotUpdateLocationDate")
}
} }
} }
if(currentSimilarGroup.count >= 2){ if(currentSimilarGroup.count >= 2){
...@@ -767,7 +774,6 @@ class PhotoAndVideoMananger { ...@@ -767,7 +774,6 @@ class PhotoAndVideoMananger {
if(currentDuplicateGroup.count >= 2){ if(currentDuplicateGroup.count >= 2){
groupDuplicateAssets.append(currentDuplicateGroup) groupDuplicateAssets.append(currentDuplicateGroup)
} }
if currentSimilarGroup.count >= 2 || currentDuplicateGroup.count >= 2 { if currentSimilarGroup.count >= 2 || currentDuplicateGroup.count >= 2 {
// 更新回调 // 更新回调
processHandler(groupDuplicateAssets,groupSimilarAssets) processHandler(groupDuplicateAssets,groupSimilarAssets)
...@@ -780,7 +786,6 @@ class PhotoAndVideoMananger { ...@@ -780,7 +786,6 @@ class PhotoAndVideoMananger {
}else{ }else{
UserDefaults.standard.set(saveFinisedArray, forKey: "screenshotUpdateLocationDate") UserDefaults.standard.set(saveFinisedArray, forKey: "screenshotUpdateLocationDate")
} }
} }
// 全部请求结束之后,清理下缓存 // 全部请求结束之后,清理下缓存
......
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