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
Expand all
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(
val
boosterServer
:
String
,
val
createdDate
:
String
,
val
dnsServer
:
String
,
val
downloadType
:
Int
,
val
downloadUrl
:
String
,
val
gameName
:
String
,
val
icon
:
String
,
...
...
@@ -36,5 +37,6 @@ data class Announcement(
val
id
:
Int
,
val
status
:
Int
,
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
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ccwangluo/accelerator/ui/gameList/GameListModel.kt
View file @
00243d6d
...
...
@@ -8,6 +8,7 @@ import com.ccwangluo.accelerator.model.GameInfo
import
com.ccwangluo.accelerator.utils.SysUtils
import
com.ccwangluo.accelerator.utils.http.HttpGo
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xutil.app.AppUtils
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
...
...
@@ -16,14 +17,16 @@ class GameListModel : ViewModel() {
val
gameModel
=
MutableLiveData
<
Game
>()
val
clearList
=
MutableLiveData
<
Boolean
>()
fun
freshData
(
xPageFragment
:
XPageFragment
,
page
:
Int
)
{
fun
freshData
(
xPageFragment
:
XPageFragment
,
page
:
Int
)
{
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
{
it
.
data
?.
let
{
clearList
.
postValue
(
page
==
1
)
gameModel
.
postValue
(
it
)
}
it
.
data
?.
let
{
clearList
.
postValue
(
page
==
1
)
gameModel
.
postValue
(
it
)
}
}
}
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/home/AcceleratorFragment.kt
View file @
00243d6d
...
...
@@ -65,7 +65,7 @@ class AcceleratorFragment : XPageFragment() {
override
fun
initViews
()
{
acceleratorViewModel
.
netState
.
observe
(
this
,
{
acceleratorViewModel
.
netState
.
observe
(
this
)
{
if
(
it
.
preNetDelay
!=
-
1
&&
state
==
BaseService
.
State
.
Connected
)
{
//有网络
binding
.
preDelay1
.
setText
(
it
.
preNetDelay
.
toString
())
...
...
@@ -110,7 +110,7 @@ class AcceleratorFragment : XPageFragment() {
binding
.
netQuality
.
setText
(
SysUtils
.
getnetQuality
(
it
.
preNetDelay
))
}
binding
.
activeNetwork
.
setText
(
SysUtils
.
getActiveNet
())
}
)
}
acceleratorViewModel
.
accState
.
observe
(
this
)
{
binding
.
accStateTx
.
setText
(
"加速中 ${SysUtils.getAccTimeString(accTimer)}"
)
...
...
@@ -313,6 +313,7 @@ class AcceleratorFragment : XPageFragment() {
fun
openToWebview
(
url
:
String
)
{
val
params
=
Bundle
()
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
params
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
AcceleratorUtils
.
game
!!
.
id
)
LoginUtils
.
token
?.
let
{
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
?:
let
{
...
...
@@ -338,6 +339,7 @@ class AcceleratorFragment : XPageFragment() {
LoginUtils
.
token
?.
let
{
PageOption
.
to
(
CommonWebViewFragment
::
class
.
java
)
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
AcceleratorUtils
.
game
!!
.
id
)
.
setRequestCode
(
CLICK_START_ACC_REQUEST_CODE
)
.
open
(
this
)
}
?:
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
import
com.google.android.material.tabs.TabLayout
import
com.google.android.material.tabs.TabLayoutMediator
import
com.hjq.toast.ToastUtils
import
com.xuexiang.xpage.annotation.Page
import
com.xuexiang.xpage.base.XPageFragment
import
com.xuexiang.xpage.utils.TitleBar
import
com.xuexiang.xutil.app.AppUtils
@Page
(
name
=
"news"
)
class
NewsFragment
:
XPageFragment
()
{
private
var
_binding
:
FragmentNewsBinding
?
=
null
private
val
binding
get
()
=
_binding
!!
...
...
@@ -42,6 +44,8 @@ class NewsFragment : XPageFragment() {
return
null
}
private
var
gameId
:
Int
=
0
var
dataList
=
arrayListOf
<
Plugin
>()
override
fun
inflateView
(
inflater
:
LayoutInflater
?,
container
:
ViewGroup
?):
View
{
...
...
@@ -53,6 +57,7 @@ class NewsFragment : XPageFragment() {
val
titles
=
arrayOf
(
"全部"
,
"攻略"
,
"视频"
,
"评价"
,
"问答"
)
var
adapter
:
NewsCollectionAdapter
?
=
null
override
fun
initViews
()
{
gameId
=
arguments
?.
getInt
(
CommonWebViewFragment
.
GAME_ID
)
!!
newsViewModel
.
notice
.
observe
(
this
)
{
it1
->
binding
.
newsNotice
.
visibility
=
View
.
VISIBLE
binding
.
tvMarquee
.
addDisplayString
(
it1
.
title
)
...
...
@@ -175,10 +180,9 @@ class NewsFragment : XPageFragment() {
})
AcceleratorUtils
.
game
?.
let
{
newsViewModel
.
getNotice
(
it
.
id
)
newsViewModel
.
getPlugin
(
it
.
id
)
}
newsViewModel
.
getNotice
(
gameId
)
newsViewModel
.
getPlugin
(
gameId
)
}
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
...
...
@@ -191,6 +195,7 @@ class NewsFragment : XPageFragment() {
fun
openToWebviewNative
(
url
:
String
)
{
val
params
=
Bundle
()
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
HttpConfig
.
UI_MAIN_URL
+
url
)
params
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
gameId
)
openPage
(
CommonWebViewFragment
::
class
.
java
,
params
)
}
...
...
@@ -198,6 +203,7 @@ class NewsFragment : XPageFragment() {
fun
openToWebview
(
url
:
String
)
{
val
params
=
Bundle
()
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
url
)
params
.
putInt
(
CommonWebViewFragment
.
GAME_ID
,
gameId
)
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() {
override
fun
initViews
()
{
val
url
=
arguments
?.
getString
(
WEBVIEW_URL_KEY
)
val
gameId
=
arguments
?.
getInt
(
GAME_ID
)
show_title
=
arguments
?.
getBoolean
(
SHOW_TITLE
)
?:
false
if
(
show_title
)
{
binding
.
webBar
.
visibility
=
View
.
VISIBLE
...
...
@@ -59,10 +60,10 @@ class CommonWebViewFragment : XPageFragment() {
var
weburl
=
it
if
(
weburl
.
contains
(
"?"
))
{
weburl
=
weburl
+
"&channel=${SysUtils.getChannel()}&gameId=${
AcceleratorUtils.game?.i
d}"
weburl
+
"&channel=${SysUtils.getChannel()}&gameId=${
gameI
d}"
}
else
{
weburl
=
weburl
+
"?channel=${SysUtils.getChannel()}&gameId=${
AcceleratorUtils.game?.i
d}"
weburl
+
"?channel=${SysUtils.getChannel()}&gameId=${
gameI
d}"
}
LoginUtils
.
token
?.
let
{
weburl
=
weburl
+
"&token=${it}"
...
...
@@ -192,5 +193,6 @@ class CommonWebViewFragment : XPageFragment() {
companion
object
{
val
WEBVIEW_URL_KEY
=
"WEBVIEW_URL_KEY"
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
import
android.content.Context
import
android.content.Intent
import
android.content.pm.ApplicationInfo
import
android.net.ConnectivityManager
import
android.net.NetworkCapabilities
import
android.net.Uri
...
...
@@ -191,4 +192,48 @@ object SysUtils {
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
import
com.hjq.toast.ToastUtils
import
com.xuexiang.xutil.XUtil
import
okhttp3.*
import
okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import
okhttp3.MediaType.Companion.toMediaTypeOrNull
import
okhttp3.RequestBody.Companion.toRequestBody
import
timber.log.Timber
...
...
@@ -79,7 +80,6 @@ object HttpGo {
return
null
}
val
jsonType
get
()
=
"application/json; charset=utf-8"
.
toMediaTypeOrNull
()
...
...
app/src/main/res/layout/fragment_quick.xml
View file @
00243d6d
...
...
@@ -215,6 +215,7 @@
</RelativeLayout>
<LinearLayout
android:visibility=
"gone"
android:id=
"@+id/game_page"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
app/src/main/res/layout/item_game.xml
View file @
00243d6d
...
...
@@ -214,6 +214,7 @@
android:background=
"@color/divide_gray"
/>
<LinearLayout
android:id=
"@+id/game_notice_area_1"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"7.75dp"
...
...
@@ -221,11 +222,13 @@
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/game_notice_1_1"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_weight=
"1"
android:gravity=
"center"
android:maxLength=
"6"
android:text=
"资讯社区"
android:textColor=
"#FF36B8F4"
android:textSize=
"11.5sp"
/>
...
...
@@ -237,11 +240,13 @@
android:background=
"@color/divide_gray"
/>
<TextView
android:id=
"@+id/game_notice_1_2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_weight=
"1"
android:gravity=
"center"
android:maxLength=
"6"
android:text=
"资讯社区"
android:textColor=
"#FF36B8F4"
android:textSize=
"11.5sp"
/>
...
...
@@ -253,10 +258,12 @@
android:background=
"@color/divide_gray"
/>
<TextView
android:id=
"@+id/game_notice_1_3"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_weight=
"1"
android:maxLength=
"6"
android:gravity=
"center"
android:text=
"资讯社区"
android:textColor=
"#FF36B8F4"
...
...
@@ -264,6 +271,42 @@
</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
android:layout_width=
"match_parent"
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