Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
ead1ad79
Commit
ead1ad79
authored
Apr 02, 2022
by
sheteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版本1.0.1
feed流排版,缩略图错乱
parent
b53fd3fa
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
301 additions
and
159 deletions
+301
-159
app/src/main/java/com/ccwangluo/accelerator/receiver/AppDownloadReceiver.java
...m/ccwangluo/accelerator/receiver/AppDownloadReceiver.java
+2
-0
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
...in/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
+9
-8
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectFragment.kt
...a/com/ccwangluo/accelerator/ui/news/NewsObjectFragment.kt
+166
-97
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectModel.kt
...java/com/ccwangluo/accelerator/ui/news/NewsObjectModel.kt
+11
-2
app/src/main/java/com/ccwangluo/accelerator/ui/web/AndroidInterface.kt
...java/com/ccwangluo/accelerator/ui/web/AndroidInterface.kt
+13
-2
app/src/main/java/com/ccwangluo/accelerator/utils/AcceleratorUtils.kt
.../java/com/ccwangluo/accelerator/utils/AcceleratorUtils.kt
+7
-3
app/src/main/java/com/ccwangluo/accelerator/utils/DownloadUtils.kt
...ain/java/com/ccwangluo/accelerator/utils/DownloadUtils.kt
+43
-29
app/src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
...src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
+1
-1
app/src/main/res/layout/item_dynamic.xml
app/src/main/res/layout/item_dynamic.xml
+35
-9
app/src/main/res/xml/filepaths.xml
app/src/main/res/xml/filepaths.xml
+12
-6
buildSrc/src/main/kotlin/Helpers.kt
buildSrc/src/main/kotlin/Helpers.kt
+2
-2
No files found.
app/src/main/java/com/ccwangluo/accelerator/receiver/AppDownloadReceiver.java
View file @
ead1ad79
...
@@ -10,6 +10,8 @@ import android.database.Cursor;
...
@@ -10,6 +10,8 @@ import android.database.Cursor;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
com.xuexiang.xutil.app.AppUtils
;
public
class
AppDownloadReceiver
extends
BroadcastReceiver
{
public
class
AppDownloadReceiver
extends
BroadcastReceiver
{
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
View file @
ead1ad79
...
@@ -101,6 +101,7 @@ class NewsFragment : XPageFragment() {
...
@@ -101,6 +101,7 @@ class NewsFragment : XPageFragment() {
val
version
=
val
version
=
AppUtils
.
getAppVersionCode
(
it
.
packageName
)
AppUtils
.
getAppVersionCode
(
it
.
packageName
)
itemData
.
url
?.
let
{
itemData
.
url
?.
let
{
if
(!
it
.
isNullOrBlank
()){
var
newversion
=
it
.
split
(
"/"
).
let
{
it1-
>
var
newversion
=
it
.
split
(
"/"
).
let
{
it1-
>
it1
.
get
(
it1
.
lastIndex
-
1
).
toInt
()
it1
.
get
(
it1
.
lastIndex
-
1
).
toInt
()
}
}
...
@@ -111,6 +112,7 @@ class NewsFragment : XPageFragment() {
...
@@ -111,6 +112,7 @@ class NewsFragment : XPageFragment() {
}
}
}
}
}
}
}
}
}
itemView
.
setOnClickListener
{
itemView
.
setOnClickListener
{
...
@@ -138,7 +140,6 @@ class NewsFragment : XPageFragment() {
...
@@ -138,7 +140,6 @@ class NewsFragment : XPageFragment() {
if
(
itemData
.
type
==
3
)
{
if
(
itemData
.
type
==
3
)
{
itemData
.
url
?.
let
{
itemData
.
url
?.
let
{
DataRePortUtils
.
report
(
"st_game_down_clk"
,
mapOf
(
"scene"
to
"3"
))
activity
?.
let
{
it1
->
activity
?.
let
{
it1
->
DownloadUtils
.
downloadFile
(
it1
,
it
)
DownloadUtils
.
downloadFile
(
it1
,
it
)
}
}
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectFragment.kt
View file @
ead1ad79
package
com.ccwangluo.accelerator.ui.news
package
com.ccwangluo.accelerator.ui.news
import
android.content.Intent
import
android.graphics.Color
import
android.graphics.Color
import
android.os.Bundle
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.LayoutInflater
...
@@ -24,9 +25,11 @@ import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
...
@@ -24,9 +25,11 @@ import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
import
com.ccwangluo.accelerator.model.NewsModel
import
com.ccwangluo.accelerator.model.NewsModel
import
com.ccwangluo.accelerator.ui.view.RatingBar
import
com.ccwangluo.accelerator.ui.view.RatingBar
import
com.ccwangluo.accelerator.ui.web.CommonWebViewFragment
import
com.ccwangluo.accelerator.ui.web.CommonWebViewFragment
import
com.ccwangluo.accelerator.utils.LoginUtils
import
com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import
com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import
com.github.shadowsocks.http.HttpConfig
import
com.github.shadowsocks.http.HttpConfig
import
com.hjq.toast.ToastUtils
import
com.hjq.toast.ToastUtils
import
com.xuexiang.xpage.core.PageOption
class
NewsObjectFragment
:
XPageFragment
()
{
class
NewsObjectFragment
:
XPageFragment
()
{
...
@@ -79,35 +82,64 @@ class NewsObjectFragment : XPageFragment() {
...
@@ -79,35 +82,64 @@ class NewsObjectFragment : XPageFragment() {
itemView
.
findViewById
<
TextView
>(
R
.
id
.
title
).
visibility
=
View
.
VISIBLE
itemView
.
findViewById
<
TextView
>(
R
.
id
.
title
).
visibility
=
View
.
VISIBLE
itemView
.
findViewById
<
TextView
>(
R
.
id
.
title
).
setText
(
it
)
itemView
.
findViewById
<
TextView
>(
R
.
id
.
title
).
setText
(
it
)
}
}
?:
let
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
title
).
visibility
=
View
.
GONE
}
?:
let
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
title
).
visibility
=
View
.
GONE
}
if
(
itemData
.
type
==
5
)
{
if
(
itemData
.
type
==
5
)
{
itemData
.
content
?.
let
{
itemData
.
content
?.
let
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
visibility
=
View
.
VISIBLE
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
visibility
=
View
.
VISIBLE
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
setText
(
it
)
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
setText
(
it
)
}
?:
let
{
}
?:
let
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
visibility
=
View
.
GONE
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
visibility
=
View
.
GONE
}
}
}
else
{
}
else
{
itemData
.
abbrContent
?.
let
{
itemData
.
abbrContent
?.
let
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
visibility
=
View
.
VISIBLE
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
visibility
=
View
.
VISIBLE
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
setText
(
it
)
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
setText
(
it
)
}
?:
let
{
}
?:
let
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
visibility
=
View
.
GONE
itemView
.
findViewById
<
TextView
>(
R
.
id
.
abbrContent
).
visibility
=
View
.
GONE
}
}
}
}
// 资讯类型:0攻略 1视频
// 资讯类型:0攻略 1视频
val
imgs
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
imgs
)
val
imgs
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
imgs
)
val
imgs1
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
imgs1
)
val
imgs2
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
imgs2
)
val
vedio
=
itemView
.
findViewById
<
JCVideoPlayerStandard
>(
R
.
id
.
video_view
)
val
vedio
=
itemView
.
findViewById
<
JCVideoPlayerStandard
>(
R
.
id
.
video_view
)
vedio
.
backButton
.
visibility
=
View
.
GONE
vedio
.
backButton
.
visibility
=
View
.
GONE
vedio
.
tinyBackImageView
.
visibility
=
View
.
GONE
vedio
.
tinyBackImageView
.
visibility
=
View
.
GONE
itemData
.
imgs
?.
let
{
itemData
.
imgs
?.
let
{
val
split
=
itemData
.
imgs
.
split
(
","
)
if
(
split
.
size
>
0
)
{
imgs
.
visibility
=
View
.
VISIBLE
imgs
.
visibility
=
View
.
VISIBLE
Glide
.
with
(
this
@NewsObjectFragment
).
load
(
itemData
.
imgs
.
split
(
","
)
.
get
(
0
))
Glide
.
with
(
this
@NewsObjectFragment
).
load
(
split
.
get
(
0
))
.
into
(
imgs
)
.
into
(
imgs
)
}
else
{
imgs
.
visibility
=
View
.
GONE
}
if
(
split
.
size
>
1
)
{
imgs1
.
visibility
=
View
.
VISIBLE
Glide
.
with
(
this
@NewsObjectFragment
).
load
(
split
.
get
(
1
))
.
into
(
imgs1
)
}
else
{
imgs1
.
visibility
=
View
.
GONE
}
if
(
split
.
size
>
2
)
{
imgs2
.
visibility
=
View
.
VISIBLE
Glide
.
with
(
this
@NewsObjectFragment
).
load
(
split
.
get
(
2
))
.
into
(
imgs2
)
}
else
{
imgs2
.
visibility
=
View
.
GONE
}
}
?:
let
{
imgs
.
visibility
=
View
.
GONE
imgs1
.
visibility
=
View
.
GONE
imgs2
.
visibility
=
View
.
GONE
}
}
itemData
.
videoUrl
?.
let
{
itemData
.
videoUrl
?.
let
{
vedio
.
visibility
=
View
.
VISIBLE
vedio
.
visibility
=
View
.
VISIBLE
...
@@ -118,7 +150,8 @@ class NewsObjectFragment : XPageFragment() {
...
@@ -118,7 +150,8 @@ class NewsObjectFragment : XPageFragment() {
Glide
.
with
(
this
@NewsObjectFragment
).
load
(
it
)
Glide
.
with
(
this
@NewsObjectFragment
).
load
(
it
)
.
into
(
vedio
.
thumbImageView
)
.
into
(
vedio
.
thumbImageView
)
}
}
}
?:
let
{
vedio
.
visibility
=
View
.
GONE
}
}
val
star
=
itemView
.
findViewById
<
RatingBar
>(
R
.
id
.
star
)
val
star
=
itemView
.
findViewById
<
RatingBar
>(
R
.
id
.
star
)
itemData
.
star
?.
let
{
itemData
.
star
?.
let
{
...
@@ -136,11 +169,13 @@ class NewsObjectFragment : XPageFragment() {
...
@@ -136,11 +169,13 @@ class NewsObjectFragment : XPageFragment() {
}
}
itemData
.
isGreat
?.
let
{
itemData
.
isGreat
?.
let
{
if
(
it
)
{
if
(
it
)
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
great_num
).
setTextColor
(
Color
.
parseColor
(
"#3CA4FD"
))
itemView
.
findViewById
<
TextView
>(
R
.
id
.
great_num
)
.
setTextColor
(
Color
.
parseColor
(
"#3CA4FD"
))
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
great_img
)
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
great_img
)
.
setBackgroundResource
(
R
.
mipmap
.
icon_praise_bu
)
.
setBackgroundResource
(
R
.
mipmap
.
icon_praise_bu
)
}
else
{
}
else
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
great_num
).
setTextColor
(
Color
.
parseColor
(
"#FFBBBBBB"
))
itemView
.
findViewById
<
TextView
>(
R
.
id
.
great_num
)
.
setTextColor
(
Color
.
parseColor
(
"#FFBBBBBB"
))
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
great_img
)
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
great_img
)
.
setBackgroundResource
(
R
.
mipmap
.
icon_praise_ga
)
.
setBackgroundResource
(
R
.
mipmap
.
icon_praise_ga
)
}
}
...
@@ -150,7 +185,13 @@ class NewsObjectFragment : XPageFragment() {
...
@@ -150,7 +185,13 @@ class NewsObjectFragment : XPageFragment() {
if
(!
it
)
{
if
(!
it
)
{
DataRePortUtils
.
report
(
"st_like_clk"
)
DataRePortUtils
.
report
(
"st_like_clk"
)
}
}
newsViewModel
?.
greate
(
this
@NewsObjectFragment
,
itemData
.
type
,
gameId
,
itemData
.
id
,
it
)
{
newsViewModel
?.
greate
(
this
@NewsObjectFragment
,
itemData
.
type
,
gameId
,
itemData
.
id
,
it
)
{
if
(!
it
)
{
if
(!
it
)
{
ToastUtils
.
show
(
"点赞成功"
)
ToastUtils
.
show
(
"点赞成功"
)
itemData
.
isGreat
=
true
itemData
.
isGreat
=
true
...
@@ -165,12 +206,7 @@ class NewsObjectFragment : XPageFragment() {
...
@@ -165,12 +206,7 @@ class NewsObjectFragment : XPageFragment() {
}
}
itemView
.
findViewById
<
View
>(
R
.
id
.
item_click_view
).
setOnClickListener
{
itemView
.
findViewById
<
View
>(
R
.
id
.
item_click_view
).
setOnClickListener
{
val
params
=
Bundle
()
openWebviewForResult
(
itemData
)
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
"/gameDetail?gameId=${gameId}&id=${itemData.id}"
)
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
}
}
}
.
create
()
.
create
()
...
@@ -201,6 +237,40 @@ class NewsObjectFragment : XPageFragment() {
...
@@ -201,6 +237,40 @@ class NewsObjectFragment : XPageFragment() {
recycle_view
?.
adapter
?.
notifyDataSetChanged
()
recycle_view
?.
adapter
?.
notifyDataSetChanged
()
viewModel
.
isRefresh
.
postValue
(
true
)
viewModel
.
isRefresh
.
postValue
(
true
)
})
})
newsViewModel
?.
clearList
?.
observe
(
this
,
{
if
(
it
)
{
dataList
.
clear
()
}
})
}
var
CLICK_GREAT_REQUEST_CODE
=
200
var
itemData
:
News
?
=
null
private
fun
openWebviewForResult
(
itemData
:
News
)
{
this
.
itemData
=
itemData
PageOption
.
to
(
CommonWebViewFragment
::
class
.
java
)
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
"/gameDetail?gameId=${gameId}&id=${itemData.id}"
)
.
setRequestCode
(
CLICK_GREAT_REQUEST_CODE
)
.
open
(
this
)
}
override
fun
onFragmentResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
super
.
onFragmentResult
(
requestCode
,
resultCode
,
data
)
if
(
requestCode
==
CLICK_GREAT_REQUEST_CODE
)
{
itemData
?.
let
{
if
(
resultCode
==
200
)
{
it
.
isGreat
=
true
it
.
greatNum
++
}
else
{
it
.
isGreat
=
false
it
.
greatNum--
}
recycle_view
?.
adapter
?.
notifyDataSetChanged
()
}
}
}
}
protected
fun
isSlideToBottom
(
recyclerView
:
RecyclerView
?):
Boolean
{
protected
fun
isSlideToBottom
(
recyclerView
:
RecyclerView
?):
Boolean
{
...
@@ -215,7 +285,6 @@ class NewsObjectFragment : XPageFragment() {
...
@@ -215,7 +285,6 @@ class NewsObjectFragment : XPageFragment() {
fun
refresh
()
{
fun
refresh
()
{
AcceleratorUtils
.
game
?.
let
{
AcceleratorUtils
.
game
?.
let
{
dataList
.
clear
()
gameId
=
it
.
id
gameId
=
it
.
id
page
=
1
page
=
1
newsViewModel
?.
freshData
(
position
,
it
.
id
,
page
)
newsViewModel
?.
freshData
(
position
,
it
.
id
,
page
)
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectModel.kt
View file @
ead1ad79
...
@@ -14,6 +14,7 @@ import kotlinx.coroutines.withContext
...
@@ -14,6 +14,7 @@ import kotlinx.coroutines.withContext
class
NewsObjectModel
:
ViewModel
()
{
class
NewsObjectModel
:
ViewModel
()
{
val
newsModel
=
MutableLiveData
<
NewsModel
>()
val
newsModel
=
MutableLiveData
<
NewsModel
>()
val
clearList
=
MutableLiveData
<
Boolean
>()
fun
freshData
(
position
:
String
,
gameId
:
Int
,
page
:
Int
)
{
fun
freshData
(
position
:
String
,
gameId
:
Int
,
page
:
Int
)
{
val
type
=
when
(
position
)
{
val
type
=
when
(
position
)
{
...
@@ -29,6 +30,7 @@ class NewsObjectModel : ViewModel() {
...
@@ -29,6 +30,7 @@ class NewsObjectModel : ViewModel() {
res
?.
let
{
res
?.
let
{
if
(
it
.
code
==
200
)
{
if
(
it
.
code
==
200
)
{
it
.
data
?.
let
{
it
.
data
?.
let
{
clearList
.
postValue
(
page
==
1
)
newsModel
.
postValue
(
it
)
newsModel
.
postValue
(
it
)
}
}
}
}
...
@@ -39,7 +41,14 @@ class NewsObjectModel : ViewModel() {
...
@@ -39,7 +41,14 @@ class NewsObjectModel : ViewModel() {
/**
/**
* 点赞
* 点赞
*/
*/
fun
greate
(
xPageFragment
:
XPageFragment
,
type
:
Int
?,
gameId
:
Int
,
parentId
:
Int
,
isGreate
:
Boolean
,
callback
:
()
->
Unit
)
{
fun
greate
(
xPageFragment
:
XPageFragment
,
type
:
Int
?,
gameId
:
Int
,
parentId
:
Int
,
isGreate
:
Boolean
,
callback
:
()
->
Unit
)
{
val
map
=
mutableMapOf
<
String
,
Any
>()
val
map
=
mutableMapOf
<
String
,
Any
>()
map
.
put
(
"gameId"
,
gameId
)
map
.
put
(
"gameId"
,
gameId
)
map
.
put
(
"parentId"
,
parentId
)
map
.
put
(
"parentId"
,
parentId
)
...
@@ -48,7 +57,7 @@ class NewsObjectModel : ViewModel() {
...
@@ -48,7 +57,7 @@ class NewsObjectModel : ViewModel() {
map
.
put
(
"type"
,
it
)
map
.
put
(
"type"
,
it
)
}
}
if
(
LoginUtils
.
token
==
null
)
{
if
(
LoginUtils
.
token
==
null
)
{
xPageFragment
.
context
?.
let
{
LoginUtils
.
login
(
it
,{})
}
xPageFragment
.
context
?.
let
{
LoginUtils
.
login
(
it
,
{})
}
return
return
}
}
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/web/AndroidInterface.kt
View file @
ead1ad79
...
@@ -78,7 +78,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -78,7 +78,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
* 跳转协议
* 跳转协议
*/
*/
@JavascriptInterface
@JavascriptInterface
fun
openWebviewByWholeUrl
(
url
:
String
,
showTitle
:
Boolean
)
{
fun
openWebviewByWholeUrl
(
url
:
String
,
showTitle
:
Boolean
)
{
val
params
=
Bundle
()
val
params
=
Bundle
()
if
(
url
.
startsWith
(
"http:"
)
||
url
.
startsWith
(
"https:"
))
{
if
(
url
.
startsWith
(
"http:"
)
||
url
.
startsWith
(
"https:"
))
{
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
url
)
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
url
)
...
@@ -97,7 +97,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -97,7 +97,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
*/
*/
@JavascriptInterface
@JavascriptInterface
fun
openWebviewByWholeUrl
(
url
:
String
)
{
fun
openWebviewByWholeUrl
(
url
:
String
)
{
openWebviewByWholeUrl
(
url
,
false
)
openWebviewByWholeUrl
(
url
,
false
)
}
}
//打开系统设置
//打开系统设置
...
@@ -371,5 +371,16 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
...
@@ -371,5 +371,16 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
}
}
}
}
@JavascriptInterface
fun
isGrate
(
isopen
:
Boolean
)
{
handler
.
post
{
if
(
isopen
)
{
xPageFragment
.
setFragmentResult
(
200
,
Intent
())
}
else
{
xPageFragment
.
setFragmentResult
(
400
,
Intent
())
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/utils/AcceleratorUtils.kt
View file @
ead1ad79
...
@@ -95,8 +95,12 @@ object AcceleratorUtils : TencentLocationListener {
...
@@ -95,8 +95,12 @@ object AcceleratorUtils : TencentLocationListener {
fun
initContext
(
context
:
XPageActivity
,
connect
:
ActivityResultLauncher
<
Void
?
>)
{
fun
initContext
(
context
:
XPageActivity
,
connect
:
ActivityResultLauncher
<
Void
?
>)
{
this
.
context
=
context
this
.
context
=
context
this
.
connect
=
connect
this
.
connect
=
connect
try
{
NetworkAdapter
.
initNetworks
(
context
)
NetworkAdapter
.
initNetworks
(
context
)
ProfileManager
.
ensureNotEmpty
()
ProfileManager
.
ensureNotEmpty
()
}
catch
(
e
:
Exception
)
{
}
context
.
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
context
.
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
while
(
true
)
{
while
(
true
)
{
if
(
state
==
BaseService
.
State
.
Connected
)
{
if
(
state
==
BaseService
.
State
.
Connected
)
{
...
@@ -157,7 +161,7 @@ object AcceleratorUtils : TencentLocationListener {
...
@@ -157,7 +161,7 @@ object AcceleratorUtils : TencentLocationListener {
}
}
}
}
fun
openLocation
(
context
:
Context
){
fun
openLocation
(
context
:
Context
)
{
PermissionUtils
.
permission
(
PermissionUtils
.
permission
(
Manifest
.
permission
.
ACCESS_FINE_LOCATION
Manifest
.
permission
.
ACCESS_FINE_LOCATION
).
rationale
({
).
rationale
({
...
...
app/src/main/java/com/ccwangluo/accelerator/utils/DownloadUtils.kt
View file @
ead1ad79
...
@@ -7,16 +7,23 @@ import android.content.Intent
...
@@ -7,16 +7,23 @@ import android.content.Intent
import
android.net.Uri
import
android.net.Uri
import
android.os.Build
import
android.os.Build
import
android.os.Environment
import
android.os.Environment
import
android.webkit.MimeTypeMap
import
androidx.core.content.FileProvider
import
androidx.core.content.FileProvider
import
androidx.fragment.app.FragmentActivity
import
androidx.fragment.app.FragmentActivity
import
com.ccwangluo.accelerator.ui.dialog.DownloadDialog
import
com.ccwangluo.accelerator.ui.dialog.DownloadDialog
import
com.hjq.toast.ToastUtils
import
com.hjq.toast.ToastUtils
import
com.xuexiang.xutil.app.AppUtils
import
com.xuexiang.xutil.file.FileUtils
import
com.xuexiang.xutil.system.PermissionUtils
import
com.xuexiang.xutil.system.PermissionUtils
import
java.io.File
import
java.io.File
object
DownloadUtils
{
object
DownloadUtils
{
fun
downloadFile
(
activity
:
FragmentActivity
,
url
:
String
)
{
fun
downloadFile
(
activity
:
FragmentActivity
,
url
:
String
)
{
if
(
url
.
isNullOrBlank
()){
return
}
if
(!
PermissionUtils
.
isGranted
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
))
{
if
(!
PermissionUtils
.
isGranted
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
))
{
ToastUtils
.
show
(
"下载需要打开存储权限"
)
ToastUtils
.
show
(
"下载需要打开存储权限"
)
PermissionUtils
.
permission
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
.
toString
())
PermissionUtils
.
permission
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
.
toString
())
...
@@ -26,22 +33,24 @@ object DownloadUtils {
...
@@ -26,22 +33,24 @@ object DownloadUtils {
return
return
}
}
var
filename
=
url
.
split
(
"/"
).
last
()
var
filename
=
url
.
split
(
"/"
).
last
()
va
l
file
=
File
(
va
r
file
=
File
(
Environment
.
getExternalStorageDirectory
().
absolutePath
+
"/${Environment.DIRECTORY_DOWNLOADS}"
,
activity
.
getExternalFilesDir
(
Environment
.
DIRECTORY_DOWNLOADS
)
,
filename
filename
)
)
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
install
App
(
activity
,
file
)
install
(
file
.
absolutePath
,
activity
)
return
return
}
}
val
downloadManager
=
activity
.
getSystemService
(
Context
.
DOWNLOAD_SERVICE
)
as
DownloadManager
val
downloadManager
=
activity
.
getSystemService
(
Context
.
DOWNLOAD_SERVICE
)
as
DownloadManager
val
request
=
val
request
=
DownloadManager
.
Request
(
Uri
.
parse
(
url
))
//添加下载文件的网络路径
DownloadManager
.
Request
(
Uri
.
parse
(
url
))
//添加下载文件的网络路径
request
.
setDestinationInExternalPublicDir
(
request
.
setDestinationInExternalFilesDir
(
activity
,
Environment
.
DIRECTORY_DOWNLOADS
,
filename
)
Environment
.
DIRECTORY_DOWNLOADS
,
val
mimeTypeMap
=
MimeTypeMap
.
getSingleton
()
filename
val
mimeString
=
)
//添加保存文件路径与名称
mimeTypeMap
.
getMimeTypeFromExtension
(
MimeTypeMap
.
getFileExtensionFromUrl
(
url
))
request
.
setMimeType
(
mimeString
)
request
.
setTitle
(
"下载中"
)
//添加在通知栏里显示的标题
request
.
setTitle
(
"下载中"
)
//添加在通知栏里显示的标题
// request.setDescription("下载中") //添加在通知栏里显示的描述
// request.setDescription("下载中") //添加在通知栏里显示的描述
...
@@ -57,29 +66,34 @@ object DownloadUtils {
...
@@ -57,29 +66,34 @@ object DownloadUtils {
DownloadDialog
(
activity
,
downloadManager
,
id
).
show
()
DownloadDialog
(
activity
,
downloadManager
,
id
).
show
()
}
}
fun
installApp
(
context
:
Context
,
apkFile
:
File
)
{
try
{
/**
* 描述: 安装
*/
fun
install
(
apkPath
:
String
,
context
:
Context
):
Boolean
{
// 没有root权限,利用意图进行安装
val
file
=
File
(
apkPath
)
if
(!
file
.
exists
())
{
return
false
}
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
)
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
val
uri
:
Uri
intent
.
flags
=
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
val
type
=
"application/vnd.android.package-archive"
val
contentUri
:
Uri
=
FileProvider
.
getUriForFile
(
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
)
{
context
,
uri
=
Uri
.
fromFile
(
file
)
"com.ccwangluo.accelerator.fileprovider"
,
apkFile
)
//authorities就是provider里声明的authorities
intent
.
setDataAndType
(
contentUri
,
"application/vnd.android.package-archive"
)
}
else
{
}
else
{
intent
.
setDataAndType
(
val
authority
=
"com.ccwangluo.accelerator.fileprovider"
Uri
.
fromFile
(
apkFile
),
uri
=
FileProvider
.
getUriForFile
(
context
,
authority
,
file
)
"application/vnd.android.package-archive"
intent
.
flags
=
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
}
}
context
.
grantUriPermission
(
context
.
packageName
,
uri
,
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
intent
.
setDataAndType
(
uri
,
type
)
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context
.
startActivity
(
intent
)
context
.
startActivity
(
intent
)
}
catch
(
e
:
Exception
)
{
return
true
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
View file @
ead1ad79
...
@@ -131,7 +131,7 @@ object SysUtils {
...
@@ -131,7 +131,7 @@ object SysUtils {
"OPPO"
->
6
"OPPO"
->
6
"baiduzhushou"
->
7
"baiduzhushou"
->
7
"wufan"
->
8
"wufan"
->
8
else
->
0
else
->
1
}
}
}
}
}
}
...
...
app/src/main/res/layout/item_dynamic.xml
View file @
ead1ad79
...
@@ -97,17 +97,43 @@
...
@@ -97,17 +97,43 @@
android:maxLines=
"3"
android:maxLines=
"3"
android:textColor=
"#FF4A4A4A"
android:textColor=
"#FF4A4A4A"
android:textSize=
"14sp"
/>
android:textSize=
"14sp"
/>
<LinearLayout
<ImageView
android:layout_marginTop=
"12.65dp"
android:layout_marginLeft=
"20dp"
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
android:layout_marginRight=
"20dp"
android:id=
"@+id/imgs"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:orientation=
"horizontal"
android:layout_height=
"wrap_content"
>
<ImageView
android:id=
"@+id/imgs"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"182.5dp"
android:layout_height=
"182.5dp"
android:layout_marginTop=
"12.65dp"
android:scaleType=
"centerCrop"
android:scaleType=
"fitXY"
android:visibility=
"gone"
/>
android:visibility=
"gone"
/>
<ImageView
android:layout_marginLeft=
"5dp"
android:id=
"@+id/imgs1"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"182.5dp"
android:scaleType=
"centerCrop"
android:visibility=
"gone"
/>
<ImageView
android:layout_marginLeft=
"5dp"
android:id=
"@+id/imgs2"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"182.5dp"
android:scaleType=
"centerCrop"
android:visibility=
"gone"
/>
</LinearLayout>
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
android:layout_marginLeft=
"20dp"
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
android:layout_marginRight=
"20dp"
...
...
app/src/main/res/xml/filepaths.xml
View file @
ead1ad79
...
@@ -5,10 +5,16 @@
...
@@ -5,10 +5,16 @@
<root-path
name=
"opensdk_root"
path=
""
/>
<root-path
name=
"opensdk_root"
path=
""
/>
<external-files-path
name=
"opensdk_external"
path=
"Images/tmp"
/>
<external-files-path
name=
"opensdk_external"
path=
"Images/tmp"
/>
<external-path
name=
"external_storage_root"
path=
"."
/>
<external-path
name=
"external_storage_root"
path=
"."
/>
<external-path
name=
"external"
<files-path
name=
"files-path"
path=
"/."
/>
path=
"./Download"
/>
<cache-path
name=
"cache-path"
path=
"/."
/>
<files-path
<external-path
name=
"external-path"
path=
"/."
/>
name=
"files"
<external-files-path
name=
"external-files-path"
path=
"/."
/>
path=
"."
/>
<external-cache-path
name=
"external-cache-path"
path=
"/."
/>
<external-path
path=
"."
name=
"download"
/>
<external-cache-path
name=
"storage/emulated/0"
path=
"."
/>
</paths>
</paths>
\ No newline at end of file
buildSrc/src/main/kotlin/Helpers.kt
View file @
ead1ad79
...
@@ -56,8 +56,8 @@ fun Project.setupCore() {
...
@@ -56,8 +56,8 @@ fun Project.setupCore() {
setupCommon
()
setupCommon
()
android
.
apply
{
android
.
apply
{
defaultConfig
{
defaultConfig
{
versionCode
=
1
versionCode
=
2
versionName
=
"1.0.
0
"
versionName
=
"1.0.
1
"
}
}
compileOptions
.
isCoreLibraryDesugaringEnabled
=
true
compileOptions
.
isCoreLibraryDesugaringEnabled
=
true
lintOptions
{
lintOptions
{
...
...
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