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
Expand all
Hide 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;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
com.xuexiang.xutil.app.AppUtils
;
public
class
AppDownloadReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/home/NewsFragment.kt
View file @
ead1ad79
...
...
@@ -101,13 +101,15 @@ class NewsFragment : XPageFragment() {
val
version
=
AppUtils
.
getAppVersionCode
(
it
.
packageName
)
itemData
.
url
?.
let
{
var
newversion
=
it
.
split
(
"/"
).
let
{
it1-
>
it1
.
get
(
it1
.
lastIndex
-
1
).
toInt
()
}
if
(
newversion
>
version
&&
version
!=
-
1
)
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
plugin_name
).
setText
(
"游戏更新"
)
itemView
.
findViewById
<
TextView
>(
R
.
id
.
plugin_name
)
.
setTextColor
(
Color
.
parseColor
(
"#329CF3"
))
if
(!
it
.
isNullOrBlank
()){
var
newversion
=
it
.
split
(
"/"
).
let
{
it1-
>
it1
.
get
(
it1
.
lastIndex
-
1
).
toInt
()
}
if
(
newversion
>
version
&&
version
!=
-
1
)
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
plugin_name
).
setText
(
"游戏更新"
)
itemView
.
findViewById
<
TextView
>(
R
.
id
.
plugin_name
)
.
setTextColor
(
Color
.
parseColor
(
"#329CF3"
))
}
}
}
}
...
...
@@ -138,7 +140,6 @@ class NewsFragment : XPageFragment() {
if
(
itemData
.
type
==
3
)
{
itemData
.
url
?.
let
{
DataRePortUtils
.
report
(
"st_game_down_clk"
,
mapOf
(
"scene"
to
"3"
))
activity
?.
let
{
it1
->
DownloadUtils
.
downloadFile
(
it1
,
it
)
}
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectFragment.kt
View file @
ead1ad79
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectModel.kt
View file @
ead1ad79
...
...
@@ -14,6 +14,7 @@ import kotlinx.coroutines.withContext
class
NewsObjectModel
:
ViewModel
()
{
val
newsModel
=
MutableLiveData
<
NewsModel
>()
val
clearList
=
MutableLiveData
<
Boolean
>()
fun
freshData
(
position
:
String
,
gameId
:
Int
,
page
:
Int
)
{
val
type
=
when
(
position
)
{
...
...
@@ -29,6 +30,7 @@ class NewsObjectModel : ViewModel() {
res
?.
let
{
if
(
it
.
code
==
200
)
{
it
.
data
?.
let
{
clearList
.
postValue
(
page
==
1
)
newsModel
.
postValue
(
it
)
}
}
...
...
@@ -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
>()
map
.
put
(
"gameId"
,
gameId
)
map
.
put
(
"parentId"
,
parentId
)
...
...
@@ -48,7 +57,7 @@ class NewsObjectModel : ViewModel() {
map
.
put
(
"type"
,
it
)
}
if
(
LoginUtils
.
token
==
null
)
{
xPageFragment
.
context
?.
let
{
LoginUtils
.
login
(
it
,{})
}
xPageFragment
.
context
?.
let
{
LoginUtils
.
login
(
it
,
{})
}
return
}
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)
* 跳转协议
*/
@JavascriptInterface
fun
openWebviewByWholeUrl
(
url
:
String
,
showTitle
:
Boolean
)
{
fun
openWebviewByWholeUrl
(
url
:
String
,
showTitle
:
Boolean
)
{
val
params
=
Bundle
()
if
(
url
.
startsWith
(
"http:"
)
||
url
.
startsWith
(
"https:"
))
{
params
.
putString
(
CommonWebViewFragment
.
WEBVIEW_URL_KEY
,
url
)
...
...
@@ -97,7 +97,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
*/
@JavascriptInterface
fun
openWebviewByWholeUrl
(
url
:
String
)
{
openWebviewByWholeUrl
(
url
,
false
)
openWebviewByWholeUrl
(
url
,
false
)
}
//打开系统设置
...
...
@@ -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 {
fun
initContext
(
context
:
XPageActivity
,
connect
:
ActivityResultLauncher
<
Void
?
>)
{
this
.
context
=
context
this
.
connect
=
connect
NetworkAdapter
.
initNetworks
(
context
)
ProfileManager
.
ensureNotEmpty
()
try
{
NetworkAdapter
.
initNetworks
(
context
)
ProfileManager
.
ensureNotEmpty
()
}
catch
(
e
:
Exception
)
{
}
context
.
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
while
(
true
)
{
if
(
state
==
BaseService
.
State
.
Connected
)
{
...
...
@@ -157,7 +161,7 @@ object AcceleratorUtils : TencentLocationListener {
}
}
fun
openLocation
(
context
:
Context
){
fun
openLocation
(
context
:
Context
)
{
PermissionUtils
.
permission
(
Manifest
.
permission
.
ACCESS_FINE_LOCATION
).
rationale
({
...
...
app/src/main/java/com/ccwangluo/accelerator/utils/DownloadUtils.kt
View file @
ead1ad79
...
...
@@ -7,16 +7,23 @@ import android.content.Intent
import
android.net.Uri
import
android.os.Build
import
android.os.Environment
import
android.webkit.MimeTypeMap
import
androidx.core.content.FileProvider
import
androidx.fragment.app.FragmentActivity
import
com.ccwangluo.accelerator.ui.dialog.DownloadDialog
import
com.hjq.toast.ToastUtils
import
com.xuexiang.xutil.app.AppUtils
import
com.xuexiang.xutil.file.FileUtils
import
com.xuexiang.xutil.system.PermissionUtils
import
java.io.File
object
DownloadUtils
{
fun
downloadFile
(
activity
:
FragmentActivity
,
url
:
String
)
{
if
(
url
.
isNullOrBlank
()){
return
}
if
(!
PermissionUtils
.
isGranted
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
))
{
ToastUtils
.
show
(
"下载需要打开存储权限"
)
PermissionUtils
.
permission
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
.
toString
())
...
...
@@ -26,22 +33,24 @@ object DownloadUtils {
return
}
var
filename
=
url
.
split
(
"/"
).
last
()
va
l
file
=
File
(
Environment
.
getExternalStorageDirectory
().
absolutePath
+
"/${Environment.DIRECTORY_DOWNLOADS}"
,
va
r
file
=
File
(
activity
.
getExternalFilesDir
(
Environment
.
DIRECTORY_DOWNLOADS
)
,
filename
)
if
(
file
.
exists
())
{
install
App
(
activity
,
file
)
install
(
file
.
absolutePath
,
activity
)
return
}
val
downloadManager
=
activity
.
getSystemService
(
Context
.
DOWNLOAD_SERVICE
)
as
DownloadManager
val
request
=
DownloadManager
.
Request
(
Uri
.
parse
(
url
))
//添加下载文件的网络路径
request
.
setDestinationInExternalPublicDir
(
Environment
.
DIRECTORY_DOWNLOADS
,
filename
)
//添加保存文件路径与名称
request
.
setDestinationInExternalFilesDir
(
activity
,
Environment
.
DIRECTORY_DOWNLOADS
,
filename
)
val
mimeTypeMap
=
MimeTypeMap
.
getSingleton
()
val
mimeString
=
mimeTypeMap
.
getMimeTypeFromExtension
(
MimeTypeMap
.
getFileExtensionFromUrl
(
url
))
request
.
setMimeType
(
mimeString
)
request
.
setTitle
(
"下载中"
)
//添加在通知栏里显示的标题
// request.setDescription("下载中") //添加在通知栏里显示的描述
...
...
@@ -57,29 +66,34 @@ object DownloadUtils {
DownloadDialog
(
activity
,
downloadManager
,
id
).
show
()
}
fun
installApp
(
context
:
Context
,
apkFile
:
File
)
{
try
{
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
intent
.
flags
=
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
val
contentUri
:
Uri
=
FileProvider
.
getUriForFile
(
context
,
"com.ccwangluo.accelerator.fileprovider"
,
apkFile
)
//authorities就是provider里声明的authorities
intent
.
setDataAndType
(
contentUri
,
"application/vnd.android.package-archive"
)
}
else
{
intent
.
setDataAndType
(
Uri
.
fromFile
(
apkFile
),
"application/vnd.android.package-archive"
)
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
}
context
.
startActivity
(
intent
)
}
catch
(
e
:
Exception
)
{
/**
* 描述: 安装
*/
fun
install
(
apkPath
:
String
,
context
:
Context
):
Boolean
{
// 没有root权限,利用意图进行安装
val
file
=
File
(
apkPath
)
if
(!
file
.
exists
())
{
return
false
}
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
)
val
uri
:
Uri
val
type
=
"application/vnd.android.package-archive"
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
)
{
uri
=
Uri
.
fromFile
(
file
)
}
else
{
val
authority
=
"com.ccwangluo.accelerator.fileprovider"
uri
=
FileProvider
.
getUriForFile
(
context
,
authority
,
file
)
intent
.
flags
=
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
}
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
)
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 {
"OPPO"
->
6
"baiduzhushou"
->
7
"wufan"
->
8
else
->
0
else
->
1
}
}
}
...
...
app/src/main/res/layout/item_dynamic.xml
View file @
ead1ad79
...
...
@@ -97,16 +97,42 @@
android:maxLines=
"3"
android:textColor=
"#FF4A4A4A"
android:textSize=
"14sp"
/>
<LinearLayout
android:layout_marginTop=
"12.65dp"
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
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:scaleType=
"centerCrop"
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>
<ImageView
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
android:id=
"@+id/imgs"
android:layout_width=
"match_parent"
android:layout_height=
"182.5dp"
android:layout_marginTop=
"12.65dp"
android:scaleType=
"fitXY"
android:visibility=
"gone"
/>
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
android:layout_marginLeft=
"20dp"
...
...
app/src/main/res/xml/filepaths.xml
View file @
ead1ad79
...
...
@@ -5,10 +5,16 @@
<root-path
name=
"opensdk_root"
path=
""
/>
<external-files-path
name=
"opensdk_external"
path=
"Images/tmp"
/>
<external-path
name=
"external_storage_root"
path=
"."
/>
<external-path
name=
"external"
path=
"./Download"
/>
<files-path
name=
"files"
path=
"."
/>
<files-path
name=
"files-path"
path=
"/."
/>
<cache-path
name=
"cache-path"
path=
"/."
/>
<external-path
name=
"external-path"
path=
"/."
/>
<external-files-path
name=
"external-files-path"
path=
"/."
/>
<external-cache-path
name=
"external-cache-path"
path=
"/."
/>
<external-path
path=
"."
name=
"download"
/>
<external-cache-path
name=
"storage/emulated/0"
path=
"."
/>
</paths>
\ No newline at end of file
buildSrc/src/main/kotlin/Helpers.kt
View file @
ead1ad79
...
...
@@ -56,8 +56,8 @@ fun Project.setupCore() {
setupCommon
()
android
.
apply
{
defaultConfig
{
versionCode
=
1
versionName
=
"1.0.
0
"
versionCode
=
2
versionName
=
"1.0.
1
"
}
compileOptions
.
isCoreLibraryDesugaringEnabled
=
true
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