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
0d4d241e
Commit
0d4d241e
authored
Apr 29, 2025
by
CZ1004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修复】
1、跳转问题 2、缓存问题 3、首页UI问题 4、磁盘占用空间更改
parent
ea238559
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
142 additions
and
146 deletions
+142
-146
CompressSelectCell.swift
...ager/Class/Session/Compress/Cell/CompressSelectCell.swift
+5
-5
CompressQualityController.swift
...ssion/Compress/Controller/CompressQualityController.swift
+5
-5
CompressCustomHeaderView.swift
...lass/Session/Compress/View/CompressCustomHeaderView.swift
+9
-9
CompressViewModel.swift
.../Class/Session/Compress/ViewModel/CompressViewModel.swift
+1
-1
HomeInfoViewController.swift
...lass/Session/Home/Controller/HomeInfoViewController.swift
+0
-6
HomePhotosDetailViewController.swift
...sion/Home/Controller/HomePhotosDetailViewController.swift
+1
-3
HomeVideoDetailController.swift
...s/Session/Home/Controller/HomeVideoDetailController.swift
+1
-3
HomeCollectionViewHeader.swift
...er/Class/Session/Home/View/HomeCollectionViewHeader.swift
+51
-40
HomeNavView.swift
PhoneManager/Class/Session/Home/View/HomeNavView.swift
+1
-1
HomePhotosModel .swift
...ager/Class/Session/Home/View/Model/HomePhotosModel .swift
+5
-1
HomeOtherCollectionCell.swift
...lass/Session/Home/View/cell/HomeOtherCollectionCell.swift
+5
-5
HomeVideoDetailCell.swift
...er/Class/Session/Home/View/cell/HomeVideoDetailCell.swift
+5
-5
PMShowVideoCell.swift
PhoneManager/Class/Session/Secret/Cell/PMShowVideoCell.swift
+6
-4
PMShowImgVideoController.swift
...nager/Class/Session/Secret/PMShowImgVideoController.swift
+13
-3
SecretVideoPlayer.swift
...Manager/Class/Session/Secret/View/SecretVideoPlayer.swift
+5
-2
WidgetPublicModel.swift
...anager/Class/Session/Widget/Model/WidgetPublicModel.swift
+15
-3
PhotoAndVideoMananger.swift
...l/Class/PhotoAndVideoMananger/PhotoAndVideoMananger.swift
+12
-48
CommonFunc.swift
PhoneManager/Class/Tool/Common/CommonFunc.swift
+2
-2
No files found.
PhoneManager/Class/Session/Compress/Cell/CompressSelectCell.swift
View file @
0d4d241e
...
...
@@ -41,14 +41,14 @@ class CompressSelectCell : UICollectionViewCell {
let
compressCompletedSize
=
Double
(
compressedData
.
count
)
let
saveSize
=
model
.
orgSize
-
compressCompletedSize
let
sizeKB
:
Double
=
saveSize
/
10
24
let
sizeKB
:
Double
=
saveSize
/
10
00
DispatchQueue
.
main
.
async
{
if
sizeKB
<
10
24
{
if
sizeKB
<
10
00
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f KB"
,
sizeKB
)
}
else
if
sizeKB
<
(
10
24
*
1024
)
&&
sizeKB
>
1024
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f MB"
,
sizeKB
/
10
24
)
}
else
if
sizeKB
<
(
10
00
*
1000
)
&&
sizeKB
>
1000
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f MB"
,
sizeKB
/
10
00
)
}
else
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f GB"
,
sizeKB
/
(
10
24
*
1024
))
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f GB"
,
sizeKB
/
(
10
00
*
1000
))
}
}
}
...
...
PhoneManager/Class/Session/Compress/Controller/CompressQualityController.swift
View file @
0d4d241e
...
...
@@ -199,15 +199,15 @@ class CompressQualityController : BaseViewController{
orgAllSize
=
orgAllSize
+
modelData
.
orgSize
}
sum
=
orgAllSize
-
compressAllSize
sum
=
sum
/
10
24
sum
=
sum
/
10
00
if
sum
<
10
24
{
if
sum
<
10
00
{
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfKB"
,
sum
)
}
else
if
sum
<
(
10
24
*
1024
)
&&
sum
>
1024
{
sum
=
sum
/
10
24
}
else
if
sum
<
(
10
00
*
1000
)
&&
sum
>
1000
{
sum
=
sum
/
10
00
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfMB"
,
sum
)
}
else
{
sum
=
sum
/
(
10
24
*
1024
)
sum
=
sum
/
(
10
00
*
1000
)
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfGB"
,
sum
)
}
let
str
=
String
(
format
:
"%.2lf"
,(
orgAllSize
-
compressAllSize
)
/
orgAllSize
)
...
...
PhoneManager/Class/Session/Compress/View/CompressCustomHeaderView.swift
View file @
0d4d241e
...
...
@@ -22,21 +22,21 @@ class CompressCustomHeaderView: UICollectionReusableView{
saveSum
=
saveSum
+
model
.
orgSize
*
0.8
}
sum
=
sum
/
1000
saveSum
=
saveSum
/
10
24
if
sum
<
10
24
{
saveSum
=
saveSum
/
10
00
if
sum
<
10
00
{
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f KB"
,(
sum
))
}
else
if
sum
<
(
10
24
*
1024
)
&&
sum
>
1024
{
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f MB"
,(
sum
/
10
24
))
}
else
if
sum
<
(
10
00
*
1000
)
&&
sum
>
1024
{
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f MB"
,(
sum
/
10
00
))
}
else
{
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f GB"
,
sum
/
(
10
24*
1024
))
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f GB"
,
sum
/
(
10
00*
1000
))
}
if
saveSum
<
10
24
{
if
saveSum
<
10
00
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f KB"
,(
saveSum
))
}
else
if
saveSum
<
(
10
24
*
1024
)
&&
saveSum
>
1024
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f MB"
,(
saveSum
/
10
24
))
}
else
if
saveSum
<
(
10
00
*
1000
)
&&
saveSum
>
1024
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f MB"
,(
saveSum
/
10
00
))
}
else
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f GB"
,
saveSum
/
(
10
24*
1024
))
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f GB"
,
saveSum
/
(
10
00*
1000
))
}
}
...
...
PhoneManager/Class/Session/Compress/ViewModel/CompressViewModel.swift
View file @
0d4d241e
...
...
@@ -401,7 +401,7 @@ class CompressViewModel{
let
imageManager
=
PHCachingImageManager
()
let
options
=
PHImageRequestOptions
()
options
.
isSynchronous
=
false
options
.
deliveryMode
=
.
highQualityFormat
options
.
deliveryMode
=
.
opportunistic
options
.
isNetworkAccessAllowed
=
true
imageManager
.
requestImage
(
for
:
asset
,
targetSize
:
CGSize
(
width
:
400
,
height
:
400
),
contentMode
:
.
aspectFill
,
options
:
options
)
{
(
image
,
_
)
in
...
...
PhoneManager/Class/Session/Home/Controller/HomeInfoViewController.swift
View file @
0d4d241e
...
...
@@ -104,12 +104,6 @@ class HomeInfoViewController:BaseViewController {
})
}
// 更新下首页数据以及缓存数据
let
dataUpdated
=
Notification
.
Name
(
"DataUpdatedNotification"
)
NotificationCenter
.
default
.
post
(
name
:
dataUpdated
,
object
:
nil
,
userInfo
:
nil
)
func
updateFreeTimes
(){
// 删除成功后更新次数
var
times
=
UserDefaults
.
standard
.
object
(
forKey
:
"saveAdvTimes"
)
as!
Int
...
...
PhoneManager/Class/Session/Home/Controller/HomePhotosDetailViewController.swift
View file @
0d4d241e
...
...
@@ -622,9 +622,7 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti
// 清理下缓存数据
PhotoDataManager
.
manager
.
removeDataWhenDeleteInPage
(
data
:
self
.
selectedModel
)
// 给首页发通知,数据删除
let
dataUpdated
=
Notification
.
Name
(
"DataUpdatedNotification"
)
NotificationCenter
.
default
.
post
(
name
:
dataUpdated
,
object
:
nil
,
userInfo
:
nil
)
// 更新页面
...
...
PhoneManager/Class/Session/Home/Controller/HomeVideoDetailController.swift
View file @
0d4d241e
...
...
@@ -540,9 +540,7 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
// 清理下缓存数据
PhotoDataManager
.
manager
.
removeDataWhenDeleteInPage
(
data
:
self
.
selectedModel
)
// 给首页发通知,数据删除
let
dataUpdated
=
Notification
.
Name
(
"DataUpdatedNotification"
)
NotificationCenter
.
default
.
post
(
name
:
dataUpdated
,
object
:
nil
,
userInfo
:
nil
)
// 更新页面
...
...
PhoneManager/Class/Session/Home/View/HomeCollectionViewHeader.swift
View file @
0d4d241e
...
...
@@ -74,16 +74,16 @@ class HomeCollectionViewHeader : UICollectionReusableView {
// 文本
self
.
addSubview
(
self
.
tipLabel
)
self
.
tipLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
offset
(
8
)
make
.
top
.
equalToSuperview
()
.
offset
(
4
)
make
.
height
.
equalTo
(
17
)
}
self
.
addSubview
(
self
.
progressBar
)
self
.
progressBar
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
self
.
tipLabel
.
snp
.
bottom
)
.
offset
(
12
)
make
.
width
.
equalToSuperview
()
make
.
width
.
equalToSuperview
()
.
offset
(
-
16
)
make
.
height
.
equalTo
(
31
)
make
.
left
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
offset
(
8
)
}
// self.addSubview(self.subTiplabel)
...
...
@@ -163,12 +163,30 @@ class CustomProgressBar: UIView {
private
let
dotSize
:
CGFloat
=
8
private
let
labelSpacing
:
CGFloat
=
18
var
usedProgress
:
CGFloat
=
0
var
chaoticProgress
:
CGFloat
=
0
var
usedProgress
:
CGFloat
=
0
{
didSet
{
self
.
updateProgress
()
}
}
var
totalProgress
:
CGFloat
=
0
var
chaoticProgress
:
CGFloat
=
0
{
didSet
{
self
.
updateProgress
()
}
}
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
setupUI
()
let
disk
=
WidgetPublicModel
.
getDiskSpace
()
self
.
totalProgress
=
Double
(
disk
.
0
)
self
.
usedProgress
=
Double
(
disk
.
0
)
-
Double
(
disk
.
1
)
Task
{
let
photoData
=
await
Double
(
StorageManager
.
manager
.
getPhotoResourceMemory
())
self
.
chaoticProgress
=
photoData
}
}
required
init
?(
coder
:
NSCoder
)
{
...
...
@@ -177,22 +195,23 @@ class CustomProgressBar: UIView {
}
private
func
setupUI
()
{
layer
.
addSublayer
(
progressLayer
)
usedLabel
.
text
=
"Used"
usedLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
usedLabel
.
textColor
=
.
black
usedLabel
.
textColor
=
UIColor
.
colorWithHex
(
hexStr
:
black6Color
)
addSubview
(
usedLabel
)
chaoticLabel
.
text
=
"Chaotic content"
chaoticLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
chaoticLabel
.
textColor
=
.
black
chaoticLabel
.
textColor
=
UIColor
.
colorWithHex
(
hexStr
:
black6Color
)
addSubview
(
chaoticLabel
)
idleLabel
.
text
=
"Idle"
idleLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
idleLabel
.
textColor
=
.
black
idleLabel
.
textColor
=
UIColor
.
colorWithHex
(
hexStr
:
black6Color
)
addSubview
(
idleLabel
)
}
...
...
@@ -222,16 +241,10 @@ class CustomProgressBar: UIView {
}
private
func
updateProgress
()
{
DispatchQueue
.
global
(
qos
:
.
userInitiated
)
.
async
{
let
disk
=
WidgetPublicModel
.
getDiskSpace
()
let
usedData
=
Double
(
disk
.
1
)
let
tolData
=
Double
(
disk
.
0
)
Task
{
let
photoData
=
await
Double
(
StorageManager
.
manager
.
getPhotoResourceMemory
())
// 回到主线程更新 UI
DispatchQueue
.
main
.
async
{
let
usedProgress
=
CGFloat
(
usedData
/
tolData
)
let
chaoticProgress
=
CGFloat
(
photoData
/
tolData
)
let
usedProgress
=
CGFloat
(
self
.
usedProgress
/
self
.
totalProgress
)
let
chaoticProgress
=
CGFloat
(
self
.
chaoticProgress
/
self
.
totalProgress
)
let
totalProgress
=
usedProgress
+
chaoticProgress
let
remainingProgress
=
1
-
totalProgress
...
...
@@ -254,8 +267,6 @@ class CustomProgressBar: UIView {
self
.
progressLayer
.
sublayers
=
[
usedLayer
,
chaoticLayer
,
idleLayer
]
}
}
}
}
private
func
drawDot
(
at
point
:
CGPoint
,
color
:
UIColor
)
{
let
dotLayer
=
CAShapeLayer
()
...
...
PhoneManager/Class/Session/Home/View/HomeNavView.swift
View file @
0d4d241e
...
...
@@ -37,7 +37,7 @@ class HomeNavView:UIView {
// 标题
self
.
addSubview
(
self
.
homeTitle
)
self
.
homeTitle
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
15
)
make
.
left
.
equalTo
(
15
+
8
)
make
.
top
.
equalTo
(
8
+
statusBarHeight
)
make
.
height
.
equalTo
(
28
)
make
.
width
.
equalTo
(
149
)
...
...
PhoneManager/Class/Session/Home/View/Model/HomePhotosModel .swift
View file @
0d4d241e
...
...
@@ -84,7 +84,7 @@ class PhotoDataManager {
}
for
index
in
0
..<
model
.
titleModelArray
.
count
{
// 删除相似截图和相似视频的缓存
var
size
:
Double
=
0.0
var
size
:
Double
=
0.0
var
finalyVideoData
:
[[
AssetModel
]]
=
[]
let
array
=
model
.
titleModelArray
[
index
]
.
assets
...
...
@@ -106,6 +106,10 @@ class PhotoDataManager {
}
// 处理完成保存下当前数据
self
.
saveToFileSystem
(
model
:
model
)
// 更新下首页数据以及缓存数据
let
dataUpdated
=
Notification
.
Name
(
"DataUpdatedNotification"
)
NotificationCenter
.
default
.
post
(
name
:
dataUpdated
,
object
:
nil
,
userInfo
:
nil
)
})
// 将单利中的数据也删除
for
item
in
data
{
...
...
PhoneManager/Class/Session/Home/View/cell/HomeOtherCollectionCell.swift
View file @
0d4d241e
...
...
@@ -117,13 +117,13 @@ class HomeOtherCollectionCell: UICollectionViewCell {
self
.
countLabel
.
text
=
"
\(
count
)
Videos"
}
// 设置文件大小文字
let
sizeKB
:
Double
=
model
.
allFileSize
/
10
24
if
sizeKB
<
10
24
{
let
sizeKB
:
Double
=
model
.
allFileSize
/
10
00
if
sizeKB
<
10
00
{
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) KB"
,
sizeKB
)
}
else
if
sizeKB
<
(
10
24
*
1024
)
&&
sizeKB
>
1024
{
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) MB"
,
sizeKB
/
10
24
)
}
else
if
sizeKB
<
(
10
00
*
1000
)
&&
sizeKB
>
1000
{
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) MB"
,
sizeKB
/
10
00
)
}
else
{
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) GB"
,
sizeKB
/
(
10
24
*
1024
))
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) GB"
,
sizeKB
/
(
10
00
*
1000
))
}
}
...
...
PhoneManager/Class/Session/Home/View/cell/HomeVideoDetailCell.swift
View file @
0d4d241e
...
...
@@ -46,13 +46,13 @@ class HomeVideoDetailCell : UICollectionViewCell {
DispatchQueue
.
main
.
async
{
// 确保在主线程更新UI
self
.
backImageView
.
image
=
thumbnailImage
let
sizeKB
:
Double
=
Double
(
assetSize
/
10
24
)
if
sizeKB
<
10
24
{
let
sizeKB
:
Double
=
Double
(
assetSize
/
10
00
)
if
sizeKB
<
10
00
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f KB"
,
sizeKB
)
}
else
if
sizeKB
<
(
10
24
*
1024
)
&&
sizeKB
>
1024
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f MB"
,
sizeKB
/
10
24
)
}
else
if
sizeKB
<
(
10
00
*
1000
)
&&
sizeKB
>
1000
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f MB"
,
sizeKB
/
10
00
)
}
else
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f GB"
,
sizeKB
/
(
10
24
*
1024
))
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f GB"
,
sizeKB
/
(
10
00
*
1000
))
}
}
}
else
{
...
...
PhoneManager/Class/Session/Secret/Cell/PMShowVideoCell.swift
View file @
0d4d241e
...
...
@@ -18,15 +18,17 @@ class PMShowVideoCell: UICollectionViewCell {
var
type
:
Int
=
0
func
reload
()
->
Void
{
var
url
:
URL
var
url
:
URL
?
if
type
==
0
{
url
=
"SecretIm"
.
document
()
.
appendingPathComponent
(
playURL
)
}
else
{
url
=
homeResouceUrl
!
url
=
homeResouceUrl
}
if
let
url
=
url
{
player
.
playVideo
(
from
:
url
)
player
.
pause
()
}
}
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
...
...
PhoneManager/Class/Session/Secret/PMShowImgVideoController.swift
View file @
0d4d241e
...
...
@@ -185,14 +185,24 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
// 相似视频
if
collectionView
==
MaxCollection
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
PMShowVideoCellID
,
for
:
indexPath
)
as!
PMShowVideoCell
cell
.
homeResouceUrl
=
self
.
url
// 这里主动获取下视频的链接
let
ident
=
self
.
homeDataSource
?[
indexPath
.
row
]
.
id
?
.
localIdentifier
if
let
ident
=
ident
{
self
.
getVideoURLFromLocalIdentifier
(
localIdentifier
:
ident
)
{
videoUrl
,
error
in
if
let
videoUrl
=
videoUrl
{
cell
.
homeResouceUrl
=
videoUrl
DispatchQueue
.
main
.
async
{
cell
.
reload
()
}
}
}
}
// 表示这个是视频
cell
.
type
=
1
cell
.
reload
()
return
cell
}
else
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
PMShowItemCellID
,
for
:
indexPath
)
as!
PMShowItemCell
cell
.
icon
=
self
.
homeDataSource
!
[
indexPath
.
row
]
.
image
!
cell
.
icon
=
self
.
homeDataSource
!
[
indexPath
.
row
]
.
image
??
UIImage
()
cell
.
isCurrent
=
(
self
.
currentIdx
==
indexPath
.
row
)
return
cell
}
...
...
PhoneManager/Class/Session/Secret/View/SecretVideoPlayer.swift
View file @
0d4d241e
...
...
@@ -63,9 +63,12 @@ class SecretVideoPlayer: UIView {
}
}
func
playVideo
(
from
url
:
URL
)
{
func
playVideo
(
from
url
:
URL
?)
{
if
url
==
nil
{
return
}
removeObservers
()
player
=
AVPlayer
(
url
:
url
)
player
=
AVPlayer
(
url
:
url
!
)
if
let
playerLayer
=
layer
.
sublayers
?
.
first
as?
AVPlayerLayer
{
playerLayer
.
player
=
player
}
...
...
PhoneManager/Class/Session/Widget/Model/WidgetPublicModel.swift
View file @
0d4d241e
...
...
@@ -20,6 +20,9 @@ class WidgetPublicModel: NSObject {
return
batt
}
/// 已使用
/// - Returns: 已使用空间
public
class
func
UseDiskSpace
()
->
CGFloat
{
let
disk
=
getDiskSpace
()
let
use
=
disk
.
0
-
disk
.
1
...
...
@@ -27,6 +30,9 @@ class WidgetPublicModel: NSObject {
return
useP
}
/// 获取总共和可用空间
/// - Returns: 总共和可用空间
public
class
func
getDiskSpace
()
->
(
Int64
,
Int64
)
{
let
total
=
TotalDiskSize
()
let
available
=
AvailableDiskSize
()
...
...
@@ -43,9 +49,15 @@ class WidgetPublicModel: NSObject {
}
// 硬盘剩余大小
class
func
AvailableDiskSize
()
->
Int64
{
var
fs
=
blankof
(
type
:
statfs
.
self
)
if
statfs
(
"/var"
,
&
fs
)
>=
0
{
return
Int64
(
UInt64
(
fs
.
f_bsize
)
*
fs
.
f_bavail
)
do
{
let
fileURL
=
URL
(
fileURLWithPath
:
NSHomeDirectory
())
let
values
=
try
fileURL
.
resourceValues
(
forKeys
:
[
.
volumeAvailableCapacityForImportantUsageKey
])
if
let
availableSpace
=
values
.
volumeAvailableCapacityForImportantUsage
{
return
Int64
(
availableSpace
)
}
}
catch
{
print
(
"获取磁盘空间信息时出错:
\(
error
)
"
)
return
-
1
}
return
-
1
}
...
...
PhoneManager/Class/Tool/Class/PhotoAndVideoMananger/PhotoAndVideoMananger.swift
View file @
0d4d241e
...
...
@@ -135,51 +135,6 @@ class PhotoAndVideoMananger {
}
func
fetchAllFile
(
propress
:
@escaping
(
Int
,
Double
)
->
Void
,
completion
:
@escaping
(
Double
,
Int
)
->
Void
)
{
// if (self.allAssets.count == 0 ) {
//
// let fetchOptions = PHFetchOptions()
//
// let photoAllAssets = PHAsset.fetchAssets(with: .image, options: fetchOptions)
//
// let videoAllAssets = PHAsset.fetchAssets(with: .video, options: fetchOptions)
//
// let photoAssetsArray = photoAllAssets.objects(at: IndexSet(0..<photoAllAssets.count))
//
// let videoAssetsArray = videoAllAssets.objects(at: IndexSet(0..<videoAllAssets.count))
//
// let combinedArray = photoAssetsArray + videoAssetsArray
//
// DispatchQueue.global().async {[weak self] in
//
// guard let self = self else { return }
// // 计算总大小
// self.calculateTotalSize(of: combinedArray,progress: { fileSiez, index in
// propress(index,Double(fileSiez))
// }, completion: { fileSize,index in
// completion(Double(fileSize),index)
// })
//
// }
//
// }else {
//
//
// let combinedArray = self.allAssets
//
// DispatchQueue.global().async {[weak self] in
//
// guard let self = self else { return }
// // 计算总大小
// self.calculateTotalSize(of: combinedArray,progress: { fileSiez, index in
//
// propress(index,Double(fileSiez))
// }, completion: { fileSize,index in
// completion(Double(fileSize),index)
// })
//
// }
// }
let
fetchOptions
=
PHFetchOptions
()
let
photoAllAssets
=
PHAsset
.
fetchAssets
(
with
:
.
image
,
options
:
fetchOptions
)
...
...
@@ -517,18 +472,24 @@ class PhotoAndVideoMananger {
func
getPhotoAssetSize
(
_
asset
:
PHAsset
,
completion
:
@escaping
(
Int64
)
->
Void
)
{
let
options
=
PHImageRequestOptions
()
options
.
isSynchronous
=
false
options
.
version
=
.
original
// 获取原始数据
// 获取原始数据
options
.
version
=
.
original
// 不去计算iclound资源
options
.
isNetworkAccessAllowed
=
false
PHImageManager
.
default
()
.
requestImageDataAndOrientation
(
for
:
asset
,
options
:
options
)
{
(
data
,
_
,
_
,
_
)
in
let
size
=
Int64
(
data
?
.
count
??
0
)
completion
(
size
)
}
}
func
getVideoAssetSize
(
_
asset
:
PHAsset
,
completion
:
@escaping
(
Int64
)
->
Void
)
{
let
options
=
PHVideoRequestOptions
()
// 获取原始数据
options
.
version
=
.
original
// 不去计算iclound资源
options
.
isNetworkAccessAllowed
=
false
PHImageManager
.
default
()
.
requestAVAsset
(
forVideo
:
asset
,
options
:
options
)
{
(
avAsset
,
_
,
_
)
in
if
let
urlAsset
=
avAsset
as?
AVURLAsset
{
let
size
=
try
?
urlAsset
.
url
.
resourceValues
(
forKeys
:
[
.
fileSizeKey
])
.
fileSize
??
0
...
...
@@ -934,7 +895,7 @@ class PhotoAndVideoMananger {
// 获取当前版本的照片或视频
options
.
version
=
.
current
// 尽可能快地提供结果
options
.
deliveryMode
=
.
highQuality
Format
options
.
deliveryMode
=
.
fast
Format
// 允许从iCloud请求
options
.
isNetworkAccessAllowed
=
true
// 异步请求
...
...
@@ -1188,6 +1149,9 @@ class SecretPhotoManager: NSObject, PhotoPickerControllerDelegate , CameraContro
PMLoadingHUD
.
share
.
disMiss
()
}
}
else
if
let
error
=
error
{
DispatchQueue
.
main
.
async
{
PMLoadingHUD
.
share
.
disMiss
()
}
print
(
"删除失败:
\(
error
.
localizedDescription
)
"
)
}
...
...
PhoneManager/Class/Tool/Common/CommonFunc.swift
View file @
0d4d241e
...
...
@@ -30,8 +30,8 @@ func formatFileSize(_ bytes: Double) -> String {
var
unitIndex
=
0
// 循环计算合适的单位
while
size
>=
10
24
&&
unitIndex
<
units
.
count
-
1
{
size
/=
10
24
while
size
>=
10
00
&&
unitIndex
<
units
.
count
-
1
{
size
/=
10
00
unitIndex
+=
1
}
...
...
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