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
592fa953
Commit
592fa953
authored
Jan 30, 2021
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APP体验时间提示
parent
9db567c7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
TaskCpdHistoryFragment.kt
...com/mints/goodmoney/ui/fragment/TaskCpdHistoryFragment.kt
+1
-1
AppUtil.kt
...ey/app/src/main/java/com/mints/goodmoney/utils/AppUtil.kt
+18
-5
ToastUtil.java
...pp/src/main/java/com/mints/goodmoney/utils/ToastUtil.java
+8
-6
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/TaskCpdHistoryFragment.kt
View file @
592fa953
...
...
@@ -95,7 +95,7 @@ class TaskCpdHistoryFragment : LazyLoadBaseFragment(), TaskCpdHistoryView,
override
fun
onItemChildClick
(
view
:
View
?,
position
:
Int
)
{
when
(
mFakeTaskList
[
position
].
state
)
{
//
0 立即下载,
1 去试玩, 2 领取奖励 3 已领取 4 继续试玩
// 1 去试玩, 2 领取奖励 3 已领取 4 继续试玩
1
->
{
mTaskAdapter
?.
let
{
val
currentPkgName
=
mFakeTaskList
[
it
.
getPosition
()].
currentPkgName
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/AppUtil.kt
View file @
592fa953
...
...
@@ -12,7 +12,10 @@ import android.content.pm.PackageManager
import
android.os.Build
import
android.provider.Settings
import
com.fly.scenemodule.util.StringUtilMy
import
com.mints.goodmoney.BuildConfig
import
com.mints.goodmoney.MintsApplication
import
java.text.SimpleDateFormat
import
java.util.*
/**
...
...
@@ -130,12 +133,22 @@ object AppUtil {
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
-
2
*
6
*
1000L
,
l
)
val
list
=
usageStatsManager
.
queryUsageStats
(
UsageStatsManager
.
INTERVAL_BEST
,
l
-
5
*
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
// val str = (list[i] as UsageStats).packageName
// l = (list[i] as UsageStats).totalTimeInForeground
// 如果当前上次使用时间 小于 当前时间-5分钟,判断合规
if
(
paramString
==
(
list
[
i
]
as
UsageStats
).
packageName
&&
(
l
-
5
*
60
*
1000L
)
<
(
list
[
i
]
as
UsageStats
).
lastTimeUsed
)
{
if
(
BuildConfig
.
DEBUG
)
{
ToastUtil
.
showLong
(
paramContext
,
"当前APP名称:"
+
getAppName
(
paramString
,
paramContext
)
+
"\r\n"
+
"当前判定时间间隔:"
+
SimpleDateFormat
().
format
(
l
-
5
*
60
*
1000L
)
+
"至"
+
SimpleDateFormat
().
format
(
l
)
+
"\r\n"
+
"当前APP上次打开时间:"
+
SimpleDateFormat
().
format
((
list
[
i
]
as
UsageStats
).
lastTimeUsed
)
+
"\r\n"
+
"当前APP使用时间:"
+
(
list
[
i
]
as
UsageStats
).
totalTimeInForeground
.
toInt
()
/
1000
+
"秒"
)
}
return
(
list
[
i
]
as
UsageStats
).
totalTimeInForeground
.
toInt
()
/
1000
}
}
}
return
-
1
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/ToastUtil.java
View file @
592fa953
...
...
@@ -36,12 +36,14 @@ public class ToastUtil {
}
public
static
void
showLong
(
Context
context
,
String
msg
)
{
try
{
ToastUtils
.
show
(
msg
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
showToast
(
context
,
msg
,
Toast
.
LENGTH_LONG
,
Gravity
.
CENTER
);
}
// try {
// ToastUtils.show(msg);
// } catch (Exception e) {
// e.printStackTrace();
// showToast(context, msg, Toast.LENGTH_LONG, Gravity.CENTER);
// }
}
public
static
void
show
(
Context
context
,
String
msg
,
boolean
isShowToast
)
{
...
...
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