Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_flowbox
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_flowbox
Commits
77161c8b
Commit
77161c8b
authored
Jul 06, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化用户定时器
parent
5ce4fc17
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
44 deletions
+71
-44
AlarmManager.java
...c/main/java/com/mints/flowbox/keepalive/AlarmManager.java
+58
-34
NotificationService.java
...java/com/mints/flowbox/keepalive/NotificationService.java
+0
-1
BoostActivity.kt
...main/java/com/mints/flowbox/ui/activitys/BoostActivity.kt
+12
-6
MainActivity.kt
.../main/java/com/mints/flowbox/ui/activitys/MainActivity.kt
+1
-3
No files found.
app/src/main/java/com/mints/flowbox/keepalive/AlarmManager.java
View file @
77161c8b
...
...
@@ -12,20 +12,24 @@ import com.mints.flowbox.ui.activitys.ScreenActivity;
import
com.mints.flowbox.utils.LogUtil
;
/**
* 描述:
保活进程高德地图管理
器
* 描述:
定时
器
* 作者:孟崔广
* 邮箱:mengcg@xiaojinqb.cn
*/
public
class
AlarmManager
implements
WeakHandler
.
IHandler
{
public
static
final
long
ONE_MINTER_Interval
=
60
*
1000
;
public
static
final
long
TEN_MINTER_Interval
=
10
*
60
*
1000
;
public
static
final
int
MSG1
=
1
;
public
static
final
int
MSG2
=
2
;
private
static
volatile
AlarmManager
_inst
;
//开屏广告加载发生超时但是SDK没有及时回调结果的时候,做的一层保护。
public
static
final
int
WIFI_MINTER
=
3
;
//单位-分钟,wifi页重置
public
static
final
int
USER_ACTIVE_MINTER
=
10
;
//单位-分钟,用户激活接口
public
static
final
int
APP_OUT_CLEAR_MINTER
=
10
;
//单位-分钟,应用外清理
public
static
final
long
ONE_MINTER_Interval
=
60
*
1000
;
//60秒
public
static
final
int
MSG1
=
1001
;
private
volatile
int
curTime
=
1
;
//每分钟变一次
public
volatile
int
userTime
=
1
;
//应用外用户操作时间
private
WeakHandler
mHandler
;
public
static
AlarmManager
getInstance
()
{
...
...
@@ -45,45 +49,60 @@ public class AlarmManager implements WeakHandler.IHandler {
private
void
init
()
{
mHandler
=
new
WeakHandler
(
this
);
curTime
=
1
;
userTime
=
1
;
}
public
void
startTime
()
{
// if (mHandler != null) {
// mHandler.removeCallbacksAndMessages(null);
// mHandler = null;
// }
// mHandler = new WeakHandler(this);
if
(
mHandler
!=
null
)
{
mHandler
.
sendEmptyMessageDelayed
(
MSG1
,
ONE_MINTER_Interval
);
}
}
public
void
startTime2
()
{
// if (mHandler != null) {
// mHandler.removeCallbacksAndMessages(null);
// mHandler = null;
// }
// mHandler = new WeakHandler(this);
if
(
mHandler
!=
null
)
{
mHandler
.
sendEmptyMessageDelayed
(
MSG2
,
TEN_MINTER_Interval
);
}
}
@Override
public
void
handleMsg
(
Message
msg
)
{
if
(
msg
.
what
==
MSG1
)
{
Intent
intent
=
new
Intent
(
MintsApplication
.
getContext
(),
BoostActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
MintsApplication
.
getContext
().
startActivity
(
intent
);
curTime
++;
if
(
curTime
>
60
)
curTime
=
1
;
// 防止userTime超出Integer范围
if
(
userTime
<
20
)
userTime
++;
TrackManager
.
getInstance
().
setMinsActive
();
// 固定时间增长
exeActionForTime
(
curTime
);
// 用户操作按时间增长
userActionForTime
(
userTime
);
if
(
mHandler
!=
null
)
{
mHandler
.
sendEmptyMessageDelayed
(
MSG1
,
ONE_MINTER_Interval
);
}
else
{
init
();
startTime
();
}
}
else
if
(
msg
.
what
==
MSG2
)
{
}
}
/**
* 用户操作按时间增长
*
* @param userTime
*/
private
void
userActionForTime
(
int
userTime
)
{
if
(
userTime
%
APP_OUT_CLEAR_MINTER
==
0
)
{
//用户关闭界面后10分钟调用
Intent
intent
=
new
Intent
(
MintsApplication
.
getContext
(),
BoostActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
MintsApplication
.
getContext
().
startActivity
(
intent
);
}
}
/**
* 固定时间增长
*
* @param curTime
*/
private
void
exeActionForTime
(
int
curTime
)
{
if
(
curTime
%
WIFI_MINTER
==
0
)
{
//每3分钟 wifi界面功能重置
AppConfig
.
isCanBoost
=
true
;
AppConfig
.
isCanClean
=
true
;
AppConfig
.
isCanSaveBattery
=
true
;
...
...
@@ -91,12 +110,17 @@ public class AlarmManager implements WeakHandler.IHandler {
AppConfig
.
fakeBoostCount
=
0
;
AppConfig
.
fakeCleanCount
=
0
;
AppConfig
.
fakeSaveBatteryCount
=
0
;
if
(
mHandler
!=
null
)
{
mHandler
.
sendEmptyMessageDelayed
(
MSG2
,
TEN_MINTER_Interval
);
}
else
{
init
();
}
}
else
if
(
curTime
%
USER_ACTIVE_MINTER
==
0
)
{
//每10分钟调用 用户激活接口
TrackManager
.
getInstance
().
setMinsActive
();
}
}
/**
* 重置用户操作时长
*/
public
void
resetUserActionTime
()
{
userTime
=
1
;
}
}
app/src/main/java/com/mints/flowbox/keepalive/NotificationService.java
View file @
77161c8b
...
...
@@ -49,7 +49,6 @@ public class NotificationService extends Service {
// 开启定时器
try
{
AlarmManager
.
getInstance
().
startTime
();
AlarmManager
.
getInstance
().
startTime2
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/BoostActivity.kt
View file @
77161c8b
...
...
@@ -6,6 +6,7 @@ import android.os.Handler
import
android.os.Looper
import
android.view.View
import
com.mints.flowbox.R
import
com.mints.flowbox.keepalive.AlarmManager
import
com.mints.flowbox.ui.activitys.base.BaseActivity
import
kotlinx.android.synthetic.main.activity_boost.*
...
...
@@ -26,6 +27,11 @@ class BoostActivity : BaseActivity() {
override
fun
isApplyKitKatTranslucency
()
=
true
override
fun
finish
()
{
super
.
finish
()
AlarmManager
.
getInstance
().
resetUserActionTime
()
}
override
fun
onResume
()
{
super
.
onResume
()
cleanMemory
()
...
...
@@ -34,12 +40,12 @@ class BoostActivity : BaseActivity() {
private
fun
cleanMemory
()
{
ccav_speed
.
startAnimation
()
Handler
(
Looper
.
getMainLooper
()).
postDelayed
(
{
ccav_speed
.
stopAnimation
()
ccav_speed
.
visibility
=
View
.
GONE
ll_ad
.
visibility
=
View
.
VISIBLE
},
2000
{
ccav_speed
.
stopAnimation
()
ccav_speed
.
visibility
=
View
.
GONE
ll_ad
.
visibility
=
View
.
VISIBLE
},
2000
)
}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/MainActivity.kt
View file @
77161c8b
...
...
@@ -84,7 +84,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
if
(!
TextUtils
.
isEmpty
(
UserManager
.
getInstance
().
userID
))
{
mainPresenter
.
getNetWorkIp
()
// TrackManager.getInstance().innerApp()
}
showPowerDialog
()
...
...
@@ -418,7 +417,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
override
fun
userLoginSuc
()
{
// 游客登录成功
mainPresenter
.
getNetWorkIp
()
TrackManager
.
getInstance
().
innerApp
()
mainPresenter
.
getHallBaseMsg
()
// token失效之后刷新数据
...
...
@@ -459,7 +457,7 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
AppConfig
.
app_black_name
=
data
.
userRiskApps
.
userRiskAppName
AppConfig
.
app_black_pkg
=
data
.
userRiskApps
.
userRiskAppPkg
CsjGroMoreManager
.
updataIdByChannel
(
data
.
gromoreAdcodes
)
//
CsjGroMoreManager.updataIdByChannel(data.gromoreAdcodes)
// 更新权重
UserWeight
.
initAdWeight
(
data
)
...
...
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