Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_goodmoney
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_goodmoney
Commits
61cd15b1
Commit
61cd15b1
authored
Jan 30, 2021
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
dbb6df8f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
12 deletions
+26
-12
DownloadApkManager.kt
...in/java/com/mints/goodmoney/manager/DownloadApkManager.kt
+9
-5
TaskCpdActivity.kt
.../java/com/mints/goodmoney/ui/activitys/TaskCpdActivity.kt
+4
-0
TaskCpdFragment.kt
...n/java/com/mints/goodmoney/ui/fragment/TaskCpdFragment.kt
+12
-6
TaskCpdHistoryFragment.kt
...com/mints/goodmoney/ui/fragment/TaskCpdHistoryFragment.kt
+1
-1
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/DownloadApkManager.kt
View file @
61cd15b1
...
@@ -19,6 +19,7 @@ import com.mints.goodmoney.MintsApplication
...
@@ -19,6 +19,7 @@ import com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.R
import
com.mints.goodmoney.R
import
com.mints.goodmoney.ui.widgets.DownloadProgressDialog
import
com.mints.goodmoney.ui.widgets.DownloadProgressDialog
import
com.mints.goodmoney.utils.CacheUtil
import
com.mints.goodmoney.utils.CacheUtil
import
com.mints.goodmoney.utils.LogUtil
import
com.mints.goodmoney.utils.MD5
import
com.mints.goodmoney.utils.MD5
import
java.io.File
import
java.io.File
...
@@ -58,7 +59,11 @@ object DownloadApkManager {
...
@@ -58,7 +59,11 @@ object DownloadApkManager {
*/
*/
fun
downloadApk
(
activity
:
Activity
,
url
:
String
,
name
:
String
)
{
fun
downloadApk
(
activity
:
Activity
,
url
:
String
,
name
:
String
)
{
this
.
activity
=
activity
this
.
activity
=
activity
if
(
name
.
contains
(
".apk"
))
{
this
.
apkName
=
name
}
else
{
this
.
apkName
=
"$name.apk"
this
.
apkName
=
"$name.apk"
}
// 判断apk是否存在
// 判断apk是否存在
if
(
isFileExist
(
"$name.apk"
))
{
if
(
isFileExist
(
"$name.apk"
))
{
...
@@ -100,17 +105,16 @@ object DownloadApkManager {
...
@@ -100,17 +105,16 @@ object DownloadApkManager {
downloadProgressDialog
!!
.
show
()
downloadProgressDialog
!!
.
show
()
val
context
=
MintsApplication
.
getContext
()
val
context
=
MintsApplication
.
getContext
()
// cachePath = context.externalCacheDir?.path + "/Download/"
PRDownloader
.
download
(
url
,
cachePath
,
apkName
)
PRDownloader
.
download
(
url
,
cachePath
,
apkName
)
.
build
()
.
build
()
.
setOnProgressListener
{
progress
->
.
setOnProgressListener
{
progress
->
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
()
)
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
)
{
downloadProgressDialog
?.
setProgress
(
progress
)
downloadProgressDialog
?.
setProgress
(
progress
)
}
}
}
}
.
start
(
object
:
OnDownloadListener
{
.
start
(
object
:
OnDownloadListener
{
override
fun
onDownloadComplete
()
{
override
fun
onDownloadComplete
()
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
()
)
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
)
{
downloadProgressDialog
?.
dismiss
()
downloadProgressDialog
?.
dismiss
()
try
{
try
{
mDownloadListener
?.
onDownloadSuccess
(
cachePath
+
apkName
)
mDownloadListener
?.
onDownloadSuccess
(
cachePath
+
apkName
)
...
@@ -142,7 +146,7 @@ object DownloadApkManager {
...
@@ -142,7 +146,7 @@ object DownloadApkManager {
val
haveInstallPermission
=
context
.
packageManager
.
canRequestPackageInstalls
()
val
haveInstallPermission
=
context
.
packageManager
.
canRequestPackageInstalls
()
if
(!
haveInstallPermission
)
{
if
(!
haveInstallPermission
)
{
showAlert
(
activity
!!
,
"安装权限"
,
"需要打开允许来自此来源,请去设置中开启此权限"
,
showAlert
(
activity
!!
,
"安装权限"
,
"需要打开允许来自此来源,请去设置中开启此权限"
,
DialogInterface
.
OnClickListener
{
dialog
,
which
->
DialogInterface
.
OnClickListener
{
_
,
_
->
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
//此方法需要API>=26才能使用
//此方法需要API>=26才能使用
toInstallPermissionSettingIntent
()
toInstallPermissionSettingIntent
()
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/TaskCpdActivity.kt
View file @
61cd15b1
...
@@ -74,6 +74,10 @@ class TaskCpdActivity : BaseActivity(), View.OnClickListener {
...
@@ -74,6 +74,10 @@ class TaskCpdActivity : BaseActivity(), View.OnClickListener {
xtTaskCpd
.
setupWithViewPager
(
vpTaskCpd
)
xtTaskCpd
.
setupWithViewPager
(
vpTaskCpd
)
}
}
fun
selectTwoFragment
()
{
vpTaskCpd
.
setCurrentItem
(
1
,
true
)
}
private
fun
backDialog
()
{
private
fun
backDialog
()
{
cdaa
=
CustomDialogAsApple
(
context
,
object
:
DialogListener
()
{
cdaa
=
CustomDialogAsApple
(
context
,
object
:
DialogListener
()
{
override
fun
onClick
(
v
:
View
)
{
override
fun
onClick
(
v
:
View
)
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/TaskCpdFragment.kt
View file @
61cd15b1
...
@@ -9,6 +9,7 @@ import android.view.View
...
@@ -9,6 +9,7 @@ import android.view.View
import
androidx.recyclerview.widget.GridLayoutManager
import
androidx.recyclerview.widget.GridLayoutManager
import
com.mints.goodmoney.R
import
com.mints.goodmoney.R
import
com.mints.goodmoney.ad.download.CoralDownload
import
com.mints.goodmoney.ad.download.CoralDownload
import
com.mints.goodmoney.common.AppConfig
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.common.DeviceInfo
import
com.mints.goodmoney.common.DeviceInfo
import
com.mints.goodmoney.manager.AppTryPlayManager
import
com.mints.goodmoney.manager.AppTryPlayManager
...
@@ -20,6 +21,7 @@ import com.mints.goodmoney.mvp.presenters.TaskPresenter
...
@@ -20,6 +21,7 @@ import com.mints.goodmoney.mvp.presenters.TaskPresenter
import
com.mints.goodmoney.mvp.views.TaskView
import
com.mints.goodmoney.mvp.views.TaskView
import
com.mints.goodmoney.service.AppInstallService
import
com.mints.goodmoney.service.AppInstallService
import
com.mints.goodmoney.ui.activitys.AwardActivity
import
com.mints.goodmoney.ui.activitys.AwardActivity
import
com.mints.goodmoney.ui.activitys.TaskCpdActivity
import
com.mints.goodmoney.ui.adapter.TaskAdapter
import
com.mints.goodmoney.ui.adapter.TaskAdapter
import
com.mints.goodmoney.ui.adapter.listener.OnItemChildClickListener
import
com.mints.goodmoney.ui.adapter.listener.OnItemChildClickListener
import
com.mints.goodmoney.ui.fragment.base.BaseFragment
import
com.mints.goodmoney.ui.fragment.base.BaseFragment
...
@@ -70,8 +72,8 @@ class TaskCpdFragment : BaseFragment(), TaskView,
...
@@ -70,8 +72,8 @@ class TaskCpdFragment : BaseFragment(), TaskView,
private
var
mCoin
=
0
private
var
mCoin
=
0
private
var
needUseTime
=
-
1
// 应用试玩时间
private
var
needUseTime
=
-
1
// 应用试玩时间
private
var
shMax
=
3
//珊瑚 广告最大填充数
private
var
shMax
=
0
//珊瑚 广告最大填充数
private
var
cpdMax
=
3
//CPD 广告最大填充数
private
var
cpdMax
=
0
//CPD 广告最大填充数
private
var
shLoadCountTime
=
0
// 珊瑚 加载广告次数
private
var
shLoadCountTime
=
0
// 珊瑚 加载广告次数
private
var
cpdLoadCountTime
=
0
// CPD 加载广告次数
private
var
cpdLoadCountTime
=
0
// CPD 加载广告次数
...
@@ -142,6 +144,12 @@ class TaskCpdFragment : BaseFragment(), TaskView,
...
@@ -142,6 +144,12 @@ class TaskCpdFragment : BaseFragment(), TaskView,
if
((
shMax
+
cpdMax
)
<=
0
)
{
if
((
shMax
+
cpdMax
)
<=
0
)
{
hideLoading
()
hideLoading
()
showToast
(
"今日任务已完成,请明日再试"
)
showToast
(
"今日任务已完成,请明日再试"
)
// 跳转试玩任务
notifyDataAndShowAd
()
if
(
AppConfig
.
useAppCpdModelShow
)
{
(
activity
as
TaskCpdActivity
).
selectTwoFragment
()
}
return
return
}
}
...
@@ -176,7 +184,6 @@ class TaskCpdFragment : BaseFragment(), TaskView,
...
@@ -176,7 +184,6 @@ class TaskCpdFragment : BaseFragment(), TaskView,
// 圣于地广告 循环完成后去重
// 圣于地广告 循环完成后去重
if
(
cpdLoadCountTime
++
>=
cpdMax
-
1
)
{
if
(
cpdLoadCountTime
++
>=
cpdMax
-
1
)
{
// notifyDataAndShowAd()
getCpdRepeatPkg
()
getCpdRepeatPkg
()
}
}
}
}
...
@@ -184,9 +191,8 @@ class TaskCpdFragment : BaseFragment(), TaskView,
...
@@ -184,9 +191,8 @@ class TaskCpdFragment : BaseFragment(), TaskView,
override
fun
getCpdModelFail
()
{
override
fun
getCpdModelFail
()
{
LogUtil
.
d
(
TAG
,
"syd getCpdModelFail"
)
LogUtil
.
d
(
TAG
,
"syd getCpdModelFail"
)
if
(
cpdLoadCountTime
++
>=
cpdMax
-
1
)
{
if
(
cpdLoadCountTime
++
>=
cpdMax
-
1
)
{
notifyDataAndShowAd
()
getCpdRepeatPkg
()
}
}
}
}
...
@@ -221,7 +227,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
...
@@ -221,7 +227,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
// 数据重复
// 数据重复
if
(
i
!=
j
&&
mFakeTaskList
[
i
].
downLoadPkgName
==
mFakeTaskList
[
j
].
downLoadPkgName
)
{
if
(
i
!=
j
&&
mFakeTaskList
[
i
].
downLoadPkgName
==
mFakeTaskList
[
j
].
downLoadPkgName
)
{
LogUtil
.
d
(
TAG
,
"syd currentPkgName:"
+
mFakeTaskList
[
i
].
downLoadPkgName
)
LogUtil
.
d
(
TAG
,
"syd currentPkgName:"
+
mFakeTaskList
[
i
].
downLoadPkgName
)
flag
=
false
flag
=
false
break
break
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/TaskCpdHistoryFragment.kt
View file @
61cd15b1
...
@@ -160,7 +160,7 @@ class TaskCpdHistoryFragment : LazyLoadBaseFragment(), TaskCpdHistoryView,
...
@@ -160,7 +160,7 @@ class TaskCpdHistoryFragment : LazyLoadBaseFragment(), TaskCpdHistoryView,
private
fun
refreshDemoTask
()
{
private
fun
refreshDemoTask
()
{
mTaskAdapter
?.
let
{
mTaskAdapter
?.
let
{
val
position
=
it
.
getPosition
()
val
position
=
it
.
getPosition
()
if
(
mFakeTaskList
.
size
==
0
||
mFakeTaskList
[
position
].
state
==
3
)
return
if
(
mFakeTaskList
.
size
==
1
||
mFakeTaskList
[
position
].
state
==
3
)
return
val
currentPkgName
=
mFakeTaskList
[
position
].
currentPkgName
val
currentPkgName
=
mFakeTaskList
[
position
].
currentPkgName
if
(
currentPkgName
!=
null
)
{
if
(
currentPkgName
!=
null
)
{
...
...
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