Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
B
Browser White
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
wanglei
Browser White
Commits
cc1d3bee
Commit
cc1d3bee
authored
Aug 26, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
bdee4010
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
7 deletions
+27
-7
WebDownloadManagerActivity.kt
...rwhite/ui/activity/download/WebDownloadManagerActivity.kt
+22
-6
WebViewFragment.kt
...se/browserwhite/ui/activity/webbrowser/WebViewFragment.kt
+5
-1
No files found.
app/src/main/java/com/base/browserwhite/ui/activity/download/WebDownloadManagerActivity.kt
View file @
cc1d3bee
...
...
@@ -2,12 +2,10 @@ package com.base.browserwhite.ui.activity.download
import
android.content.Intent
import
android.graphics.Color
import
android.os.Environment
import
androidx.activity.addCallback
import
androidx.core.content.FileProvider
import
androidx.core.view.isVisible
import
androidx.core.view.updatePadding
import
com.base.browserwhite.R
import
com.base.browserwhite.bean.DownloadBean
import
com.base.browserwhite.databinding.ActivityWebDownloadManagerBinding
import
com.base.browserwhite.ui.activity.BaseActivity
...
...
@@ -22,6 +20,7 @@ import com.base.browserwhite.utils.IntentEx.shareAction
import
com.base.browserwhite.utils.KotlinExt.toFormatTime
import
com.base.browserwhite.utils.PermissionHelp.checkStorePermission
import
com.base.browserwhite.utils.PermissionHelp.requestStorePermission
import
com.google.gson.Gson
import
java.io.File
class
WebDownloadManagerActivity
:
BaseActivity
<
ActivityWebDownloadManagerBinding
>()
{
...
...
@@ -43,8 +42,18 @@ class WebDownloadManagerActivity : BaseActivity<ActivityWebDownloadManagerBindin
showMediaMoreDialog
(
archView
,
deleteAction
=
{
showDeleteTipDialog
{
runCatching
{
File
(
item
.
path
).
delete
()
}
runCatching
{
File
(
item
.
path
).
delete
()
saveDeleteJson
(
item
)
}
adapter
.
remove
(
item
)
val
list
=
adapter
.
items
.
filter
{
!
it
.
isTime
&&
it
.
time
==
item
.
time
}
if
(
list
.
isEmpty
())
{
adapter
.
items
.
filter
{
it
.
isTime
&&
it
.
time
==
item
.
time
}.
forEach
{
timeBean
->
adapter
.
remove
(
timeBean
)
}
binding
.
llEmpty
.
isVisible
=
adapter
.
items
.
isEmpty
()
}
}
},
shareAction
=
{
...
...
@@ -65,6 +74,14 @@ class WebDownloadManagerActivity : BaseActivity<ActivityWebDownloadManagerBindin
}
}
private
fun
saveDeleteJson
(
item
:
DownloadBean
)
{
val
recordFile
=
getDownloadJson
()
val
list
=
getDownloadJsonBean
(
recordFile
).
toMutableList
()
list
.
removeIf
{
it
.
path
==
item
.
path
}
val
json
=
Gson
().
toJson
(
list
)
recordFile
.
writeText
(
json
)
}
override
fun
initListener
()
{
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
...
...
@@ -89,14 +106,13 @@ class WebDownloadManagerActivity : BaseActivity<ActivityWebDownloadManagerBindin
val
beanList
=
arrayListOf
<
DownloadBean
>()
val
timeList
=
arrayListOf
<
String
>()
list
.
forEach
{
old
->
list
.
sortedBy
{
it
.
time
}.
forEach
{
old
->
val
time
=
old
.
time
.
toFormatTime
()
if
(!
timeList
.
contains
(
time
))
{
timeList
.
add
(
time
)
beanList
.
add
(
DownloadBean
(
time
=
old
.
time
).
apply
{
isTime
=
true
})
}
else
{
beanList
.
add
(
old
)
}
beanList
.
add
(
old
.
apply
{
uiType
=
1
})
}
adapter
.
submitList
(
beanList
)
}
...
...
app/src/main/java/com/base/browserwhite/ui/activity/webbrowser/WebViewFragment.kt
View file @
cc1d3bee
...
...
@@ -103,7 +103,11 @@ class WebViewFragment : BaseFragment<FragmentWebViewBinding>() {
val
recordFile
=
requireContext
().
getDownloadJson
()
val
list
=
downloadList
list
.
filter
{
it
.
status
!=
FileDownloadStatus
.
completed
}.
forEach
{
it
.
time
=
System
.
currentTimeMillis
()
}
list
.
filter
{
it
.
status
==
FileDownloadStatus
.
completed
||
it
.
status
==
FileDownloadStatus
.
progress
||
it
.
status
==
FileDownloadStatus
.
paused
}.
forEach
{
it
.
time
=
System
.
currentTimeMillis
()
}
val
olderList
=
getDownloadJsonBean
(
recordFile
,
downloadBeanGson
).
filter
{
!
list
.
contains
(
it
)
}
...
...
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