Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
Out
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
xjl
Out
Commits
1e39f373
Commit
1e39f373
authored
Jan 04, 2024
by
shenpc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
b28738d9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
13 deletions
+46
-13
OutHelp.java
app/src/main/java/com/zl/sdk/OutHelp.java
+1
-1
AdManagerV2.java
app/src/main/java/com/zl/sdk/ad/AdManagerV2.java
+33
-7
CheckHelper.java
app/src/main/java/com/zl/sdk/out/CheckHelper.java
+1
-2
DxActivity.java
app/src/main/java/com/zl/sdk/out/ui/DxActivity.java
+11
-3
No files found.
app/src/main/java/com/zl/sdk/OutHelp.java
View file @
1e39f373
...
...
@@ -133,7 +133,7 @@ public final class OutHelp implements KPListener {
LogUtil
.
d
(
TAG
+
", 定时触发 !"
);
showOutAd
(
ActionFrom
.
ACTION_TIMER
);
}
},
0
,
60
*
1000
);
},
5
,
60
*
1000
);
}
private
void
initReceiver
()
{
...
...
app/src/main/java/com/zl/sdk/ad/AdManagerV2.java
View file @
1e39f373
package
com
.
zl
.
sdk
.
ad
;
import
android.app.Activity
;
import
android.text.TextUtils
;
import
com.anythink.core.api.ATAdInfo
;
import
com.anythink.core.api.ATAdStatusInfo
;
...
...
@@ -11,16 +12,18 @@ import com.zl.sdk.OutHelp;
import
com.zl.sdk.event.AdsParamsInfo
;
import
com.zl.sdk.event.EventUtils
;
import
com.zl.sdk.event.ReportBean
;
import
com.zl.sdk.event.statistics.Statistics
;
import
com.zl.sdk.out.AppOutSP
;
import
com.zl.sdk.util.AppOutUtils
;
import
com.zl.sdk.util.LogUtil
;
import
java.lang.ref.WeakReference
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
AdManagerV2
implements
ATInterstitialListener
{
private
volatile
ATInterstitial
atInterstitial
=
null
;
private
WeakReference
<
OnInAdListener
>
mListener
=
null
;
private
OnInAdListener
mListener
=
null
;
private
int
reloadCount
=
3
;
...
...
@@ -95,8 +98,9 @@ public class AdManagerV2 implements ATInterstitialListener {
requestTime
=
System
.
currentTimeMillis
();
EventUtils
.
statAdReport
(
getReportRequestBean
(
adId
));
LogUtil
.
d
(
"OutShow"
,
"Topon: ad show mListener="
+
mListener
);
if
(
mListener
!=
null
)
{
mListener
.
get
().
onShow
();
mListener
.
onShow
();
}
}
...
...
@@ -105,7 +109,8 @@ public class AdManagerV2 implements ATInterstitialListener {
LogUtil
.
d
(
"OutShow"
,
"Topon: ad close"
);
EventUtils
.
statAdClose
(
getReportBean
(
atAdInfo
,
null
));
if
(
mListener
!=
null
)
{
mListener
.
get
().
onCloseAd
();
mListener
.
onCloseAd
();
removeListener
();
}
}
...
...
@@ -128,7 +133,8 @@ public class AdManagerV2 implements ATInterstitialListener {
EventUtils
.
statDisplayFail
(
getReportBean
(
null
,
builder
));
if
(
mListener
!=
null
)
{
mListener
.
get
().
showFail
();
mListener
.
showFail
();
removeListener
();
}
}
...
...
@@ -137,6 +143,7 @@ public class AdManagerV2 implements ATInterstitialListener {
adId
=
id
;
if
(
atInterstitial
!=
null
)
{
ATAdStatusInfo
atAdStatusInfo
=
atInterstitial
.
checkAdStatus
();
LogUtil
.
d
(
"OutShow"
,
"atAdStatusInfo :"
+
atAdStatusInfo
);
if
(
atAdStatusInfo
.
isReady
())
{
LogUtil
.
d
(
"OutShow"
,
"ad isReady!"
);
return
false
;
...
...
@@ -163,10 +170,29 @@ public class AdManagerV2 implements ATInterstitialListener {
public
void
showAd
(
Activity
activity
,
OnInAdListener
listener
)
{
LogUtil
.
d
(
"OutShow"
,
"Topon: showAd"
);
mListener
=
new
WeakReference
<>(
listener
)
;
mListener
=
listener
;
ATInterstitial
.
entryAdScenario
(
"111"
,
""
);
atInterstitial
.
show
(
activity
);
statCallShow
(
activity
);
}
public
void
removeListener
()
{
mListener
=
null
;
}
private
void
statCallShow
(
Activity
activity
)
{
try
{
Map
<
String
,
Object
>
para
=
new
HashMap
<>();
para
.
put
(
"screen_state"
,
String
.
valueOf
(
AppOutUtils
.
isScreenOn
()));
para
.
put
(
"foreground"
,
OutHelp
.
get
().
isAppForeground
());
String
adPage
=
OutHelp
.
get
().
getPage
();
if
(!
TextUtils
.
isEmpty
(
adPage
))
{
para
.
put
(
"page"
,
adPage
);
}
Statistics
.
getInstance
().
dotEvent
(
activity
,
"ad_call_show"
,
""
,
para
);
}
catch
(
Exception
e
)
{
}
}
...
...
app/src/main/java/com/zl/sdk/out/CheckHelper.java
View file @
1e39f373
...
...
@@ -23,8 +23,7 @@ public class CheckHelper {
* 解锁/回到桌面 触发展示的外展广告
*/
public
static
boolean
checkAdCanShowByScene
(
int
actionState
,
String
scenes
)
{
if
((
actionState
==
ActionFrom
.
ACTION_TIMER
.
getAction
()
||
actionState
==
ActionFrom
.
ACTION_BATTERY_CHANGED
.
getAction
())
if
((
actionState
==
ActionFrom
.
ACTION_TIMER
.
getAction
())
&&
!
AppOutUtils
.
isScreenOn
())
{
LogUtil
.
d
(
TAG
+
"(场景检查)手机未亮屏,不能展示"
);
EventUtils
.
staDialogFail
(
DialogFailReason
.
SCREEN_OFF
,
actionState
,
scenes
,
EventUtils
.
DIALOG_TYPE_AD
);
...
...
app/src/main/java/com/zl/sdk/out/ui/DxActivity.java
View file @
1e39f373
...
...
@@ -5,6 +5,7 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.Window
;
import
android.view.WindowManager
;
...
...
@@ -96,6 +97,7 @@ public class DxActivity extends BaseActivity {
LogUtil
.
d
(
TAG
+
"onDestroy hashCode="
+
hashCode
());
mainHandler
.
removeCallbacksAndMessages
(
null
);
AdManagerV2
.
get
().
removeListener
();
final
long
time
=
Math
.
abs
(
onceStayTime
-
System
.
currentTimeMillis
());
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
...
...
@@ -110,7 +112,11 @@ public class DxActivity extends BaseActivity {
}
public
void
close
()
{
try
{
activity
.
finish
();
}
catch
(
Throwable
e
)
{
LogUtil
.
d
(
TAG
+
"close e="
+
Log
.
getStackTraceString
(
e
));
}
}
public
void
finishAndRemoveTask
()
{
...
...
@@ -150,16 +156,18 @@ public class DxActivity extends BaseActivity {
AdManagerV2
.
get
().
showAd
(
activity
,
new
OnInAdListener
()
{
@Override
public
void
onCloseAd
()
{
LogUtil
.
d
(
TAG
+
"onCloseAd"
);
close
();
}
@Override
public
void
onShow
()
{
LogUtil
.
d
(
TAG
+
"onShow"
);
}
@Override
public
void
showFail
()
{
LogUtil
.
d
(
TAG
+
"showFail"
);
close
();
}
});
...
...
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