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
608a7872
Commit
608a7872
authored
Sep 13, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
。。。
parent
ad8d78f1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
102 deletions
+89
-102
AdmobMaxHelper.kt
...src/main/java/com/base/browserwhite/ads/AdmobMaxHelper.kt
+3
-1
BookmarkActivity.kt
...ase/browserwhite/ui/activity/bookmark/BookmarkActivity.kt
+3
-16
DownloadAdapter.kt
...base/browserwhite/ui/activity/download/DownloadAdapter.kt
+41
-12
WebDownloadManagerActivity.kt
...rwhite/ui/activity/download/WebDownloadManagerActivity.kt
+1
-10
NewsActivity.kt
...va/com/base/browserwhite/ui/activity/news/NewsActivity.kt
+1
-8
WebBrowserActivity.kt
...browserwhite/ui/activity/webbrowser/WebBrowserActivity.kt
+2
-19
WebViewFragment.kt
...se/browserwhite/ui/activity/webbrowser/WebViewFragment.kt
+26
-22
WebStoreActivity.kt
...ase/browserwhite/ui/activity/webstore/WebStoreActivity.kt
+1
-8
DownloadUtils.kt
...rc/main/java/com/base/browserwhite/utils/DownloadUtils.kt
+11
-6
No files found.
app/src/main/java/com/base/browserwhite/ads/AdmobMaxHelper.kt
View file @
608a7872
...
@@ -25,7 +25,7 @@ object AdmobMaxHelper {
...
@@ -25,7 +25,7 @@ object AdmobMaxHelper {
var
isBlack
:
Boolean
=
false
var
isBlack
:
Boolean
=
false
var
isInterOpenShowing
:
Boolean
=
false
var
isInterOpenShowing
:
Boolean
=
false
fun
testIntervalAd
(
activity
:
Activity
)
{
fun
showIntervalAd
(
activity
:
Activity
,
callBack
:
()
->
Unit
)
{
val
time
=
intervalAdTime
()
val
time
=
intervalAdTime
()
val
flag
=
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
*
1000
val
flag
=
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
*
1000
LogEx
.
logDebug
(
TAG
,
"testIntervalAd time=$time flag=$flag"
)
LogEx
.
logDebug
(
TAG
,
"testIntervalAd time=$time flag=$flag"
)
...
@@ -35,8 +35,10 @@ object AdmobMaxHelper {
...
@@ -35,8 +35,10 @@ object AdmobMaxHelper {
if
(
it
)
{
if
(
it
)
{
lastShowInter
=
System
.
currentTimeMillis
()
lastShowInter
=
System
.
currentTimeMillis
()
}
}
callBack
.
invoke
()
}
}
}
else
{
}
else
{
callBack
.
invoke
()
}
}
}
}
...
...
app/src/main/java/com/base/browserwhite/ui/activity/bookmark/BookmarkActivity.kt
View file @
608a7872
...
@@ -86,29 +86,16 @@ class BookmarkActivity : BaseActivity<ActivityBookmarkBinding>() {
...
@@ -86,29 +86,16 @@ class BookmarkActivity : BaseActivity<ActivityBookmarkBinding>() {
super
.
initListener
()
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
onBackPressedDispatcher
.
addCallback
{
if
(
currentTab
==
BOOKMARK_TAB
)
{
if
(
currentTab
==
BOOKMARK_TAB
)
{
if
(
bookmarkFragment
.
bookmarkAdapter
.
canBeforeFolder
())
{
if
(
bookmarkFragment
.
bookmarkAdapter
.
canBeforeFolder
())
{
bookmarkFragment
.
bookmarkAdapter
.
beforeFolder
()
bookmarkFragment
.
bookmarkAdapter
.
beforeFolder
()
}
else
{
}
else
{
if
(
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
*
1000
||
lastShowInter
==
0L
)
{
AdmobMaxHelper
.
showIntervalAd
(
this
@BookmarkActivity
){
AdmobMaxHelper
.
admobMaxShowInterstitialAd
(
this
@BookmarkActivity
,
false
)
{
if
(
it
)
{
lastShowInter
=
System
.
currentTimeMillis
()
}
finish
()
}
}
else
{
finish
()
finish
()
}
}
}
}
}
else
{
}
else
{
if
(
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
||
lastShowInter
==
0L
)
{
AdmobMaxHelper
.
showIntervalAd
(
this
@BookmarkActivity
){
AdmobMaxHelper
.
admobMaxShowInterstitialAd
(
this
@BookmarkActivity
,
false
)
{
if
(
it
)
{
lastShowInter
=
System
.
currentTimeMillis
()
}
finish
()
}
}
else
{
finish
()
finish
()
}
}
}
}
...
...
app/src/main/java/com/base/browserwhite/ui/activity/download/DownloadAdapter.kt
View file @
608a7872
package
com.base.browserwhite.ui.activity.download
package
com.base.browserwhite.ui.activity.download
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Context
import
android.content.Context
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.base.browserwhite.R
import
com.base.browserwhite.R
import
com.base.browserwhite.ads.AdmobMaxHelper
import
com.base.browserwhite.bean.DownloadBean
import
com.base.browserwhite.bean.DownloadBean
import
com.base.browserwhite.databinding.ItemDownloadBinding
import
com.base.browserwhite.databinding.ItemDownloadBinding
import
com.base.browserwhite.databinding.ItemDownloadCardBinding
import
com.base.browserwhite.databinding.ItemDownloadCardBinding
import
com.base.browserwhite.databinding.ItemDownloadTimeBinding
import
com.base.browserwhite.databinding.ItemDownloadTimeBinding
import
com.base.browserwhite.ui.activity.download.DownloadDialog.showDownloadConfirmDialog
import
com.base.browserwhite.ui.activity.download.DownloadDialog.showDownloadConfirmDialog
import
com.base.browserwhite.utils.DownloadUtils.getDownloadPath
import
com.base.browserwhite.utils.DownloadUtils.getDownloadPath
import
com.base.browserwhite.utils.DownloadUtils.saveDownloadRecordFile
import
com.base.browserwhite.utils.KotlinExt.toFormatSize
import
com.base.browserwhite.utils.KotlinExt.toFormatSize
import
com.base.browserwhite.utils.KotlinExt.toFormatTime
import
com.base.browserwhite.utils.KotlinExt.toFormatTime
import
com.base.browserwhite.utils.LogEx
import
com.base.browserwhite.utils.LogEx
...
@@ -27,13 +30,14 @@ import kotlin.math.abs
...
@@ -27,13 +30,14 @@ import kotlin.math.abs
@Suppress
(
"ControlFlowWithEmptyBody"
)
@Suppress
(
"ControlFlowWithEmptyBody"
)
class
DownloadAdapter
:
BaseQuickAdapter
<
DownloadBean
,
DownloadAdapter
.
DownloadViewHolder
>()
{
class
DownloadAdapter
(
val
activity
:
Activity
)
:
BaseQuickAdapter
<
DownloadBean
,
DownloadAdapter
.
DownloadViewHolder
>()
{
private
val
TAG
=
"DownloadAdapter"
private
val
TAG
=
"DownloadAdapter"
inner
class
DownloadViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
inner
class
DownloadViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
var
beginProgressAction
:
(()
->
Unit
)?
=
null
//开始下载时调用,每个下载调用一次后设置为null
var
downloadAction
:
(()
->
Unit
)?
=
null
//下载按钮
var
downloadAction
:
(()
->
Unit
)?
=
null
//下载按钮
var
downloadFinishAction
:
((
id
:
Int
)
->
Unit
)?
=
null
//下载完成
var
downloadFinishAction
:
((
id
:
Int
)
->
Unit
)?
=
null
//下载完成
...
@@ -90,7 +94,11 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
...
@@ -90,7 +94,11 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
if
(
payloads
.
isNullOrEmpty
())
{
if
(
payloads
.
isNullOrEmpty
())
{
Glide
.
with
(
context
).
load
(
item
.
url
).
centerCrop
().
into
(
binding
.
iv
)
Glide
.
with
(
context
).
load
(
item
.
url
).
centerCrop
().
into
(
binding
.
iv
)
binding
.
tvName
.
text
=
item
.
name
binding
.
tvName
.
text
=
item
.
name
binding
.
tvSize
.
text
=
item
.
size
.
toFormatSize
()
if
(
item
.
size
!=
-
1L
)
{
binding
.
tvSize
.
text
=
item
.
size
.
toFormatSize
()
}
else
{
binding
.
tvSize
.
text
=
""
}
when
(
item
.
status
)
{
when
(
item
.
status
)
{
FileDownloadStatus
.
completed
->
{
FileDownloadStatus
.
completed
->
{
binding
.
flMore
.
visibility
=
View
.
VISIBLE
binding
.
flMore
.
visibility
=
View
.
VISIBLE
...
@@ -156,7 +164,11 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
...
@@ -156,7 +164,11 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
if
(
payloads
.
isNullOrEmpty
())
{
if
(
payloads
.
isNullOrEmpty
())
{
Glide
.
with
(
context
).
load
(
item
.
url
).
centerCrop
().
into
(
binding
.
iv
)
Glide
.
with
(
context
).
load
(
item
.
url
).
centerCrop
().
into
(
binding
.
iv
)
binding
.
tvName
.
text
=
item
.
name
.
ifEmpty
{
item
.
url
.
split
(
"/"
).
last
()
}
binding
.
tvName
.
text
=
item
.
name
.
ifEmpty
{
item
.
url
.
split
(
"/"
).
last
()
}
binding
.
tvSize
.
text
=
item
.
size
.
toFormatSize
()
if
(
item
.
size
!=
-
1L
)
{
binding
.
tvSize
.
text
=
item
.
size
.
toFormatSize
()
}
else
{
binding
.
tvSize
.
text
=
""
}
var
status
=
item
.
status
var
status
=
item
.
status
// LogEx.logDebug(TAG, "status=${item.status} path=${item.path} progress=${item.progress}")
// LogEx.logDebug(TAG, "status=${item.status} path=${item.path} progress=${item.progress}")
...
@@ -192,8 +204,11 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
...
@@ -192,8 +204,11 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
binding
.
ivDownload
.
setOnClickListener
{
binding
.
ivDownload
.
setOnClickListener
{
downloadAction
?.
invoke
()
downloadAction
?.
invoke
()
context
.
showDownloadConfirmDialog
(
item
)
{
downloadItem
(
context
,
item
,
position
)
AdmobMaxHelper
.
showIntervalAd
(
activity
)
{
context
.
showDownloadConfirmDialog
(
item
)
{
downloadItem
(
context
,
item
,
position
)
}
}
}
}
}
binding
.
flDownload
.
setOnClickListener
{
binding
.
flDownload
.
setOnClickListener
{
...
@@ -272,7 +287,7 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
...
@@ -272,7 +287,7 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
item
.
path
=
context
.
getDownloadPath
(
item
)
item
.
path
=
context
.
getDownloadPath
(
item
)
LogEx
.
logDebug
(
TAG
,
"downloadItem ${item.path}"
)
LogEx
.
logDebug
(
TAG
,
"downloadItem ${item.path}"
)
item
.
fileDownloadListener
=
createNewLister
(
item
,
"downloadItem"
,
position
)
item
.
fileDownloadListener
=
createNewLister
(
context
,
item
,
"downloadItem"
,
position
)
val
downloadTask
=
FileDownloader
.
getImpl
().
create
(
item
.
url
)
val
downloadTask
=
FileDownloader
.
getImpl
().
create
(
item
.
url
)
.
setPath
(
item
.
path
)
.
setPath
(
item
.
path
)
...
@@ -284,13 +299,19 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
...
@@ -284,13 +299,19 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
private
fun
replaceListener
(
item
:
DownloadBean
,
position
:
Int
)
{
private
fun
replaceListener
(
item
:
DownloadBean
,
position
:
Int
)
{
if
(
item
.
fileDownloadListener
==
null
)
{
if
(
item
.
fileDownloadListener
==
null
)
{
item
.
fileDownloadListener
=
createNewLister
(
item
,
"replaceListener"
,
position
)
item
.
fileDownloadListener
=
createNewLister
(
context
,
item
,
"replaceListener"
,
position
)
FileDownloader
.
getImpl
().
replaceListener
(
item
.
downloadId
,
item
.
fileDownloadListener
)
FileDownloader
.
getImpl
().
replaceListener
(
item
.
downloadId
,
item
.
fileDownloadListener
)
}
}
}
}
private
fun
createNewLister
(
item
:
DownloadBean
,
tag
:
String
=
""
,
position
:
Int
):
FileDownloadListener
{
var
startMap
=
HashMap
<
String
,
Boolean
>()
private
fun
createNewLister
(
context
:
Context
,
item
:
DownloadBean
,
tag
:
String
=
""
,
position
:
Int
):
FileDownloadListener
{
return
object
:
FileDownloadListener
()
{
return
object
:
FileDownloadListener
()
{
override
fun
pending
(
task
:
BaseDownloadTask
?,
soFarBytes
:
Int
,
totalBytes
:
Int
)
{
override
fun
pending
(
task
:
BaseDownloadTask
?,
soFarBytes
:
Int
,
totalBytes
:
Int
)
{
LogEx
.
logDebug
(
TAG
,
"pending tag=$tag item=${item.downloadId} ${task?.id} ${item.url}"
)
LogEx
.
logDebug
(
TAG
,
"pending tag=$tag item=${item.downloadId} ${task?.id} ${item.url}"
)
...
@@ -303,8 +324,12 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
...
@@ -303,8 +324,12 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
item
.
status
=
FileDownloader
.
getImpl
().
getStatus
(
item
.
url
,
item
.
path
)
item
.
status
=
FileDownloader
.
getImpl
().
getStatus
(
item
.
url
,
item
.
path
)
LogEx
.
logDebug
(
TAG
,
"progress tag=$tag item=${item.downloadId} percent=$percent ${item.path} state=${task?.status}"
)
LogEx
.
logDebug
(
TAG
,
"progress tag=$tag item=${item.downloadId} percent=$percent ${item.path} state=${task?.status}"
)
notifyItemChanged
(
position
,
"aaa"
)
notifyItemChanged
(
position
,
"aaa"
)
beginProgressAction
?.
invoke
()
beginProgressAction
=
null
val
start
=
startMap
[
item
.
url
]
if
(
start
==
null
||
start
!=
true
)
{
startMap
[
item
.
url
]
=
true
context
.
saveDownloadRecordFile
(
items
,
"progress start ${item.url}"
)
}
}
}
override
fun
completed
(
task
:
BaseDownloadTask
?)
{
override
fun
completed
(
task
:
BaseDownloadTask
?)
{
...
@@ -313,7 +338,10 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
...
@@ -313,7 +338,10 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
item
.
time
=
System
.
currentTimeMillis
()
item
.
time
=
System
.
currentTimeMillis
()
LogEx
.
logDebug
(
TAG
,
"completed tag=$tag item=${item.downloadId} ${item.path} ${item.status}"
)
LogEx
.
logDebug
(
TAG
,
"completed tag=$tag item=${item.downloadId} ${item.path} ${item.status}"
)
notifyItemChanged
(
position
,
"aaa"
)
notifyItemChanged
(
position
,
"aaa"
)
task
?.
let
{
downloadFinishAction
?.
invoke
(
it
.
id
)
}
task
?.
let
{
downloadFinishAction
?.
invoke
(
it
.
id
)
context
.
saveDownloadRecordFile
(
items
,
"completed"
)
}
}
}
override
fun
paused
(
task
:
BaseDownloadTask
?,
soFarBytes
:
Int
,
totalBytes
:
Int
)
{
override
fun
paused
(
task
:
BaseDownloadTask
?,
soFarBytes
:
Int
,
totalBytes
:
Int
)
{
...
@@ -323,6 +351,7 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
...
@@ -323,6 +351,7 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
item
.
status
=
FileDownloadStatus
.
paused
item
.
status
=
FileDownloadStatus
.
paused
item
.
time
=
System
.
currentTimeMillis
()
item
.
time
=
System
.
currentTimeMillis
()
notifyItemChanged
(
position
,
"aaa"
)
notifyItemChanged
(
position
,
"aaa"
)
context
.
saveDownloadRecordFile
(
items
,
"paused"
)
}
}
override
fun
error
(
task
:
BaseDownloadTask
?,
e
:
Throwable
?)
{
override
fun
error
(
task
:
BaseDownloadTask
?,
e
:
Throwable
?)
{
...
...
app/src/main/java/com/base/browserwhite/ui/activity/download/WebDownloadManagerActivity.kt
View file @
608a7872
...
@@ -16,7 +16,6 @@ import com.base.browserwhite.ui.views.DialogViews.showMediaMoreDialog
...
@@ -16,7 +16,6 @@ import com.base.browserwhite.ui.views.DialogViews.showMediaMoreDialog
import
com.base.browserwhite.utils.BarUtils
import
com.base.browserwhite.utils.BarUtils
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJson
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJson
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJsonBean
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJsonBean
import
com.base.browserwhite.utils.DownloadUtils.saveDownloadRecordFile
import
com.base.browserwhite.utils.IntentEx.shareAction
import
com.base.browserwhite.utils.IntentEx.shareAction
import
com.base.browserwhite.utils.KotlinExt.toFormatTime
import
com.base.browserwhite.utils.KotlinExt.toFormatTime
import
com.base.browserwhite.utils.PermissionUtils.checkStorePermission
import
com.base.browserwhite.utils.PermissionUtils.checkStorePermission
...
@@ -39,7 +38,7 @@ class WebDownloadManagerActivity : BaseActivity<ActivityWebDownloadManagerBindin
...
@@ -39,7 +38,7 @@ class WebDownloadManagerActivity : BaseActivity<ActivityWebDownloadManagerBindin
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
adapter
=
DownloadAdapter
()
adapter
=
DownloadAdapter
(
this
)
adapter
.
moreAction
=
{
archView
,
item
->
adapter
.
moreAction
=
{
archView
,
item
->
showMediaMoreDialog
(
archView
,
showMediaMoreDialog
(
archView
,
deleteAction
=
{
deleteAction
=
{
...
@@ -165,12 +164,4 @@ class WebDownloadManagerActivity : BaseActivity<ActivityWebDownloadManagerBindin
...
@@ -165,12 +164,4 @@ class WebDownloadManagerActivity : BaseActivity<ActivityWebDownloadManagerBindin
}
}
override
fun
onPause
()
{
super
.
onPause
()
this
.
saveDownloadRecordFile
(
adapter
.
items
)
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
}
}
}
\ No newline at end of file
app/src/main/java/com/base/browserwhite/ui/activity/news/NewsActivity.kt
View file @
608a7872
...
@@ -89,14 +89,7 @@ class NewsActivity : BaseActivity<ActivityNewsBinding>() {
...
@@ -89,14 +89,7 @@ class NewsActivity : BaseActivity<ActivityNewsBinding>() {
override
fun
initListener
()
{
override
fun
initListener
()
{
super
.
initListener
()
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
onBackPressedDispatcher
.
addCallback
{
if
(
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
*
1000
||
lastShowInter
==
0L
)
{
AdmobMaxHelper
.
showIntervalAd
(
this
@NewsActivity
)
{
AdmobMaxHelper
.
admobMaxShowInterstitialAd
(
this
@NewsActivity
,
false
)
{
if
(
it
)
{
lastShowInter
=
System
.
currentTimeMillis
()
}
finishToMain
()
}
}
else
{
finishToMain
()
finishToMain
()
}
}
}
}
...
...
app/src/main/java/com/base/browserwhite/ui/activity/webbrowser/WebBrowserActivity.kt
View file @
608a7872
...
@@ -200,17 +200,7 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
...
@@ -200,17 +200,7 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
"WevStoreActivity"
->
{
"WevStoreActivity"
->
{
if
(
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
*
1000
||
lastShowInter
==
0L
)
{
AdmobMaxHelper
.
showIntervalAd
(
this
@WebBrowserActivity
)
{
AdmobMaxHelper
.
admobMaxShowInterstitialAd
(
this
@WebBrowserActivity
,
false
)
{
if
(
it
)
{
lastShowInter
=
System
.
currentTimeMillis
()
}
finishToMain
()
}
}
else
{
finishToMain
()
finishToMain
()
}
}
...
@@ -230,14 +220,7 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
...
@@ -230,14 +220,7 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
}
}
}
}
binding
.
ivHome
.
setOnClickListener
{
binding
.
ivHome
.
setOnClickListener
{
if
(
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
*
1000
||
lastShowInter
==
0L
)
{
AdmobMaxHelper
.
showIntervalAd
(
this
)
{
AdmobMaxHelper
.
admobMaxShowInterstitialAd
(
this
@WebBrowserActivity
,
false
)
{
if
(
it
)
{
lastShowInter
=
System
.
currentTimeMillis
()
}
finishToMain
()
}
}
else
{
finishToMain
()
finishToMain
()
}
}
}
}
...
...
app/src/main/java/com/base/browserwhite/ui/activity/webbrowser/WebViewFragment.kt
View file @
608a7872
...
@@ -4,6 +4,7 @@ import android.animation.ValueAnimator
...
@@ -4,6 +4,7 @@ import android.animation.ValueAnimator
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.app.Dialog
import
android.app.Dialog
import
android.content.Intent
import
android.content.Intent
import
android.graphics.Bitmap
import
android.net.Uri
import
android.net.Uri
import
android.net.http.SslError
import
android.net.http.SslError
import
android.text.Html
import
android.text.Html
...
@@ -47,7 +48,6 @@ import com.base.browserwhite.utils.ColorUtils
...
@@ -47,7 +48,6 @@ import com.base.browserwhite.utils.ColorUtils
import
com.base.browserwhite.utils.DownloadUtils
import
com.base.browserwhite.utils.DownloadUtils
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJson
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJson
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJsonBean
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJsonBean
import
com.base.browserwhite.utils.DownloadUtils.saveDownloadRecordFile
import
com.base.browserwhite.utils.LogEx
import
com.base.browserwhite.utils.LogEx
import
com.base.browserwhite.utils.PermissionUtils.checkStorePermission
import
com.base.browserwhite.utils.PermissionUtils.checkStorePermission
import
com.base.browserwhite.utils.SpBeanUtils
import
com.base.browserwhite.utils.SpBeanUtils
...
@@ -161,7 +161,6 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -161,7 +161,6 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
downloadDialog
=
requireContext
().
showDownloadVideoDialog
(
downloadDialog
=
requireContext
().
showDownloadVideoDialog
(
adapter
,
downloadList
,
adapter
,
downloadList
,
dismissAction
=
{
dismissAction
=
{
requireContext
().
saveDownloadRecordFile
(
downloadList
)
downloadDialog
=
null
downloadDialog
=
null
},
},
)
)
...
@@ -170,26 +169,12 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -170,26 +169,12 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
private
fun
initDownloadAdapter
()
{
private
fun
initDownloadAdapter
()
{
if
(
downloadAdapter
==
null
)
{
if
(
downloadAdapter
==
null
)
{
downloadAdapter
=
DownloadAdapter
()
downloadAdapter
=
DownloadAdapter
(
requireActivity
()
)
}
}
downloadAdapter
?.
downloadAction
=
{
downloadAdapter
?.
downloadAction
=
{
if
(
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
*
1000
||
lastShowInter
==
0L
)
{
downloadDialog
?.
dismiss
()
AdmobMaxHelper
.
admobMaxShowInterstitialAd
(
requireActivity
(),
false
)
{
if
(
it
)
{
lastShowInter
=
System
.
currentTimeMillis
()
}
downloadDialog
?.
dismiss
()
downloadAdapter
?.
beginProgressAction
=
{
requireContext
().
saveDownloadRecordFile
(
downloadList
)
}
}
}
else
{
downloadDialog
?.
dismiss
()
downloadAdapter
?.
beginProgressAction
=
{
requireContext
().
saveDownloadRecordFile
(
downloadList
)
}
}
}
}
downloadAdapter
?.
downloadFinishAction
=
{
id
->
downloadAdapter
?.
downloadFinishAction
=
{
id
->
downloadDialog
?.
dismiss
()
downloadDialog
?.
dismiss
()
val
recordFile
=
requireContext
().
getDownloadJson
()
val
recordFile
=
requireContext
().
getDownloadJson
()
...
@@ -199,9 +184,7 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -199,9 +184,7 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
bean
?.
let
{
bean
?.
let
{
requireContext
().
showDownloadFinishDialog
(
it
)
{
callDownloadDialog
()
}
requireContext
().
showDownloadFinishDialog
(
it
)
{
callDownloadDialog
()
}
}
}
requireContext
().
saveDownloadRecordFile
(
downloadList
)
}
}
}
}
private
var
keyword
=
""
private
var
keyword
=
""
...
@@ -400,6 +383,7 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -400,6 +383,7 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
view
:
WebView
?,
view
:
WebView
?,
request
:
WebResourceRequest
?
request
:
WebResourceRequest
?
):
Boolean
{
):
Boolean
{
LogEx
.
logDebug
(
TAG
,
"shouldOverrideUrlLoading"
)
if
(
request
!=
null
)
{
if
(
request
!=
null
)
{
val
uri
=
request
.
url
val
uri
=
request
.
url
val
scheme
=
uri
.
scheme
val
scheme
=
uri
.
scheme
...
@@ -418,6 +402,11 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -418,6 +402,11 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
return
false
return
false
}
}
override
fun
onPageStarted
(
view
:
WebView
?,
url
:
String
?,
favicon
:
Bitmap
?)
{
super
.
onPageStarted
(
view
,
url
,
favicon
)
downloadList
.
clear
()
}
override
fun
onPageFinished
(
view
:
WebView
?,
url
:
String
?)
{
override
fun
onPageFinished
(
view
:
WebView
?,
url
:
String
?)
{
LogEx
.
logDebug
(
TAG
,
"onPageFinished"
)
LogEx
.
logDebug
(
TAG
,
"onPageFinished"
)
super
.
onPageFinished
(
view
,
url
)
super
.
onPageFinished
(
view
,
url
)
...
@@ -482,6 +471,8 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -482,6 +471,8 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
@SuppressLint
(
"NotifyDataSetChanged"
)
@SuppressLint
(
"NotifyDataSetChanged"
)
fun
addVideoLink
(
addUri
:
String
)
{
fun
addVideoLink
(
addUri
:
String
)
{
if
(
downloadList
.
map
{
it
.
url
}.
contains
(
addUri
))
return
val
olderList
=
arrayListOf
<
DownloadBean
>()
val
olderList
=
arrayListOf
<
DownloadBean
>()
val
recordFile
=
requireContext
().
getDownloadJson
()
val
recordFile
=
requireContext
().
getDownloadJson
()
olderList
.
addAll
(
getDownloadJsonBean
(
recordFile
,
Gson
()))
olderList
.
addAll
(
getDownloadJsonBean
(
recordFile
,
Gson
()))
...
@@ -585,8 +576,21 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -585,8 +576,21 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
requireContext
().
saveDownloadRecordFile
(
downloadList
)
binding
.
webView
.
destroy
()
binding
.
webView
.
destroy
()
}
}
override
fun
onResume
()
{
super
.
onResume
()
if
(
requireContext
().
checkStorePermission
())
{
upDateDownloadList
()
}
}
private
fun
upDateDownloadList
()
{
downloadList
.
forEach
{
it
.
status
=
FileDownloader
.
getImpl
().
getStatus
(
it
.
url
,
it
.
path
)
}
downloadAdapter
?.
submitList
(
downloadList
)
}
}
}
\ No newline at end of file
app/src/main/java/com/base/browserwhite/ui/activity/webstore/WebStoreActivity.kt
View file @
608a7872
...
@@ -68,14 +68,7 @@ class WebStoreActivity : BaseActivity<ActivityWebStoreBinding>() {
...
@@ -68,14 +68,7 @@ class WebStoreActivity : BaseActivity<ActivityWebStoreBinding>() {
super
.
initListener
()
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
onBackPressedDispatcher
.
addCallback
{
if
(
System
.
currentTimeMillis
()
-
lastShowInter
>
intervalAdTime
()
*
1000
||
lastShowInter
==
0L
)
{
AdmobMaxHelper
.
showIntervalAd
(
this
@WebStoreActivity
)
{
AdmobMaxHelper
.
admobMaxShowInterstitialAd
(
this
@WebStoreActivity
,
false
)
{
if
(
it
)
{
lastShowInter
=
System
.
currentTimeMillis
()
}
finishToMain
()
}
}
else
{
finishToMain
()
finishToMain
()
}
}
}
}
...
...
app/src/main/java/com/base/browserwhite/utils/DownloadUtils.kt
View file @
608a7872
...
@@ -76,11 +76,10 @@ object DownloadUtils {
...
@@ -76,11 +76,10 @@ object DownloadUtils {
return
path
return
path
}
}
fun
Context
.
saveDownloadRecordFile
(
downloadList
:
List
<
DownloadBean
>)
=
Thread
{
/**
*
downloadList
.
forEach
{
*/
LogEx
.
logDebug
(
TAG
,
"saveDownloadRecordFile ${it.downloadId} ${it.name} ${it.path} status=${it.status}"
)
fun
Context
.
saveDownloadRecordFile
(
downloadList
:
List
<
DownloadBean
>,
whenCall
:
String
=
""
)
=
Thread
{
}
val
recordFile
=
getDownloadJson
()
val
recordFile
=
getDownloadJson
()
...
@@ -111,8 +110,14 @@ object DownloadUtils {
...
@@ -111,8 +110,14 @@ object DownloadUtils {
arrayList
.
addAll
(
startedList
)
arrayList
.
addAll
(
startedList
)
arrayList
.
addAll
(
finishList
)
arrayList
.
addAll
(
finishList
)
val
urlList
=
arrayList
.
map
{
it
.
url
}
val
setList
=
urlList
.
toSet
()
if
(
urlList
.
size
!=
setList
.
size
)
{
LogEx
.
logDebug
(
TAG
,
"$whenCall Duplication Save"
)
}
arrayList
.
forEach
{
arrayList
.
forEach
{
LogEx
.
logDebug
(
TAG
,
"saveDownloadRecordFile ${it.name} ${it.downloadId} ${it.status} ${it.path}"
)
LogEx
.
logDebug
(
TAG
,
"saveDownloadRecordFile $
whenCall $
{it.name} ${it.downloadId} ${it.status} ${it.path}"
)
}
}
val
json
=
downloadBeanGson
.
toJson
(
arrayList
)
val
json
=
downloadBeanGson
.
toJson
(
arrayList
)
...
...
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