Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PhoneManager
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yang
PhoneManager
Commits
96dd0303
Commit
96dd0303
authored
Apr 15, 2025
by
CZ1004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
06ce2ebf
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
203 additions
and
126 deletions
+203
-126
AppDelegate.swift
PhoneManager/AppDelegate.swift
+11
-0
CompressController.swift
...lass/Session/Compress/Controller/CompressController.swift
+12
-0
HomeInfoViewController.swift
...lass/Session/Home/Controller/HomeInfoViewController.swift
+18
-0
HomePhotosDetailViewController.swift
...sion/Home/Controller/HomePhotosDetailViewController.swift
+38
-9
HomeVideoDetailController.swift
...s/Session/Home/Controller/HomeVideoDetailController.swift
+38
-16
HomeViewController.swift
...er/Class/Session/Home/Controller/HomeViewController.swift
+0
-39
HomeInfoView.swift
PhoneManager/Class/Session/Home/View/HomeInfoView.swift
+1
-9
HomeVideoDetailCustomHeaderView.swift
...s/Session/Home/View/HomeVideoDetailCustomHeaderView.swift
+1
-1
HomeView.swift
PhoneManager/Class/Session/Home/View/HomeView.swift
+1
-0
HomePhotosModel .swift
...ager/Class/Session/Home/View/Model/HomePhotosModel .swift
+62
-36
HomeOtherCollectionCell.swift
...lass/Session/Home/View/cell/HomeOtherCollectionCell.swift
+1
-1
PhotoAndVideoMananger.swift
...l/Class/PhotoAndVideoMananger/PhotoAndVideoMananger.swift
+20
-15
No files found.
PhoneManager/AppDelegate.swift
View file @
96dd0303
...
@@ -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
]]
=
[]
...
...
PhoneManager/Class/Session/Compress/Controller/CompressController.swift
View file @
96dd0303
...
@@ -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
...
...
PhoneManager/Class/Session/Home/Controller/HomeInfoViewController.swift
View file @
96dd0303
...
@@ -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
()
}
}
}
}
...
...
PhoneManager/Class/Session/Home/Controller/HomePhotosDetailViewController.swift
View file @
96dd0303
...
@@ -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
)
}
}
}
...
...
PhoneManager/Class/Session/Home/Controller/HomeVideoDetailController.swift
View file @
96dd0303
...
@@ -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
)
}
}
}
...
...
PhoneManager/Class/Session/Home/Controller/HomeViewController.swift
View file @
96dd0303
...
@@ -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("接收到数据更新通知,但没有携带额外信息")
// }
}
}
}
}
PhoneManager/Class/Session/Home/View/HomeInfoView.swift
View file @
96dd0303
...
@@ -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
...
...
PhoneManager/Class/Session/Home/View/HomeVideoDetailCustomHeaderView.swift
View file @
96dd0303
...
@@ -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
)
...
...
PhoneManager/Class/Session/Home/View/HomeView.swift
View file @
96dd0303
...
@@ -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
{
...
...
PhoneManager/Class/Session/Home/View/Model/HomePhotosModel .swift
View file @
96dd0303
...
@@ -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
)
...
...
PhoneManager/Class/Session/Home/View/cell/HomeOtherCollectionCell.swift
View file @
96dd0303
...
@@ -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"
p
rivate
let
imageView
:
UIImageView
=
{
p
ublic
let
imageView
:
UIImageView
=
{
let
iv
=
UIImageView
()
let
iv
=
UIImageView
()
iv
.
contentMode
=
.
scaleAspectFill
iv
.
contentMode
=
.
scaleAspectFill
iv
.
clipsToBounds
=
true
iv
.
clipsToBounds
=
true
...
...
PhoneManager/Class/Tool/Class/PhotoAndVideoMananger/PhotoAndVideoMananger.swift
View file @
96dd0303
...
@@ -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
=
.
highQuality
Format
imageRequestOptions
.
deliveryMode
=
.
fast
Format
// 缓存没有再去加载下
// 缓存没有再去加载下
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
CGSizeMake
(
400
,
4
00
),
contentMode
:
.
aspectFit
,
options
:
imageRequestOptions
)
{
image
,
info
in
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
CGSizeMake
(
100
,
1
00
),
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
=
.
highQuality
Format
imageRequestOptions
.
deliveryMode
=
.
fast
Format
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.9
999
{
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"
)
}
}
}
}
// 全部请求结束之后,清理下缓存
// 全部请求结束之后,清理下缓存
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment