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
7ab40d47
Commit
7ab40d47
authored
Apr 11, 2025
by
CZ1004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bug
parent
de98cae7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
38 deletions
+71
-38
CompressCompletedViewController.swift
...Compress/Controller/CompressCompletedViewController.swift
+2
-1
HomePhotosDetailViewController.swift
...sion/Home/Controller/HomePhotosDetailViewController.swift
+7
-5
HomeVideoDetailController.swift
...s/Session/Home/Controller/HomeVideoDetailController.swift
+22
-6
HomePhotosModel .swift
...ager/Class/Session/Home/View/Model/HomePhotosModel .swift
+15
-12
PMShowImgVideoController.swift
...nager/Class/Session/Secret/PMShowImgVideoController.swift
+14
-5
PhotoAndVideoMananger.swift
...l/Class/PhotoAndVideoMananger/PhotoAndVideoMananger.swift
+11
-9
No files found.
PhoneManager/Class/Session/Compress/Controller/CompressCompletedViewController.swift
View file @
7ab40d47
...
@@ -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
)
}
}
}
}
PhoneManager/Class/Session/Home/Controller/HomePhotosDetailViewController.swift
View file @
7ab40d47
...
@@ -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
)
Vide
os"
,
for
:
.
normal
)
self
.
deleteButton
.
setTitle
(
"Delete
\(
selectedModel
.
count
)
Phot
os"
,
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
]
=
[]
...
...
PhoneManager/Class/Session/Home/Controller/HomeVideoDetailController.swift
View file @
7ab40d47
...
@@ -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
]
=
[]
...
...
PhoneManager/Class/Session/Home/View/Model/HomePhotosModel .swift
View file @
7ab40d47
...
@@ -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
)
}
}
}
}
}
...
...
PhoneManager/Class/Session/Secret/PMShowImgVideoController.swift
View file @
7ab40d47
...
@@ -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"
]))
}
}
}
}
}
}
}
...
...
PhoneManager/Class/Tool/Class/PhotoAndVideoMananger/PhotoAndVideoMananger.swift
View file @
7ab40d47
...
@@ -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
:
fetchOptions
S
)
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
..<
all
Assets
.
count
))
let
assetsArray
=
screenshotAssets
.
objects
(
at
:
IndexSet
(
0
..<
screenshot
Assets
.
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
.
image
Assets
{
for
item
in
self
.
other
Assets
{
data
.
append
(
item
.
localIdentifier
)
data
.
append
(
item
.
localIdentifier
)
}
}
var
finalData
:
[[
String
]]
=
[]
var
finalData
:
[[
String
]]
=
[]
...
...
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