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
a0b51d39
Commit
a0b51d39
authored
Jan 06, 2021
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
14d42a9b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
39 deletions
+62
-39
VedioAdingManager.java
.../java/com/mints/goodmoney/ad/vedio/VedioAdingManager.java
+13
-13
AppTryPlayManager.kt
...ain/java/com/mints/goodmoney/manager/AppTryPlayManager.kt
+12
-11
AwardActivity.kt
...in/java/com/mints/goodmoney/ui/activitys/AwardActivity.kt
+7
-4
MyFragment.kt
...c/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
+13
-11
AppUtil.kt
...ey/app/src/main/java/com/mints/goodmoney/utils/AppUtil.kt
+17
-0
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/vedio/VedioAdingManager.java
View file @
a0b51d39
...
...
@@ -348,7 +348,7 @@ public class VedioAdingManager {
// 优量汇
if
(
ylhVedioAdManager
==
null
)
{
if
(
activity
==
null
)
{
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerError
(
Constant
.
YLH_VEDIO_AD
);
}
return
;
...
...
@@ -359,7 +359,7 @@ public class VedioAdingManager {
ylhVedioAdManager
.
setYlhVedioAdListener
(
new
YlhVedioAdManager
.
YlhVedioAdListener
()
{
@Override
public
void
ylhVedioAdFail
()
{
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerFail
(
Constant
.
YLH_VEDIO_AD
);
}
}
...
...
@@ -367,7 +367,7 @@ public class VedioAdingManager {
@Override
public
void
ylhVedioAdSuccess
()
{
AppConfig
.
ylhAdCount
--;
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerSuccess
(
Constant
.
YLH_VEDIO_AD
);
}
}
...
...
@@ -382,7 +382,7 @@ public class VedioAdingManager {
// 穿山甲激励视频
if
(
csjVedioAdManager
==
null
)
{
if
(
activity
==
null
)
{
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerError
(
Constant
.
CSJ_VEDIO_AD
);
}
return
;
...
...
@@ -394,7 +394,7 @@ public class VedioAdingManager {
csjVedioAdManager
.
setCsjVedioAdListener
(
new
CsjVedioAdManager
.
CsjVedioAdListener
()
{
@Override
public
void
csjVedioAdFail
()
{
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerFail
(
Constant
.
CSJ_VEDIO_AD
);
}
}
...
...
@@ -402,7 +402,7 @@ public class VedioAdingManager {
@Override
public
void
csjVedioAdSuccess
()
{
AppConfig
.
csjVedioAdCount
--;
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerSuccess
(
Constant
.
CSJ_VEDIO_AD
);
}
}
...
...
@@ -417,7 +417,7 @@ public class VedioAdingManager {
// 闪电盒子激励视频
if
(
wnVedioAdManager
==
null
)
{
if
(
activity
==
null
)
{
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerError
(
Constant
.
SDHZ_VEDIO_AD
);
}
return
;
...
...
@@ -428,14 +428,14 @@ public class VedioAdingManager {
@Override
public
void
wnVedioAdSuccess
()
{
AppConfig
.
wnVedioAdCount
--;
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerSuccess
(
Constant
.
SDHZ_VEDIO_AD
);
}
}
@Override
public
void
wnVedioAdFail
()
{
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerFail
(
Constant
.
SDHZ_VEDIO_AD
);
}
}
...
...
@@ -450,7 +450,7 @@ public class VedioAdingManager {
// 枫岚广告激励视频
if
(
mhVedioAdManager
==
null
)
{
if
(
activity
==
null
)
{
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerError
(
Constant
.
FL_VEDIO_AD
);
}
return
;
...
...
@@ -461,14 +461,14 @@ public class VedioAdingManager {
@Override
public
void
mhVedioAdSuccess
()
{
AppConfig
.
flVedioAdCount
--;
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerSuccess
(
Constant
.
FL_VEDIO_AD
);
}
}
@Override
public
void
mhVedioAdFail
()
{
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerFail
(
Constant
.
FL_VEDIO_AD
);
}
}
...
...
@@ -483,7 +483,7 @@ public class VedioAdingManager {
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
if
(
vedioAdingListener
!=
null
)
{
if
(
vedioAdingListener
!=
null
&&
!
isHighWeight
)
{
vedioAdingListener
.
vedioAdingListenerError
(
bean
.
getCarrierType
());
}
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/AppTryPlayManager.kt
View file @
a0b51d39
package
com.mints.goodmoney.manager
import
com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.mvp.model.EventMessage
import
com.mints.goodmoney.utils.RxBus
import
com.mints.goodmoney.utils.AppUtil
/**
...
...
@@ -12,24 +9,28 @@ import com.mints.goodmoney.utils.AppUtil
object
AppTryPlayManager
{
// 第一次打开时间
private
var
openTime
=
0L
//
private var openTime = 0L
private
var
currentPkg
=
""
fun
toTryPlay
(
pkg
:
String
)
{
if
(
currentPkg
!=
pkg
)
{
openTime
=
AppUtil
.
getAppUseTime
(
MintsApplication
.
getContext
(),
pkg
)
//
openTime = AppUtil.getAppUseTime(MintsApplication.getContext(), pkg)
AppUtil
.
openThirdApp
(
MintsApplication
.
getContext
(),
pkg
)
val
eventMessage
=
EventMessage
(
Constant
.
IS_HIGH_TASK
,
pkg
)
RxBus
.
getDefault
().
postSticky
(
eventMessage
)
//
val eventMessage = EventMessage(Constant.IS_HIGH_TASK, pkg)
//
RxBus.getDefault().postSticky(eventMessage)
currentPkg
=
pkg
}
}
fun
getTryPlayIsOK
(
pkg
:
String
):
Boolean
{
val
currentUseTime
=
AppUtil
.
getAppUseTime
(
MintsApplication
.
getContext
(),
pkg
)
openTime
=
0L
currentPkg
=
""
return
currentUseTime
-
openTime
>=
20
// val currentUseTime = AppUtil.getAppUseTime(MintsApplication.getContext(), pkg)
// openTime = 0L
// currentPkg = ""
// LogUtil.d("currentUseTime ->" + currentUseTime + "-- openTime ->" + openTime)
// return currentUseTime - openTime >= 100
val
timePkgUsed
=
AppUtil
.
getTimePkgUsed
(
MintsApplication
.
getContext
(),
pkg
)
return
timePkgUsed
>=
30
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/AwardActivity.kt
View file @
a0b51d39
...
...
@@ -260,11 +260,14 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
Constant
.
CARRIER_HIGH_ACTIVITY
->
{
if
(
curCoin
>
0
)
{
tvAwardContent
.
setText
(
"试玩奖励${curCoin}金币"
)
tvAwardNext
.
setText
(
"领取金币"
)
val
vo
=
HashMap
<
String
,
Any
>()
vo
[
"carrierType"
]
=
carrierType
awardPresenter
.
reportAddCoinMsg
(
vo
)
}
else
{
tvAwardContent
.
setText
(
"很遗憾,试玩不足30秒"
)
tvAwardNext
.
setText
(
"我知道了"
)
}
tvAwardNext
.
setText
(
"领取金币"
)
val
vo
=
HashMap
<
String
,
Any
>()
vo
[
"carrierType"
]
=
carrierType
awardPresenter
.
reportAddCoinMsg
(
vo
)
}
Constant
.
CARRIER_SIGNIN_HOMEPAGE_CARD
->
{
tvAwardContent
.
text
=
"奖励金币已发放"
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
View file @
a0b51d39
...
...
@@ -137,17 +137,18 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
// 刷新喜马拉雅信息流
TTPreLoadExpressXmlyManager
.
getInstance
().
loadTtFrameLayout
()
if
(
AppConfig
.
isHighTask
)
{
disposable
=
RxBus
.
getDefault
().
tObservableStick
(
EventMessage
::
class
.
java
).
subscribe
{
if
(
it
.
message
==
Constant
.
IS_HIGH_TASK
)
{
if
(
AppTryPlayManager
.
getTryPlayIsOK
(
it
.
content
as
String
))
{
myPresenter
.
setHighTaskType
(
"1"
)
}
else
{
myPresenter
.
setHighTaskType
(
"0"
)
}
}
AppConfig
.
isHighTask
=
false
if
(
AppConfig
.
isHighTask
&&
mCurrentPkg
!=
null
)
{
if
(
AppTryPlayManager
.
getTryPlayIsOK
(
mCurrentPkg
!!
))
{
myPresenter
.
setHighTaskType
(
"1"
)
}
else
{
val
bundle
=
Bundle
(
)
bundle
.
putInt
(
Constant
.
MAIN_CUR_COIN
,
0
)
bundle
.
putString
(
Constant
.
MAIN_CARRIER_TYPE
,
Constant
.
CARRIER_HIGH_ACTIVITY
)
readyGo
(
AwardActivity
::
class
.
java
,
bundle
)
myPresenter
.
setHighTaskType
(
"0"
)
}
AppConfig
.
isHighTask
=
false
}
}
}
...
...
@@ -467,9 +468,11 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
}
3
->
{
if
(
mCurrentPkg
==
null
)
{
showToast
(
"网络出小差儿了~"
)
myPresenter
.
setHighTaskType
(
"0"
)
myPresenter
.
getAutoUserHallBaseMsg
()
}
else
{
AppConfig
.
isHighTask
=
true
AppTryPlayManager
.
toTryPlay
(
mCurrentPkg
!!
)
}
}
...
...
@@ -1059,7 +1062,6 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
R
.
id
.
dialog_btn_right
->
{
cdaa
!!
.
dismiss
()
AppConfig
.
isHighTask
=
true
vedioAdingManager
.
setIsHighWeight
(
true
)
awardVedio
(
taskBean
.
otherConfig
.
coin
,
Constant
.
CARRIER_HIGH_ACTIVITY
)
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/AppUtil.kt
View file @
a0b51d39
package
com.mints.goodmoney.utils
import
android.app.Service
import
android.app.usage.UsageStats
import
android.app.usage.UsageStatsManager
import
android.content.Context
import
android.content.Intent
...
...
@@ -8,6 +9,7 @@ import android.content.pm.PackageInfo
import
android.content.pm.PackageManager
import
android.os.Build
import
android.provider.Settings
import
com.fly.scenemodule.util.StringUtilMy
import
com.mints.goodmoney.MintsApplication
...
...
@@ -110,4 +112,19 @@ object AppUtil {
return
packageInfo
!=
null
}
fun
getTimePkgUsed
(
paramContext
:
Context
,
paramString
:
String
):
Int
{
if
(
StringUtilMy
.
stringAvalable
(
paramString
)
&&
checkPackInfo
(
paramContext
,
paramString
)
&&
Build
.
VERSION
.
SDK_INT
>=
21
)
{
val
usageStatsManager
=
paramContext
.
getSystemService
(
"usagestats"
)
as
UsageStatsManager
var
l
=
System
.
currentTimeMillis
()
val
list
=
usageStatsManager
.
queryUsageStats
(
4
,
l
-
6
*
60
*
1000L
,
l
)
if
(
list
!=
null
&&
list
.
size
>
0
)
for
(
i
in
list
.
indices
)
{
val
str
=
(
list
[
i
]
as
UsageStats
).
packageName
(
list
[
i
]
as
UsageStats
).
lastTimeUsed
l
=
(
list
[
i
]
as
UsageStats
).
totalTimeInForeground
if
(
paramString
==
str
)
return
l
.
toInt
()
/
1000
}
}
return
-
1
}
}
\ No newline at end of file
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