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
00243d6d
Commit
00243d6d
authored
Jul 15, 2022
by
sheteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0版本
parent
cd104a8c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
250 additions
and
30 deletions
+250
-30
app/src/main/java/com/ccwangluo/accelerator/model/Game.kt
app/src/main/java/com/ccwangluo/accelerator/model/Game.kt
+3
-1
app/src/main/java/com/ccwangluo/accelerator/ui/gameList/GameListFragment.kt
...com/ccwangluo/accelerator/ui/gameList/GameListFragment.kt
+123
-14
app/src/main/java/com/ccwangluo/accelerator/ui/gameList/GameListModel.kt
...va/com/ccwangluo/accelerator/ui/gameList/GameListModel.kt
+9
-6
app/src/main/java/com/ccwangluo/accelerator/ui/home/AcceleratorFragment.kt
.../com/ccwangluo/accelerator/ui/home/AcceleratorFragment.kt
+4
-2
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
...in/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
+10
-4
app/src/main/java/com/ccwangluo/accelerator/ui/web/CommonWebViewFragment.kt
...com/ccwangluo/accelerator/ui/web/CommonWebViewFragment.kt
+4
-2
app/src/main/java/com/ccwangluo/accelerator/utils/Constants.kt
...rc/main/java/com/ccwangluo/accelerator/utils/Constants.kt
+7
-0
app/src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
...src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
+45
-0
app/src/main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
.../main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
+1
-1
app/src/main/res/layout/fragment_quick.xml
app/src/main/res/layout/fragment_quick.xml
+1
-0
app/src/main/res/layout/item_game.xml
app/src/main/res/layout/item_game.xml
+43
-0
No files found.
app/src/main/java/com/ccwangluo/accelerator/model/Game.kt
View file @
00243d6d
...
@@ -13,6 +13,7 @@ data class GameInfo(
...
@@ -13,6 +13,7 @@ data class GameInfo(
val
boosterServer
:
String
,
val
boosterServer
:
String
,
val
createdDate
:
String
,
val
createdDate
:
String
,
val
dnsServer
:
String
,
val
dnsServer
:
String
,
val
downloadType
:
Int
,
val
downloadUrl
:
String
,
val
downloadUrl
:
String
,
val
gameName
:
String
,
val
gameName
:
String
,
val
icon
:
String
,
val
icon
:
String
,
...
@@ -36,5 +37,6 @@ data class Announcement(
...
@@ -36,5 +37,6 @@ data class Announcement(
val
id
:
Int
,
val
id
:
Int
,
val
status
:
Int
,
val
status
:
Int
,
val
title
:
String
,
val
title
:
String
,
val
url
:
String
val
url
:
String
,
val
type
:
Int
)
)
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/ui/gameList/GameListFragment.kt
View file @
00243d6d
...
@@ -2,6 +2,7 @@ package com.ccwangluo.accelerator.ui.gameList
...
@@ -2,6 +2,7 @@ package com.ccwangluo.accelerator.ui.gameList
import
android.content.Intent
import
android.content.Intent
import
android.net.Uri
import
android.net.Uri
import
android.os.Bundle
import
android.os.Handler
import
android.os.Handler
import
android.os.Looper
import
android.os.Looper
import
android.view.LayoutInflater
import
android.view.LayoutInflater
...
@@ -17,19 +18,25 @@ import com.ccwangluo.accelerator.R
...
@@ -17,19 +18,25 @@ import com.ccwangluo.accelerator.R
import
com.ccwangluo.accelerator.adapter.KotlinDataAdapter
import
com.ccwangluo.accelerator.adapter.KotlinDataAdapter
import
com.ccwangluo.accelerator.databinding.FragmentGameListBinding
import
com.ccwangluo.accelerator.databinding.FragmentGameListBinding
import
com.ccwangluo.accelerator.manager.GameDownLoadManger
import
com.ccwangluo.accelerator.manager.GameDownLoadManger
import
com.ccwangluo.accelerator.manager.LoginUtils
import
com.ccwangluo.accelerator.model.Announcement
import
com.ccwangluo.accelerator.model.GameInfo
import
com.ccwangluo.accelerator.model.GameInfo
import
com.ccwangluo.accelerator.ui.dialog.CommonDialog
import
com.ccwangluo.accelerator.ui.dialog.CommonDialog
import
com.ccwangluo.accelerator.ui.dialog.GameDownloadDialog
import
com.ccwangluo.accelerator.ui.dialog.GameDownloadDialog
import
com.ccwangluo.accelerator.ui.home.AcceleratorFragment
import
com.ccwangluo.accelerator.ui.home.AcceleratorFragment
import
com.ccwangluo.accelerator.utils.AcceleratorUtils
import
com.ccwangluo.accelerator.ui.home.NewsFragment
import
com.ccwangluo.accelerator.utils.ByteUtils
import
com.ccwangluo.accelerator.ui.web.CommonWebViewFragment
import
com.ccwangluo.accelerator.utils.ShareUtils
import
com.ccwangluo.accelerator.utils.*
import
com.ccwangluo.accelerator.utils.SysUtils
import
com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import
com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import
com.github.shadowsocks.bg.BaseService
import
com.github.shadowsocks.bg.BaseService
import
com.github.shadowsocks.http.HttpConfig
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xpage.utils.TitleBar
import
com.xuexiang.xpage.utils.TitleBar
import
com.xuexiang.xui.widget.progress.CircleProgressView
import
com.xuexiang.xui.widget.progress.CircleProgressView
import
com.xuexiang.xutil.app.AppUtils
import
com.xuexiang.xutil.tip.ToastUtils
import
java.util.*
import
java.util.stream.Collectors
class
GameListFragment
:
XPageFragment
()
{
class
GameListFragment
:
XPageFragment
()
{
...
@@ -51,7 +58,7 @@ class GameListFragment : XPageFragment() {
...
@@ -51,7 +58,7 @@ class GameListFragment : XPageFragment() {
override
fun
inflateView
(
inflater
:
LayoutInflater
?,
container
:
ViewGroup
?):
View
{
override
fun
inflateView
(
inflater
:
LayoutInflater
?,
container
:
ViewGroup
?):
View
{
_binding
=
FragmentGameListBinding
.
inflate
(
inflater
!!
,
container
,
false
)
_binding
=
FragmentGameListBinding
.
inflate
(
inflater
!!
,
container
,
false
)
gameListModel
=
ViewModelProvider
(
this
).
get
(
GameListModel
::
class
.
java
)
gameListModel
=
ViewModelProvider
(
this
).
get
(
GameListModel
::
class
.
java
)
return
_binding
!!
.
root
return
_binding
.
root
}
}
override
fun
initViews
()
{
override
fun
initViews
()
{
...
@@ -88,6 +95,55 @@ class GameListFragment : XPageFragment() {
...
@@ -88,6 +95,55 @@ class GameListFragment : XPageFragment() {
val
tx_download_size
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
tx_download_size
)
val
tx_download_size
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
tx_download_size
)
val
tx_status
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
tx_status
)
val
tx_status
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
tx_status
)
//公告
//公告
val
game_notice_area_1
=
itemView
.
findViewById
<
View
>(
R
.
id
.
game_notice_area_1
)
val
game_notice_area_2
=
itemView
.
findViewById
<
View
>(
R
.
id
.
game_notice_area_2
)
val
game_notice_2_1
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
game_notice_2_1
)
val
game_notice_1_1
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
game_notice_1_1
)
val
game_notice_1_2
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
game_notice_1_2
)
val
game_notice_1_3
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
game_notice_1_3
)
val
announcement1
=
itemData
.
announcementList
.
stream
().
filter
{
it
.
type
==
1
}
.
collect
(
Collectors
.
toList
())
if
(
announcement1
==
null
||
announcement1
.
size
==
0
)
{
game_notice_area_1
.
visibility
=
View
.
GONE
}
else
{
game_notice_area_1
.
visibility
=
View
.
VISIBLE
game_notice_1_1
.
setText
(
announcement1
.
get
(
0
).
title
)
game_notice_1_1
.
setOnClickListener
{
openNoticePage
(
announcement1
.
get
(
0
))
}
if
(
announcement1
.
size
>
1
)
{
game_notice_1_2
.
visibility
=
View
.
VISIBLE
game_notice_1_2
.
setText
(
announcement1
.
get
(
1
).
title
)
game_notice_1_2
.
setOnClickListener
{
openNoticePage
(
announcement1
.
get
(
1
))
}
}
else
{
game_notice_1_2
.
visibility
=
View
.
GONE
}
if
(
announcement1
.
size
>
2
)
{
game_notice_1_3
.
visibility
=
View
.
VISIBLE
game_notice_1_3
.
setText
(
announcement1
.
get
(
2
).
title
)
game_notice_1_3
.
setOnClickListener
{
openNoticePage
(
announcement1
.
get
(
2
))
}
}
else
{
game_notice_1_3
.
visibility
=
View
.
GONE
}
}
val
announcement2
=
itemData
.
announcementList
.
stream
().
filter
{
it
.
type
==
2
}
.
collect
(
Collectors
.
toList
())
if
(
announcement2
==
null
||
announcement2
.
size
==
0
)
{
game_notice_area_2
.
visibility
=
View
.
GONE
}
else
{
game_notice_area_2
.
visibility
=
View
.
VISIBLE
game_notice_2_1
.
setText
(
announcement2
.
get
(
0
).
content
)
game_notice_area_2
.
setOnClickListener
{
openNoticePage
(
announcement2
.
get
(
0
))
}
}
Glide
.
with
(
this
@GameListFragment
)
Glide
.
with
(
this
@GameListFragment
)
.
load
(
itemData
.
icon
)
.
load
(
itemData
.
icon
)
...
@@ -123,7 +179,9 @@ class GameListFragment : XPageFragment() {
...
@@ -123,7 +179,9 @@ class GameListFragment : XPageFragment() {
progress_download
.
progress
=
it
.
progress
progress_download
.
progress
=
it
.
progress
}
}
}
else
if
(!
SysUtils
.
isPackageInstall
(
it
,
itemData
.
packageName
))
{
}
//应用未安装
else
if
(!
SysUtils
.
isPackageInstall
(
it
,
itemData
.
packageName
))
{
btn_uninstall
.
visibility
=
View
.
VISIBLE
btn_uninstall
.
visibility
=
View
.
VISIBLE
btn_acc
.
visibility
=
View
.
GONE
btn_acc
.
visibility
=
View
.
GONE
btn_acc_stop
.
visibility
=
View
.
GONE
btn_acc_stop
.
visibility
=
View
.
GONE
...
@@ -131,6 +189,19 @@ class GameListFragment : XPageFragment() {
...
@@ -131,6 +189,19 @@ class GameListFragment : XPageFragment() {
tx_download_status
.
visibility
=
View
.
GONE
tx_download_status
.
visibility
=
View
.
GONE
btn_download_status
.
visibility
=
View
.
GONE
btn_download_status
.
visibility
=
View
.
GONE
}
//应用升级
else
if
(!
SysUtils
.
compareVersionTo
(
AppUtils
.
getAppVersionName
(
itemData
.
packageName
),
itemData
.
version
)
)
{
btn_uninstall
.
visibility
=
View
.
GONE
btn_acc
.
visibility
=
View
.
VISIBLE
btn_acc_stop
.
visibility
=
View
.
GONE
tx_game_update_notice
.
visibility
=
View
.
VISIBLE
tx_download_status
.
visibility
=
View
.
GONE
btn_download_status
.
visibility
=
View
.
GONE
}
else
if
(
AcceleratorUtils
.
state
==
BaseService
.
State
.
Connected
&&
AcceleratorUtils
.
game
!!
.
id
==
itemData
.
id
)
{
}
else
if
(
AcceleratorUtils
.
state
==
BaseService
.
State
.
Connected
&&
AcceleratorUtils
.
game
!!
.
id
==
itemData
.
id
)
{
btn_uninstall
.
visibility
=
View
.
GONE
btn_uninstall
.
visibility
=
View
.
GONE
btn_acc
.
visibility
=
View
.
GONE
btn_acc
.
visibility
=
View
.
GONE
...
@@ -162,8 +233,22 @@ class GameListFragment : XPageFragment() {
...
@@ -162,8 +233,22 @@ class GameListFragment : XPageFragment() {
}
}
btn_acc
.
setOnClickListener
{
btn_acc
.
setOnClickListener
{
AcceleratorUtils
.
setGameInfo
(
itemData
)
if
(
AcceleratorUtils
.
state
==
BaseService
.
State
.
Connected
)
{
openPage
(
AcceleratorFragment
::
class
.
java
)
context
?.
let
{
CommonDialog
(
it
)
.
setContent
(
"当前${AcceleratorUtils.game?.gameName}应用正在加速,是否取消"
)
.
setBtnLeft
(
"取消"
)
{
}.
setBtnRight
(
"确定"
)
{
AcceleratorUtils
.
stopAccelerator
()
AcceleratorUtils
.
setGameInfo
(
itemData
)
openPage
(
AcceleratorFragment
::
class
.
java
)
}.
show
<
CommonDialog
>()
}
}
else
{
AcceleratorUtils
.
setGameInfo
(
itemData
)
openPage
(
AcceleratorFragment
::
class
.
java
)
}
}
}
game_name
.
setOnClickListener
{
game_name
.
setOnClickListener
{
...
@@ -171,7 +256,7 @@ class GameListFragment : XPageFragment() {
...
@@ -171,7 +256,7 @@ class GameListFragment : XPageFragment() {
}
}
tx_game_update_notice
.
setOnClickListener
{
tx_game_update_notice
.
setOnClickListener
{
download
(
itemData
)
}
}
}
}
.
create
()
.
create
()
...
@@ -217,6 +302,19 @@ class GameListFragment : XPageFragment() {
...
@@ -217,6 +302,19 @@ class GameListFragment : XPageFragment() {
registerListener
()
registerListener
()
}
}
private
fun
openNoticePage
(
ann
:
Announcement
)
{
if
(
ann
.
type
==
2
)
{
val
params
=
Bundle
()
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
ann
.
url
)
params
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
ann
.
gameId
)
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
else
if
(
ann
.
type
==
1
)
{
val
params
=
Bundle
()
params
.
putInt
(
Constants
.
GAME_ID
,
ann
.
gameId
)
openPage
(
NewsFragment
::
class
.
java
)
}
}
override
fun
initListeners
()
{
override
fun
initListeners
()
{
_binding
.
accShare
.
setOnClickListener
{
_binding
.
accShare
.
setOnClickListener
{
DataRePortUtils
.
report
(
"st_share_clk"
,
mapOf
(
"scene"
to
"3"
))
DataRePortUtils
.
report
(
"st_share_clk"
,
mapOf
(
"scene"
to
"3"
))
...
@@ -263,17 +361,28 @@ class GameListFragment : XPageFragment() {
...
@@ -263,17 +361,28 @@ class GameListFragment : XPageFragment() {
acctime
=
l
acctime
=
l
if
(
state
==
BaseService
.
State
.
Connected
)
{
if
(
state
==
BaseService
.
State
.
Connected
)
{
Handler
(
Looper
.
getMainLooper
()).
post
{
Handler
(
Looper
.
getMainLooper
()).
post
{
_binding
.
gameList
.
adapter
?.
notifyItemChanged
(
AcceleratorUtils
.
game
?.
let
{
dataList
.
indexOf
(
if
(
dataList
.
indexOf
(
AcceleratorUtils
.
game
)
==
0
)
{
AcceleratorUtils
.
game
_binding
.
gameList
.
adapter
?.
notifyItemChanged
(
)
0
)
)
}
else
{
dataList
.
remove
(
it
)
dataList
.
add
(
0
,
it
)
_binding
.
gameList
.
adapter
?.
notifyDataSetChanged
()
}
}
}
}
}
}
}
}
}
}
fun
download
(
itemData
:
GameInfo
)
{
fun
download
(
itemData
:
GameInfo
)
{
//
if
(
itemData
.
downloadType
!=
0
)
{
ToastUtils
.
toast
(
"暂不提供下载功能,请前往游戏官网下载~"
)
return
}
activity
?.
let
{
activity
?.
let
{
if
(
itemData
.
downloadUrl
.
endsWith
(
".apk"
))
{
if
(
itemData
.
downloadUrl
.
endsWith
(
".apk"
))
{
GameDownloadDialog
(
GameDownloadDialog
(
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/gameList/GameListModel.kt
View file @
00243d6d
...
@@ -8,6 +8,7 @@ import com.ccwangluo.accelerator.model.GameInfo
...
@@ -8,6 +8,7 @@ import com.ccwangluo.accelerator.model.GameInfo
import
com.ccwangluo.accelerator.utils.SysUtils
import
com.ccwangluo.accelerator.utils.SysUtils
import
com.ccwangluo.accelerator.utils.http.HttpGo
import
com.ccwangluo.accelerator.utils.http.HttpGo
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xutil.app.AppUtils
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
...
@@ -16,14 +17,16 @@ class GameListModel : ViewModel() {
...
@@ -16,14 +17,16 @@ class GameListModel : ViewModel() {
val
gameModel
=
MutableLiveData
<
Game
>()
val
gameModel
=
MutableLiveData
<
Game
>()
val
clearList
=
MutableLiveData
<
Boolean
>()
val
clearList
=
MutableLiveData
<
Boolean
>()
fun
freshData
(
xPageFragment
:
XPageFragment
,
page
:
Int
)
{
fun
freshData
(
xPageFragment
:
XPageFragment
,
page
:
Int
)
{
xPageFragment
.
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
xPageFragment
.
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
res
=
HttpGo
.
getSync
<
Game
>(
"/api/new/game/list?page=${page}&size=10&channelId=${SysUtils.getChannel()}"
)
val
res
=
HttpGo
.
getSync
<
Game
>(
"/api/new/game/list?page=${page}&size=20&channelId=${SysUtils.getChannel()}"
)
res
?.
let
{
res
?.
let
{
it
.
data
?.
let
{
it
.
data
?.
let
{
clearList
.
postValue
(
page
==
1
)
clearList
.
postValue
(
page
==
1
)
gameModel
.
postValue
(
it
)
gameModel
.
postValue
(
it
)
}
}
}
}
}
}
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/home/AcceleratorFragment.kt
View file @
00243d6d
...
@@ -65,7 +65,7 @@ class AcceleratorFragment : XPageFragment() {
...
@@ -65,7 +65,7 @@ class AcceleratorFragment : XPageFragment() {
override
fun
initViews
()
{
override
fun
initViews
()
{
acceleratorViewModel
.
netState
.
observe
(
this
,
{
acceleratorViewModel
.
netState
.
observe
(
this
)
{
if
(
it
.
preNetDelay
!=
-
1
&&
state
==
BaseService
.
State
.
Connected
)
{
//有网络
if
(
it
.
preNetDelay
!=
-
1
&&
state
==
BaseService
.
State
.
Connected
)
{
//有网络
binding
.
preDelay1
.
setText
(
it
.
preNetDelay
.
toString
())
binding
.
preDelay1
.
setText
(
it
.
preNetDelay
.
toString
())
...
@@ -110,7 +110,7 @@ class AcceleratorFragment : XPageFragment() {
...
@@ -110,7 +110,7 @@ class AcceleratorFragment : XPageFragment() {
binding
.
netQuality
.
setText
(
SysUtils
.
getnetQuality
(
it
.
preNetDelay
))
binding
.
netQuality
.
setText
(
SysUtils
.
getnetQuality
(
it
.
preNetDelay
))
}
}
binding
.
activeNetwork
.
setText
(
SysUtils
.
getActiveNet
())
binding
.
activeNetwork
.
setText
(
SysUtils
.
getActiveNet
())
}
)
}
acceleratorViewModel
.
accState
.
observe
(
this
)
{
acceleratorViewModel
.
accState
.
observe
(
this
)
{
binding
.
accStateTx
.
setText
(
"加速中 ${SysUtils.getAccTimeString(accTimer)}"
)
binding
.
accStateTx
.
setText
(
"加速中 ${SysUtils.getAccTimeString(accTimer)}"
)
...
@@ -313,6 +313,7 @@ class AcceleratorFragment : XPageFragment() {
...
@@ -313,6 +313,7 @@ class AcceleratorFragment : XPageFragment() {
fun
openToWebview
(
url
:
String
)
{
fun
openToWebview
(
url
:
String
)
{
val
params
=
Bundle
()
val
params
=
Bundle
()
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
params
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
AcceleratorUtils
.
game
!!
.
id
)
LoginUtils
.
token
?.
let
{
LoginUtils
.
token
?.
let
{
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
?:
let
{
}
?:
let
{
...
@@ -338,6 +339,7 @@ class AcceleratorFragment : XPageFragment() {
...
@@ -338,6 +339,7 @@ class AcceleratorFragment : XPageFragment() {
LoginUtils
.
token
?.
let
{
LoginUtils
.
token
?.
let
{
PageOption
.
to
(
CommonWebViewFragment
::
class
.
java
)
PageOption
.
to
(
CommonWebViewFragment
::
class
.
java
)
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
AcceleratorUtils
.
game
!!
.
id
)
.
setRequestCode
(
CLICK_START_ACC_REQUEST_CODE
)
.
setRequestCode
(
CLICK_START_ACC_REQUEST_CODE
)
.
open
(
this
)
.
open
(
this
)
}
?:
let
{
}
?:
let
{
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
View file @
00243d6d
...
@@ -29,10 +29,12 @@ import com.google.android.material.appbar.AppBarLayout
...
@@ -29,10 +29,12 @@ import com.google.android.material.appbar.AppBarLayout
import
com.google.android.material.tabs.TabLayout
import
com.google.android.material.tabs.TabLayout
import
com.google.android.material.tabs.TabLayoutMediator
import
com.google.android.material.tabs.TabLayoutMediator
import
com.hjq.toast.ToastUtils
import
com.hjq.toast.ToastUtils
import
com.xuexiang.xpage.annotation.Page
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xpage.utils.TitleBar
import
com.xuexiang.xpage.utils.TitleBar
import
com.xuexiang.xutil.app.AppUtils
import
com.xuexiang.xutil.app.AppUtils
@Page
(
name
=
"news"
)
class
NewsFragment
:
XPageFragment
()
{
class
NewsFragment
:
XPageFragment
()
{
private
var
_binding
:
FragmentNewsBinding
?
=
null
private
var
_binding
:
FragmentNewsBinding
?
=
null
private
val
binding
get
()
=
_binding
!!
private
val
binding
get
()
=
_binding
!!
...
@@ -42,6 +44,8 @@ class NewsFragment : XPageFragment() {
...
@@ -42,6 +44,8 @@ class NewsFragment : XPageFragment() {
return
null
return
null
}
}
private
var
gameId
:
Int
=
0
var
dataList
=
arrayListOf
<
Plugin
>()
var
dataList
=
arrayListOf
<
Plugin
>()
override
fun
inflateView
(
inflater
:
LayoutInflater
?,
container
:
ViewGroup
?):
View
{
override
fun
inflateView
(
inflater
:
LayoutInflater
?,
container
:
ViewGroup
?):
View
{
...
@@ -53,6 +57,7 @@ class NewsFragment : XPageFragment() {
...
@@ -53,6 +57,7 @@ class NewsFragment : XPageFragment() {
val
titles
=
arrayOf
(
"全部"
,
"攻略"
,
"视频"
,
"评价"
,
"问答"
)
val
titles
=
arrayOf
(
"全部"
,
"攻略"
,
"视频"
,
"评价"
,
"问答"
)
var
adapter
:
NewsCollectionAdapter
?
=
null
var
adapter
:
NewsCollectionAdapter
?
=
null
override
fun
initViews
()
{
override
fun
initViews
()
{
gameId
=
arguments
?.
getInt
(
CommonWebViewFragment
.
GAME_ID
)
!!
newsViewModel
.
notice
.
observe
(
this
)
{
it1
->
newsViewModel
.
notice
.
observe
(
this
)
{
it1
->
binding
.
newsNotice
.
visibility
=
View
.
VISIBLE
binding
.
newsNotice
.
visibility
=
View
.
VISIBLE
binding
.
tvMarquee
.
addDisplayString
(
it1
.
title
)
binding
.
tvMarquee
.
addDisplayString
(
it1
.
title
)
...
@@ -175,10 +180,9 @@ class NewsFragment : XPageFragment() {
...
@@ -175,10 +180,9 @@ class NewsFragment : XPageFragment() {
})
})
AcceleratorUtils
.
game
?.
let
{
newsViewModel
.
getNotice
(
gameId
)
newsViewModel
.
getNotice
(
it
.
id
)
newsViewModel
.
getPlugin
(
gameId
)
newsViewModel
.
getPlugin
(
it
.
id
)
}
}
}
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
...
@@ -191,6 +195,7 @@ class NewsFragment : XPageFragment() {
...
@@ -191,6 +195,7 @@ class NewsFragment : XPageFragment() {
fun
openToWebviewNative
(
url
:
String
)
{
fun
openToWebviewNative
(
url
:
String
)
{
val
params
=
Bundle
()
val
params
=
Bundle
()
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
params
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
gameId
)
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
}
...
@@ -198,6 +203,7 @@ class NewsFragment : XPageFragment() {
...
@@ -198,6 +203,7 @@ class NewsFragment : XPageFragment() {
fun
openToWebview
(
url
:
String
)
{
fun
openToWebview
(
url
:
String
)
{
val
params
=
Bundle
()
val
params
=
Bundle
()
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
url
)
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
url
)
params
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
gameId
)
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
}
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/web/CommonWebViewFragment.kt
View file @
00243d6d
...
@@ -42,6 +42,7 @@ class CommonWebViewFragment : XPageFragment() {
...
@@ -42,6 +42,7 @@ class CommonWebViewFragment : XPageFragment() {
override
fun
initViews
()
{
override
fun
initViews
()
{
val
url
=
arguments
?.
getString
(
WEBVIEW_URL_KEY
)
val
url
=
arguments
?.
getString
(
WEBVIEW_URL_KEY
)
val
gameId
=
arguments
?.
getInt
(
GAME_ID
)
show_title
=
arguments
?.
getBoolean
(
SHOW_TITLE
)
?:
false
show_title
=
arguments
?.
getBoolean
(
SHOW_TITLE
)
?:
false
if
(
show_title
)
{
if
(
show_title
)
{
binding
.
webBar
.
visibility
=
View
.
VISIBLE
binding
.
webBar
.
visibility
=
View
.
VISIBLE
...
@@ -59,10 +60,10 @@ class CommonWebViewFragment : XPageFragment() {
...
@@ -59,10 +60,10 @@ class CommonWebViewFragment : XPageFragment() {
var
weburl
=
it
var
weburl
=
it
if
(
weburl
.
contains
(
"?"
))
{
if
(
weburl
.
contains
(
"?"
))
{
weburl
=
weburl
=
weburl
+
"&channel=${SysUtils.getChannel()}&gameId=${
AcceleratorUtils.game?.i
d}"
weburl
+
"&channel=${SysUtils.getChannel()}&gameId=${
gameI
d}"
}
else
{
}
else
{
weburl
=
weburl
=
weburl
+
"?channel=${SysUtils.getChannel()}&gameId=${
AcceleratorUtils.game?.i
d}"
weburl
+
"?channel=${SysUtils.getChannel()}&gameId=${
gameI
d}"
}
}
LoginUtils
.
token
?.
let
{
LoginUtils
.
token
?.
let
{
weburl
=
weburl
+
"&token=${it}"
weburl
=
weburl
+
"&token=${it}"
...
@@ -192,5 +193,6 @@ class CommonWebViewFragment : XPageFragment() {
...
@@ -192,5 +193,6 @@ class CommonWebViewFragment : XPageFragment() {
companion
object
{
companion
object
{
val
WEBVIEW_URL_KEY
=
"WEBVIEW_URL_KEY"
val
WEBVIEW_URL_KEY
=
"WEBVIEW_URL_KEY"
val
SHOW_TITLE
=
"SHOW_TITLE"
val
SHOW_TITLE
=
"SHOW_TITLE"
val
GAME_ID
=
"GAME_ID"
}
}
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/utils/Constants.kt
0 → 100644
View file @
00243d6d
package
com.ccwangluo.accelerator.utils
class
Constants
{
companion
object
{
val
GAME_ID
=
"GAME_ID"
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/utils/SysUtils.kt
View file @
00243d6d
...
@@ -2,6 +2,7 @@ package com.ccwangluo.accelerator.utils
...
@@ -2,6 +2,7 @@ package com.ccwangluo.accelerator.utils
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.content.pm.ApplicationInfo
import
android.net.ConnectivityManager
import
android.net.ConnectivityManager
import
android.net.NetworkCapabilities
import
android.net.NetworkCapabilities
import
android.net.Uri
import
android.net.Uri
...
@@ -191,4 +192,48 @@ object SysUtils {
...
@@ -191,4 +192,48 @@ object SysUtils {
return
MMKV
.
defaultMMKV
().
decodeString
(
"device_uuid"
,
null
)
return
MMKV
.
defaultMMKV
().
decodeString
(
"device_uuid"
,
null
)
}
}
fun
compareVersionTo
(
localVersion
:
String
?,
remoteVersion
:
String
?):
Boolean
{
try
{
if
(
TextUtils
.
isEmpty
(
localVersion
)
||
TextUtils
.
isEmpty
(
remoteVersion
))
{
return
true
}
val
local
=
localVersion
!!
.
split
(
"\\."
)
val
remote
=
remoteVersion
!!
.
split
(
"\\."
)
if
(
local
.
size
!=
remote
.
size
||
local
.
size
==
0
)
{
return
true
}
for
(
i
in
0
..
local
.
size
)
{
if
(
local
[
i
].
toInt
()
<
remote
[
i
].
toInt
())
{
return
false
}
}
}
catch
(
e
:
java
.
lang
.
Exception
)
{
}
return
true
}
/**
* 获取手机已安装应用列表
* @param ctx
* @return
*/
fun
getAllAppInfo
(
ctx
:
Context
):
ArrayList
<
String
?
>?
{
val
appBeanList
:
ArrayList
<
String
?
>
=
ArrayList
()
val
packageManager
=
ctx
.
packageManager
val
list
=
packageManager
.
getInstalledPackages
(
0
)
for
(
p
in
list
)
{
val
flags
=
p
.
applicationInfo
.
flags
// 判断是否是属于系统的apk
if
(
flags
!=
ApplicationInfo
.
FLAG_SYSTEM
)
{
appBeanList
.
add
(
p
.
applicationInfo
.
packageName
)
}
}
return
appBeanList
}
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
View file @
00243d6d
...
@@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken
...
@@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken
import
com.hjq.toast.ToastUtils
import
com.hjq.toast.ToastUtils
import
com.xuexiang.xutil.XUtil
import
com.xuexiang.xutil.XUtil
import
okhttp3.*
import
okhttp3.*
import
okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import
okhttp3.MediaType.Companion.toMediaTypeOrNull
import
okhttp3.MediaType.Companion.toMediaTypeOrNull
import
okhttp3.RequestBody.Companion.toRequestBody
import
okhttp3.RequestBody.Companion.toRequestBody
import
timber.log.Timber
import
timber.log.Timber
...
@@ -79,7 +80,6 @@ object HttpGo {
...
@@ -79,7 +80,6 @@ object HttpGo {
return
null
return
null
}
}
val
jsonType
get
()
=
"application/json; charset=utf-8"
.
toMediaTypeOrNull
()
val
jsonType
get
()
=
"application/json; charset=utf-8"
.
toMediaTypeOrNull
()
...
...
app/src/main/res/layout/fragment_quick.xml
View file @
00243d6d
...
@@ -215,6 +215,7 @@
...
@@ -215,6 +215,7 @@
</RelativeLayout>
</RelativeLayout>
<LinearLayout
<LinearLayout
android:visibility=
"gone"
android:id=
"@+id/game_page"
android:id=
"@+id/game_page"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
app/src/main/res/layout/item_game.xml
View file @
00243d6d
...
@@ -214,6 +214,7 @@
...
@@ -214,6 +214,7 @@
android:background=
"@color/divide_gray"
/>
android:background=
"@color/divide_gray"
/>
<LinearLayout
<LinearLayout
android:id=
"@+id/game_notice_area_1"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"7.75dp"
android:layout_marginTop=
"7.75dp"
...
@@ -221,11 +222,13 @@
...
@@ -221,11 +222,13 @@
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
<TextView
<TextView
android:id=
"@+id/game_notice_1_1"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:gravity=
"center"
android:gravity=
"center"
android:maxLength=
"6"
android:text=
"资讯社区"
android:text=
"资讯社区"
android:textColor=
"#FF36B8F4"
android:textColor=
"#FF36B8F4"
android:textSize=
"11.5sp"
/>
android:textSize=
"11.5sp"
/>
...
@@ -237,11 +240,13 @@
...
@@ -237,11 +240,13 @@
android:background=
"@color/divide_gray"
/>
android:background=
"@color/divide_gray"
/>
<TextView
<TextView
android:id=
"@+id/game_notice_1_2"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:gravity=
"center"
android:gravity=
"center"
android:maxLength=
"6"
android:text=
"资讯社区"
android:text=
"资讯社区"
android:textColor=
"#FF36B8F4"
android:textColor=
"#FF36B8F4"
android:textSize=
"11.5sp"
/>
android:textSize=
"11.5sp"
/>
...
@@ -253,10 +258,12 @@
...
@@ -253,10 +258,12 @@
android:background=
"@color/divide_gray"
/>
android:background=
"@color/divide_gray"
/>
<TextView
<TextView
android:id=
"@+id/game_notice_1_3"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:maxLength=
"6"
android:gravity=
"center"
android:gravity=
"center"
android:text=
"资讯社区"
android:text=
"资讯社区"
android:textColor=
"#FF36B8F4"
android:textColor=
"#FF36B8F4"
...
@@ -264,6 +271,42 @@
...
@@ -264,6 +271,42 @@
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id=
"@+id/game_notice_area_2"
android:layout_width=
"match_parent"
android:layout_height=
"30dp"
android:layout_marginTop=
"9dp"
android:layout_marginBottom=
"9.5dp"
android:layout_marginLeft=
"22.5dp"
android:layout_marginRight=
"22.5dp"
android:orientation=
"horizontal"
android:background=
"@drawable/acc_text_bg_blue"
>
<TextView
android:id=
"@+id/game_notice_2_1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"【最新消息】常见问题解答,更新了~"
android:textColor=
"#FF36B8F4"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"5dp"
android:textSize=
"11sp"
/>
<TextView
android:layout_width=
"22dp"
android:layout_height=
"15dp"
android:text=
"查看 >"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"5dp"
android:textColor=
"#FF36B8F4"
android:textSize=
"11sp"
/>
</RelativeLayout>
<View
<View
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"13dp"
android:layout_height=
"13dp"
...
...
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