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
b88d4e35
Commit
b88d4e35
authored
Jul 07, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加wifi gromore广告管理
parent
0926f4f5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
146 additions
and
29 deletions
+146
-29
MintsApplication.java
app/src/main/java/com/mints/flowbox/MintsApplication.java
+17
-13
FullGroManager.java
...c/main/java/com/mints/flowbox/ad/full/FullGroManager.java
+2
-2
WifiAdManager.kt
app/src/main/java/com/mints/flowbox/ad/wifi/WifiAdManager.kt
+101
-0
Constant.kt
app/src/main/java/com/mints/flowbox/common/Constant.kt
+5
-1
AlarmManager.java
...c/main/java/com/mints/flowbox/keepalive/AlarmManager.java
+10
-3
ForegroundOrBackground.java
.../java/com/mints/flowbox/utils/ForegroundOrBackground.java
+9
-9
BaseWebActivity.java
...src/main/java/com/mints/library/base/BaseWebActivity.java
+2
-1
No files found.
app/src/main/java/com/mints/flowbox/MintsApplication.java
View file @
b88d4e35
...
...
@@ -184,29 +184,29 @@ public class MintsApplication extends BaseApp {
AdHelper
.
getInstance
().
init
(
this
);
// 这个用来在release版本出toast,方便测试
if
(
TextUtils
.
isEmpty
(
channel
)
||
"BUG"
.
equalsIgnoreCase
(
channel
))
{
// release 模式下,无渠道号就弹这个TOAST,这样方便监测进程启动,可以去掉
Toast
.
makeText
(
this
,
"测试:主进程重启成功"
,
Toast
.
LENGTH_LONG
).
show
();
}
//
if (TextUtils.isEmpty(channel) || "BUG".equalsIgnoreCase(channel)) {
//
// release 模式下,无渠道号就弹这个TOAST,这样方便监测进程启动,可以去掉
//
Toast.makeText(this, "测试:主进程重启成功", Toast.LENGTH_LONG).show();
//
}
// 监听锁屏状态
ScreenWatch
.
getInstance
(
this
).
begin
(()
->
{
showScreen
();
ToastUtils
.
show
(
"--> 唤醒屏幕 <--"
);
//
ToastUtils.show("--> 唤醒屏幕 <--");
});
// 监听锁屏状态
HomeKeyWatch
.
getInstance
(
this
).
begin
(
new
HomeKeyWatch
.
HomeKeyStateListener
()
{
@Override
public
void
onHOME_KEY
()
{
ToastUtils
.
show
(
"--> 点击HOME建 <--"
);
//
ToastUtils.show("--> 点击HOME建 <--");
// showScreen();
}
@Override
public
void
onRECENT_APPS
()
{
ToastUtils
.
show
(
"--> 最近任务列表 <--"
);
//
ToastUtils.show("--> 最近任务列表 <--");
// showScreen();
}
});
...
...
@@ -215,7 +215,7 @@ public class MintsApplication extends BaseApp {
PhoneWatch
.
getInstance
(
this
).
begin
(
new
PhoneWatch
.
PhoneStateListener
()
{
@Override
public
void
onIdle
()
{
ToastUtils
.
show
(
"--> 电话挂断 <--"
);
//
ToastUtils.show("--> 电话挂断 <--");
}
});
...
...
@@ -225,13 +225,13 @@ public class MintsApplication extends BaseApp {
public
void
onCharging
()
{
showScreen
();
ToastUtils
.
show
(
"--> 正在充电 <--"
);
//
ToastUtils.show("--> 正在充电 <--");
}
@Override
public
void
onUnCharging
()
{
showScreen
();
ToastUtils
.
show
(
"--> 停止充电 <--"
);
//
ToastUtils.show("--> 停止充电 <--");
}
});
...
...
@@ -239,17 +239,17 @@ public class MintsApplication extends BaseApp {
PackageWatch
.
getInstance
(
this
).
begin
(
new
PackageWatch
.
InstallStateListener
()
{
@Override
public
void
onAdded
()
{
ToastUtils
.
show
(
"--> APK安装 <--"
);
//
ToastUtils.show("--> APK安装 <--");
}
@Override
public
void
onReplaced
()
{
ToastUtils
.
show
(
"--> APK卸载 <--"
);
//
ToastUtils.show("--> APK卸载 <--");
}
@Override
public
void
onRemoved
()
{
ToastUtils
.
show
(
"--> APK移除 <--"
);
//
ToastUtils.show("--> APK移除 <--");
}
});
...
...
@@ -261,6 +261,10 @@ public class MintsApplication extends BaseApp {
}
private
void
showScreen
()
{
if
(
ForegroundOrBackground
.
isForeground
())
{
return
;
}
Intent
intent
=
new
Intent
(
MintsApplication
.
getContext
(),
ScreenActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
MintsApplication
.
this
.
startActivity
(
intent
);
...
...
app/src/main/java/com/mints/flowbox/ad/full/FullGroManager.java
View file @
b88d4e35
...
...
@@ -123,8 +123,8 @@ public class FullGroManager {
vo
.
put
(
"adcode"
,
mTTFullVideoAd
.
getAdNetworkRitId
());
vo
.
put
(
"ecpm"
,
mTTFullVideoAd
.
getPreEcpm
());
vo
.
put
(
"adSource"
,
mTTFullVideoAd
.
getAdNetworkPlatformId
());
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE
3
);
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_
INTERSTITIA
L_ID
());
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE
4
);
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_
FUL
L_ID
());
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
}
else
{
// 当加载到广告后 ,长时间未展示失效时 改变状态
...
...
app/src/main/java/com/mints/flowbox/ad/wifi/WifiAdManager.kt
0 → 100644
View file @
b88d4e35
package
com.mints.flowbox.ad.wifi
import
android.app.Activity
import
com.mints.flowbox.ad.full.FullGroManager
import
com.mints.flowbox.ad.inscreen.InterstitialGroManager
import
com.mints.flowbox.common.Constant
import
java.util.*
/**
* wifi广告管理
*
* 广告形式-Gromore的插屏、全屏
*/
class
WifiAdManager
{
// groMore插屏
private
var
interstitialGroManager
:
InterstitialGroManager
?
=
null
// groMore全屏
private
var
fullGroManager
:
FullGroManager
?
=
null
// 当前广告类型
private
var
currentAdType
=
""
/**
* 预加载广告,必须传入activity
*/
fun
loadWifiAd
(
activity
:
Activity
)
{
currentAdType
=
getCurrentAdType
()
when
(
currentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
preLoadInterstitialGroMore
(
activity
)
}
Constant
.
GROMORE_FULL_AD
->
{
preLoadFullGroMore
(
activity
)
}
}
}
/**
* 定义广告类型规则
*/
private
fun
getCurrentAdType
():
String
{
var
tempAdType
=
""
val
randomInt
=
Random
().
nextInt
(
10
)
if
(
randomInt
%
2
==
0
)
{
tempAdType
=
Constant
.
GROMORE_INSERTSCREEN_AD
}
else
{
tempAdType
=
Constant
.
GROMORE_FULL_AD
}
return
tempAdType
}
/**
* 插屏
*/
private
fun
preLoadInterstitialGroMore
(
activity
:
Activity
)
{
if
(
interstitialGroManager
!=
null
)
{
interstitialGroManager
?.
onDestroy
()
}
interstitialGroManager
=
InterstitialGroManager
()
interstitialGroManager
?.
loadInsertScreenAd
(
activity
)
}
/**
* 全屏
*/
private
fun
preLoadFullGroMore
(
activity
:
Activity
)
{
if
(
fullGroManager
!=
null
)
{
fullGroManager
?.
onDestroy
()
}
fullGroManager
=
FullGroManager
()
fullGroManager
?.
loadFullAd
(
activity
)
}
/**
* 展示广告
*/
fun
showInterstitial
()
{
when
(
currentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
interstitialGroManager
?.
showInteractionAd
()
}
Constant
.
GROMORE_FULL_AD
->
{
fullGroManager
?.
showFullAd
()
}
}
}
fun
onDestroy
()
{
interstitialGroManager
?.
onDestroy
()
interstitialGroManager
=
null
fullGroManager
?.
onDestroy
()
fullGroManager
=
null
}
}
\ No newline at end of file
app/src/main/java/com/mints/flowbox/common/Constant.kt
View file @
b88d4e35
...
...
@@ -184,6 +184,9 @@ object Constant {
const
val
CSJ_INSERTSCREEN_AD
=
"CSJ_INSERTSCREEN_AD"
const
val
YLH_INSERTSCREEN_AD
=
"YLH_INSERTSCREEN_AD"
// 全屏广告类型
const
val
GROMORE_FULL_AD
=
"GROMORE_FULL_AD"
// 热门活动类型
const
val
HOT_ACTIVITY_WATER
=
"water"
const
val
HOT_ACTIVITY_WALK
=
"walk"
...
...
@@ -224,11 +227,12 @@ object Constant {
// 外网IP地址
const
val
OUT_NET_IP
=
"out_net_ip"
//0-开屏,1-信息流,2-激励视频
//0-开屏,1-信息流,2-激励视频
,3-插屏,4-全屏
const
val
GRO_MORE_ADTYPE0
=
"0"
const
val
GRO_MORE_ADTYPE1
=
"1"
const
val
GRO_MORE_ADTYPE2
=
"2"
const
val
GRO_MORE_ADTYPE3
=
"3"
const
val
GRO_MORE_ADTYPE4
=
"4"
// 大转盘是否自动转动 true-自动
const
val
TURNTABLE_SWITCH_BUTTON
=
"TURNTABLE_SWITCH_BUTTON"
...
...
app/src/main/java/com/mints/flowbox/keepalive/AlarmManager.java
View file @
b88d4e35
...
...
@@ -8,9 +8,10 @@ import com.mints.flowbox.MintsApplication;
import
com.mints.flowbox.common.AppConfig
;
import
com.mints.flowbox.manager.TrackManager
;
import
com.mints.flowbox.ui.activitys.BoostActivity
;
import
com.mints.flowbox.utils.ForegroundOrBackground
;
/**
* 描述:定时器
* 描述:
应用外广告
定时器
* 作者:孟崔广
* 邮箱:mengcg@xiaojinqb.cn
*/
...
...
@@ -60,8 +61,7 @@ public class AlarmManager implements WeakHandler.IHandler {
@Override
public
void
handleMsg
(
Message
msg
)
{
if
(
msg
.
what
==
MSG1
)
{
curTime
++;
if
(
curTime
>
60
)
curTime
=
1
;
curTime
=
curTime
>
60
?
curTime
=
1
:
curTime
++;
// 防止userTime超出Integer范围
if
(
userTime
<
20
)
userTime
++;
...
...
@@ -79,6 +79,13 @@ public class AlarmManager implements WeakHandler.IHandler {
*/
private
void
userActionForTime
(
int
userTime
)
{
if
(
userTime
%
APP_OUT_CLEAR_MINTER
==
0
)
{
// 应用在前台时,不弹出应用外广告
if
(
ForegroundOrBackground
.
isForeground
())
{
this
.
resetUserActionTime
();
return
;
}
//用户关闭界面后10分钟调用
Intent
intent
=
new
Intent
(
MintsApplication
.
getContext
(),
BoostActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
...
...
app/src/main/java/com/mints/flowbox/utils/ForegroundOrBackground.java
View file @
b88d4e35
...
...
@@ -31,6 +31,15 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
private
VersionUpdatePresenter
vup
;
private
WeakReference
<
Activity
>
reference
;
/**
* 是否在前台
*
* @return true-前台
*/
public
static
boolean
isForeground
()
{
return
count
==
0
?
true
:
false
;
}
public
static
ForegroundOrBackground
init
(
Application
application
)
{
if
(
instance
==
null
)
{
instance
=
new
ForegroundOrBackground
();
...
...
@@ -112,15 +121,6 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
if
(
count
==
0
)
{
leaveTime
=
System
.
currentTimeMillis
();
String
simpleName
=
activity
.
getClass
().
getSimpleName
();
if
(
TextUtils
.
equals
(
simpleName
,
"SplashGroMoreActivity"
)
||
TextUtils
.
equals
(
simpleName
,
"GuideActivity"
)
||
TextUtils
.
equals
(
simpleName
,
"AwardActivity"
)
||
TextUtils
.
equals
(
simpleName
,
"DrawcashActivity"
))
{
count
++;
return
;
}
TrackManager
.
getInstance
().
offline
();
}
}
...
...
app/src/main/java/com/mints/library/base/BaseWebActivity.java
View file @
b88d4e35
...
...
@@ -26,7 +26,9 @@ import android.widget.TextView;
import
com.mints.flowbox.R
;
import
com.mints.flowbox.utils.LogUtil
;
import
com.mints.library.net.netstatus.NetUtils
;
import
com.mints.library.swipeback.SwipeBackLayout
;
import
com.mints.library.utils.CommonUtils
;
import
com.mints.library.widgets.BrowserLayout
;
...
...
@@ -70,7 +72,6 @@ public class BaseWebActivity extends BaseSwipeBackCompatActivity {
@Override
protected
void
initViewsAndEvents
()
{
setSystemBarTintDrawable
(
ContextCompat
.
getDrawable
(
this
,
R
.
drawable
.
sr_primary_r
));
title
.
findViewById
(
R
.
id
.
title
);
mBrowserLayout
.
findViewById
(
R
.
id
.
common_web_browser_layout
);
leftBtn
.
findViewById
(
R
.
id
.
left_btn
);
...
...
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