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
331e2978
Commit
331e2978
authored
Jan 23, 2021
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加去重代码
parent
26d3ffac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
19 deletions
+132
-19
DeviceInfo.kt
...pp/src/main/java/com/mints/goodmoney/common/DeviceInfo.kt
+32
-0
CpdManager.kt
...p/src/main/java/com/mints/goodmoney/manager/CpdManager.kt
+2
-0
TaskPresenter.kt
.../java/com/mints/goodmoney/mvp/presenters/TaskPresenter.kt
+2
-1
TaskActivity.kt
...ain/java/com/mints/goodmoney/ui/activitys/TaskActivity.kt
+96
-18
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/common/DeviceInfo.kt
View file @
331e2978
...
@@ -684,6 +684,38 @@ class DeviceInfo private constructor() {
...
@@ -684,6 +684,38 @@ class DeviceInfo private constructor() {
return
pkg
return
pkg
}
}
/**
*
*
* return:包名
*/
fun
isLoadingPkg
(
pkg
:
String
):
Boolean
{
var
flag
=
false
try
{
val
mainintent
=
Intent
(
Intent
.
ACTION_MAIN
,
null
)
mainintent
.
addCategory
(
Intent
.
CATEGORY_LAUNCHER
)
val
packageinfo
=
mContext
!!
.
packageManager
.
getInstalledPackages
(
0
)
var
pinfo
:
PackageInfo
?
=
null
val
count
=
packageinfo
.
size
for
(
i
in
0
until
count
)
{
pinfo
=
packageinfo
[
i
]
val
appInfo
=
pinfo
.
applicationInfo
if
(
appInfo
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
>
0
)
{
//系统程序 忽略
}
else
{
//非系统程序
if
(
TextUtils
.
equals
(
pkg
,
pinfo
.
packageName
))
{
return
true
}
}
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
flag
}
/**
/**
* Android ID
* Android ID
*
*
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/CpdManager.kt
View file @
331e2978
...
@@ -4,6 +4,8 @@ import com.mints.goodmoney.MintsApplication
...
@@ -4,6 +4,8 @@ import com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.common.DeviceInfo
import
com.mints.goodmoney.common.DeviceInfo
import
com.mints.goodmoney.net.CpdService
import
com.mints.goodmoney.net.CpdService
import
com.mints.goodmoney.utils.MD5
import
com.mints.goodmoney.utils.MD5
import
com.mints.goodmoney.utils.rxutil.CommonRxTask
import
com.mints.goodmoney.utils.rxutil.RxjavaUtil
import
com.mints.library.net.netstatus.NetUtils
import
com.mints.library.net.netstatus.NetUtils
import
okhttp3.MediaType.Companion.toMediaTypeOrNull
import
okhttp3.MediaType.Companion.toMediaTypeOrNull
import
okhttp3.RequestBody
import
okhttp3.RequestBody
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/mvp/presenters/TaskPresenter.kt
View file @
331e2978
...
@@ -66,7 +66,8 @@ class TaskPresenter : BasePresenter<TaskView>() {
...
@@ -66,7 +66,8 @@ class TaskPresenter : BasePresenter<TaskView>() {
}
}
override
fun
onError
(
e
:
Throwable
)
{
override
fun
onError
(
e
:
Throwable
)
{
LogUtil
.
d
(
e
.
code
)
LogUtil
.
d
(
""
+
e
.
code
+
" -> "
+
e
.
message
)
view
.
getCpdModelFail
()
}
}
override
fun
onNext
(
t
:
JsonObject
?)
{
override
fun
onNext
(
t
:
JsonObject
?)
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/TaskActivity.kt
View file @
331e2978
...
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.GridLayoutManager
...
@@ -10,6 +10,7 @@ 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.Constant
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.common.DeviceInfo
import
com.mints.goodmoney.manager.AppTryPlayManager
import
com.mints.goodmoney.manager.AppTryPlayManager
import
com.mints.goodmoney.manager.DownloadApkManager
import
com.mints.goodmoney.manager.DownloadApkManager
import
com.mints.goodmoney.mvp.model.CpdModelBean
import
com.mints.goodmoney.mvp.model.CpdModelBean
...
@@ -25,6 +26,8 @@ import com.mints.goodmoney.ui.widgets.DialogListener
...
@@ -25,6 +26,8 @@ import com.mints.goodmoney.ui.widgets.DialogListener
import
com.mints.goodmoney.ui.widgets.TaskCpdDialog
import
com.mints.goodmoney.ui.widgets.TaskCpdDialog
import
com.mints.goodmoney.ui.widgets.TaskDialog
import
com.mints.goodmoney.ui.widgets.TaskDialog
import
com.mints.goodmoney.utils.*
import
com.mints.goodmoney.utils.*
import
com.mints.goodmoney.utils.rxutil.CommonRxTask
import
com.mints.goodmoney.utils.rxutil.RxjavaUtil
import
com.scwang.smartrefresh.layout.api.RefreshLayout
import
com.scwang.smartrefresh.layout.api.RefreshLayout
import
com.scwang.smartrefresh.layout.listener.OnRefreshListener
import
com.scwang.smartrefresh.layout.listener.OnRefreshListener
import
com.tz.sdk.coral.ad.CoralAD
import
com.tz.sdk.coral.ad.CoralAD
...
@@ -32,6 +35,7 @@ import com.tz.sdk.coral.callback.h5.DownloadProcess
...
@@ -32,6 +35,7 @@ import com.tz.sdk.coral.callback.h5.DownloadProcess
import
kotlinx.android.synthetic.main.activity_task.*
import
kotlinx.android.synthetic.main.activity_task.*
import
kotlinx.android.synthetic.main.header_layout.*
import
kotlinx.android.synthetic.main.header_layout.*
/**
/**
*
*
* 描述:试玩任务
* 描述:试玩任务
...
@@ -64,6 +68,9 @@ class TaskActivity : BaseActivity(), TaskView,
...
@@ -64,6 +68,9 @@ class TaskActivity : BaseActivity(), TaskView,
// 试完时间不足弹窗
// 试完时间不足弹窗
private
var
tryTimeOut
=
false
private
var
tryTimeOut
=
false
// 第二次拉取重复不拉取
private
var
isTwiceGetCpd
=
false
companion
object
{
companion
object
{
const
val
TASK_COIN
=
"task_coin"
const
val
TASK_COIN
=
"task_coin"
const
val
TASK_USE_MAX
=
"task_use_max"
const
val
TASK_USE_MAX
=
"task_use_max"
...
@@ -143,6 +150,8 @@ class TaskActivity : BaseActivity(), TaskView,
...
@@ -143,6 +150,8 @@ class TaskActivity : BaseActivity(), TaskView,
shMax
=
CPD
shMax
=
CPD
cpdMax
=
CPD_SYD
cpdMax
=
CPD_SYD
isTwiceGetCpd
=
false
if
((
shMax
+
cpdMax
)
<=
0
)
{
if
((
shMax
+
cpdMax
)
<=
0
)
{
hideLoading
()
hideLoading
()
showToast
(
"今日任务已完成,请明日再试"
)
showToast
(
"今日任务已完成,请明日再试"
)
...
@@ -167,33 +176,102 @@ class TaskActivity : BaseActivity(), TaskView,
...
@@ -167,33 +176,102 @@ class TaskActivity : BaseActivity(), TaskView,
mFakeTaskList
.
add
(
tzTaskBean
)
mFakeTaskList
.
add
(
tzTaskBean
)
}
}
LogUtil
.
d
(
TAG_LOG
,
"CPD -> getCpdModelSuc
"
)
LogUtil
.
d
(
TAG_LOG
,
"CPD -> getCpdModelSuc
CPD-PKG -> "
+
dataBean
.
materials
[
0
].
app_apk_name
)
// 多拉取的CPD广告
// 多拉取的CPD广告
if
(
cpdLoadCountTime
++
==
cpdMax
-
1
)
{
if
(
cpdLoadCountTime
++
==
cpdMax
-
1
)
{
hideLoadin
g
()
getCpdRepeatPk
g
()
srl_task
.
finishRefresh
()
}
mTaskAdapter
?.
notifyDataSetChanged
()
}
for
(
tzTaskBean
in
mFakeTaskList
)
{
/**
if
(!
tzTaskBean
.
isShCpd
)
{
* 遍历去重APP包名
val
trackerBean
=
tzTaskBean
.
trackerBean
*/
if
(
trackerBean
!=
null
)
{
private
fun
getCpdRepeatPkg
()
{
LogUtil
.
d
(
TAG_LOG
,
"CPD -> show"
)
if
(
isTwiceGetCpd
)
{
LogUtil
.
d
(
"isTwiceGetCpd"
)
notifyDataAndShowAd
()
return
}
var
thatCpdLoadCountTime
=
cpdMax
// 上报CPD显示
RxjavaUtil
.
executeRxTask
<
MutableList
<
TzTaskBean
>>(
object
:
CommonRxTask
<
MutableList
<
TzTaskBean
>>()
{
taskPresenter
.
cmtImp
(
trackerBean
.
show
[
0
])
override
fun
doInIOThread
()
{
val
newPkgData
=
mutableListOf
<
TzTaskBean
>()
for
(
i
in
0
until
mFakeTaskList
.
size
)
{
if
(
mFakeTaskList
[
i
].
isShCpd
)
{
newPkgData
.
add
(
mFakeTaskList
[
i
])
}
else
{
for
(
j
in
0
until
mFakeTaskList
.
size
)
{
if
(!
mFakeTaskList
[
j
].
isShCpd
&&
!
mFakeTaskList
[
i
].
isShCpd
)
{
if
(
mFakeTaskList
[
j
].
currentPkgName
==
mFakeTaskList
[
i
].
currentPkgName
)
{
// 是否已经安装此app
if
(!
DeviceInfo
.
instance
.
isLoadingPkg
(
mFakeTaskList
[
j
].
currentPkgName
))
{
newPkgData
.
add
(
mFakeTaskList
[
j
])
}
else
{
thatCpdLoadCountTime
--
}
}
else
{
thatCpdLoadCountTime
--
}
}
}
}
}
}
}
t
=
newPkgData
}
override
fun
doInUIThread
()
{
LogUtil
.
d
(
"数据源 列表数据"
+
"-->"
+
mFakeTaskList
.
size
)
mFakeTaskList
.
clear
()
mFakeTaskList
.
addAll
(
t
)
LogUtil
.
d
(
"列表数据"
+
"-->"
+
mFakeTaskList
.
size
)
LogUtil
.
d
(
"thatCpdLoadCountTime"
+
"-->"
+
thatCpdLoadCountTime
)
// 重新获取数据
if
(
thatCpdLoadCountTime
<
cpdMax
-
1
)
{
isTwiceGetCpd
=
true
for
(
i
in
thatCpdLoadCountTime
until
cpdMax
)
{
loadCPDData
()
}
return
}
else
{
notifyDataAndShowAd
()
}
}
})
}
fun
notifyDataAndShowAd
()
{
hideLoading
()
srl_task
.
finishRefresh
()
mTaskAdapter
?.
notifyDataSetChanged
()
for
(
tzTaskBean
in
mFakeTaskList
)
{
if
(!
tzTaskBean
.
isShCpd
)
{
val
trackerBean
=
tzTaskBean
.
trackerBean
if
(
trackerBean
!=
null
)
{
LogUtil
.
d
(
TAG_LOG
,
"CPD -> show"
)
// 上报CPD显示
taskPresenter
.
cmtImp
(
trackerBean
.
show
[
0
])
}
}
}
}
}
}
}
override
fun
getCpdModelFail
()
{
override
fun
getCpdModelFail
()
{
if
(
cpdLoadCountTime
==
cpdMax
-
1
)
{
notifyDataAndShowAd
()
hideLoading
()
srl_task
.
finishRefresh
()
}
}
}
override
fun
onRefresh
(
refreshLayout
:
RefreshLayout
)
{
override
fun
onRefresh
(
refreshLayout
:
RefreshLayout
)
{
...
@@ -451,14 +529,14 @@ class TaskActivity : BaseActivity(), TaskView,
...
@@ -451,14 +529,14 @@ class TaskActivity : BaseActivity(), TaskView,
val
trackerBean
=
mFakeTaskList
[
position
].
trackerBean
val
trackerBean
=
mFakeTaskList
[
position
].
trackerBean
if
(
trackerBean
!=
null
)
{
if
(
trackerBean
!=
null
)
{
// 上报CPD激活完成
// 上报CPD激活完成
LogUtil
.
d
(
TAG_LOG
,
"CPD -> install_start"
)
LogUtil
.
d
(
TAG_LOG
,
"CPD -> install_finish"
)
LogUtil
.
d
(
TAG_LOG
,
"CPD -> activation"
)
LogUtil
.
d
(
TAG_LOG
,
"CPD -> install_start"
)
taskPresenter
.
cmtImp
(
trackerBean
.
install_start
[
0
])
taskPresenter
.
cmtImp
(
trackerBean
.
install_start
[
0
])
LogUtil
.
d
(
TAG_LOG
,
"CPD -> install_finish"
)
taskPresenter
.
cmtImp
(
trackerBean
.
install_finish
[
0
])
taskPresenter
.
cmtImp
(
trackerBean
.
install_finish
[
0
])
LogUtil
.
d
(
TAG_LOG
,
"CPD -> activation"
)
taskPresenter
.
cmtImp
(
trackerBean
.
activation
[
0
])
taskPresenter
.
cmtImp
(
trackerBean
.
activation
[
0
])
}
}
}
}
...
...
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