Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_youyou
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_youyou
Commits
ca56df1e
Commit
ca56df1e
authored
Mar 30, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
a5432f3c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
41 deletions
+74
-41
PreLoadExpressManager.kt
...ava/com/wenshu/youyou/ad/express/PreLoadExpressManager.kt
+2
-2
YlhPreLoadExpressManager.kt
.../com/wenshu/youyou/ad/express/YlhPreLoadExpressManager.kt
+69
-35
YlhAdManager.kt
app/src/main/java/com/wenshu/youyou/manager/YlhAdManager.kt
+1
-1
GsonConverterFactory.java
...main/java/com/wenshu/youyou/net/GsonConverterFactory.java
+1
-2
dialog_power.xml
app/src/main/res/layout/dialog_power.xml
+1
-1
No files found.
app/src/main/java/com/wenshu/youyou/ad/express/PreLoadExpressManager.kt
View file @
ca56df1e
...
@@ -129,7 +129,7 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
...
@@ -129,7 +129,7 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
mAdFrameLayout
=
adFrameLayout
mAdFrameLayout
=
adFrameLayout
}
}
override
fun
onYlhAdLoadSuc
(
view
:
NativeExpressAD
View
?)
{
override
fun
onYlhAdLoadSuc
(
view
:
View
?)
{
// if (currentIndex == 2) {
// if (currentIndex == 2) {
// mAdFrameLayout?.addView(view)
// mAdFrameLayout?.addView(view)
// }
// }
...
@@ -150,7 +150,7 @@ interface TTADLoadSuccessListener {
...
@@ -150,7 +150,7 @@ interface TTADLoadSuccessListener {
}
}
interface
YLHADLoadSuccessListener
{
interface
YLHADLoadSuccessListener
{
fun
onYlhAdLoadSuc
(
view
:
NativeExpressAD
View
?)
fun
onYlhAdLoadSuc
(
view
:
View
?)
}
}
interface
KSADLoadSuccessListener
{
interface
KSADLoadSuccessListener
{
...
...
app/src/main/java/com/wenshu/youyou/ad/express/YlhPreLoadExpressManager.kt
View file @
ca56df1e
package
com.wenshu.youyou.ad.express
package
com.wenshu.youyou.ad.express
import
com.wenshu.youyou.BuildConfig
import
com.qq.e.ads.nativ.ADSize
import
com.qq.e.ads.nativ.express2.*
import
com.qq.e.comm.util.AdError
import
com.wenshu.youyou.WenshuApplication
import
com.wenshu.youyou.WenshuApplication
import
com.wenshu.youyou.manager.YlhAdManager
import
com.wenshu.youyou.manager.YlhAdManager
import
com.wenshu.youyou.utils.LogUtil
import
com.wenshu.youyou.utils.LogUtil
import
com.qq.e.ads.nativ.ADSize
import
com.qq.e.ads.nativ.NativeExpressAD
import
com.qq.e.ads.nativ.NativeExpressADView
import
com.qq.e.comm.util.AdError
/**
/**
* 优量汇预加载信息流
* 优量汇预加载信息流
*/
*/
object
YlhPreLoadExpressManager
{
object
YlhPreLoadExpressManager
{
private
var
nativeExpressAD
:
NativeExpressAD
?
=
null
private
var
nativeExpressAD
:
NativeExpressAD
2
?
=
null
private
var
nativeExpressADView
:
NativeExpressADView
?
=
null
private
var
mNativeExpressADData2
:
NativeExpressADData2
?
=
null
private
var
mADLoadSuccessListener
:
YLHADLoadSuccessListener
?
=
null
private
var
mADLoadSuccessListener
:
YLHADLoadSuccessListener
?
=
null
...
@@ -25,55 +24,90 @@ object YlhPreLoadExpressManager {
...
@@ -25,55 +24,90 @@ object YlhPreLoadExpressManager {
fun
loadYlhFrameLayout
()
{
fun
loadYlhFrameLayout
()
{
try
{
try
{
nativeExpressAD
=
NativeExpressAD
(
WenshuApplication
.
getContext
(),
ADSize
(
ADSize
.
FULL_WIDTH
,
ADSize
.
AUTO_HEIGHT
),
YlhAdManager
.
YLH_AD_NATIVEEXPRESS_AWARD
,
object
:
NativeExpressAD
.
NativeExpressADListener
{
nativeExpressAD
=
NativeExpressAD2
(
WenshuApplication
.
getContext
(),
YlhAdManager
.
YLH_AD_NATIVEEXPRESS_AWARD
,
object
:
NativeExpressAD2
.
AdLoadListener
{
override
fun
onNoAD
(
p0
:
AdError
?)
{
override
fun
onLoadSuccess
(
adDataList
:
MutableList
<
NativeExpressADData2
>)
{
if
(
BuildConfig
.
DEBUG
)
{
// 渲染广告
LogUtil
.
d
(
"通用奖励 ylh:TTNativeExpressManager"
,
"onError ${p0?.errorCode} ${p0?.errorMsg}"
)
renderAd
(
adDataList
)
}
}
}
override
fun
onADClicked
(
p0
:
NativeExpressADView
?)
{
override
fun
onNoAD
(
p0
:
AdError
?)
{
LogUtil
.
d
(
"YlhPreLoadExpressManager"
,
"code:${p0?.errorCode} msg:${p0?.errorMsg}"
)
}
}
})
loadAd
()
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
override
fun
onADCloseOverlay
(
p0
:
NativeExpressADView
?)
{
private
fun
loadAd
()
{
}
nativeExpressAD
?.
setAdSize
(
ADSize
.
FULL_WIDTH
,
ADSize
.
AUTO_HEIGHT
)
// 如果您在平台上新建平台模板2.0广告位时,选择了支持视频,那么可以进行个性化设置(可选)
val
builder
=
VideoOption2
.
Builder
()
/**
* 如果广告位支持视频广告,强烈建议在调用loadData请求广告前设置setAutoPlayPolicy,有助于提高视频广告的eCPM值 <br/>
* 如果广告位仅支持图文广告,则无需调用
*/
/**
* 如果广告位支持视频广告,强烈建议在调用loadData请求广告前设置setAutoPlayPolicy,有助于提高视频广告的eCPM值 <br></br>
* 如果广告位仅支持图文广告,则无需调用
*/
builder
.
setAutoPlayPolicy
(
VideoOption2
.
AutoPlayPolicy
.
WIFI
)
// WIFI 环境下可以自动播放视频
.
setAutoPlayMuted
(
true
)
// 自动播放时为静音
.
setDetailPageMuted
(
false
)
// 视频详情页播放时不静音
.
setMaxVideoDuration
(
0
)
// 设置返回视频广告的最大视频时长(闭区间,可单独设置),单位:秒,默认为 0 代表无限制,合法输入为:5<=maxVideoDuration<=61. 此设置会影响广告填充,请谨慎设置
.
setMinVideoDuration
(
0
)
// 设置返回视频广告的最小视频时长(闭区间,可单独设置),单位:秒,默认为 0 代表无限制, 此设置会影响广告填充,请谨慎设置
nativeExpressAD
?.
setVideoOption2
(
builder
.
build
())
nativeExpressAD
?.
loadAd
(
1
)
}
override
fun
onADClosed
(
p0
:
NativeExpressADView
?)
{
private
fun
renderAd
(
adDataList
:
List
<
NativeExpressADData2
>)
{
// 释放前一个展示的NativeExpressADView的资源
mNativeExpressADData2
?.
destroy
()
if
(
adDataList
.
size
>
0
)
{
mNativeExpressADData2
=
adDataList
[
0
]
mNativeExpressADData2
?.
getECPMLevel
()
+
" Video duration: "
+
mNativeExpressADData2
?.
getVideoDuration
()
mNativeExpressADData2
?.
setAdEventListener
(
object
:
AdEventListener
{
override
fun
onClick
()
{
}
}
override
fun
on
ADExposure
(
p0
:
NativeExpressADView
?
)
{
override
fun
on
Exposed
(
)
{
}
}
override
fun
onADLeftApplication
(
p0
:
NativeExpressADView
?)
{
override
fun
onRenderSuccess
()
{
if
(
mNativeExpressADData2
?.
getAdView
()
!=
null
)
{
mADLoadSuccessListener
?.
onYlhAdLoadSuc
(
mNativeExpressADData2
?.
getAdView
())
}
}
}
override
fun
onADLoaded
(
p0
:
MutableList
<
NativeExpressADView
>?)
{
override
fun
onRenderFail
()
{
// 释放前一个展示的NativeExpressADView的资源
}
nativeExpressADView
?.
destroy
()
nativeExpressADView
=
p0
?.
get
(
0
)
// 广告可见才会产生曝光,否则将无法产生收益。
override
fun
onAdClosed
()
{
mADLoadSuccessListener
?.
onYlhAdLoadSuc
(
nativeExpressADView
)
}
})
mNativeExpressADData2
?.
setMediaListener
(
object
:
MediaEventListener
{
override
fun
onVideoCache
()
{
}
nativeExpressADView
?.
render
()
override
fun
onVideoStart
()
{
}
}
override
fun
on
ADOpenOverlay
(
p0
:
NativeExpressADView
?
)
{
override
fun
on
VideoResume
(
)
{
}
}
override
fun
on
RenderFail
(
p0
:
NativeExpressADView
?
)
{
override
fun
on
VideoPause
(
)
{
}
}
override
fun
on
RenderSuccess
(
p0
:
NativeExpressADView
?
)
{
override
fun
on
VideoComplete
(
)
{
}
}
override
fun
onVideoError
()
{
}
})
})
nativeExpressAD
?.
loadAD
(
1
)
mNativeExpressADData2
?.
render
()
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
}
...
@@ -82,7 +116,7 @@ object YlhPreLoadExpressManager {
...
@@ -82,7 +116,7 @@ object YlhPreLoadExpressManager {
*/
*/
fun
onDestroy
()
{
fun
onDestroy
()
{
// 使用完了每一个NativeExpressADView之后都要释放掉资源
// 使用完了每一个NativeExpressADView之后都要释放掉资源
nativeExpressADView
?.
destroy
()
mNativeExpressADData2
?.
destroy
()
}
}
}
}
\ No newline at end of file
app/src/main/java/com/wenshu/youyou/manager/YlhAdManager.kt
View file @
ca56df1e
...
@@ -39,7 +39,7 @@ object YlhAdManager {
...
@@ -39,7 +39,7 @@ object YlhAdManager {
/*信息流*/
/*信息流*/
var
YLH_AD_NATIVEEXPRESS_JULEYUN
=
""
//聚乐云
var
YLH_AD_NATIVEEXPRESS_JULEYUN
=
""
//聚乐云
var
YLH_AD_NATIVEEXPRESS_AWARD
=
"
5061071124059461
"
//奖励弹窗
var
YLH_AD_NATIVEEXPRESS_AWARD
=
"
4021677125089838
"
//奖励弹窗
/* 插屏 */
/* 插屏 */
var
YLH_AD_INTERSTITIALAD_LIEBAO
=
""
//猎豹
var
YLH_AD_INTERSTITIALAD_LIEBAO
=
""
//猎豹
...
...
app/src/main/java/com/wenshu/youyou/net/GsonConverterFactory.java
View file @
ca56df1e
...
@@ -28,9 +28,8 @@ import retrofit2.Converter;
...
@@ -28,9 +28,8 @@ import retrofit2.Converter;
import
retrofit2.Retrofit
;
import
retrofit2.Retrofit
;
/**
/**
* Description:gson
2.2 gson全局解析问题
* Description:gson
全局解析
*/
*/
public
class
GsonConverterFactory
extends
Converter
.
Factory
{
public
class
GsonConverterFactory
extends
Converter
.
Factory
{
private
final
Gson
gson
;
private
final
Gson
gson
;
...
...
app/src/main/res/layout/dialog_power.xml
View file @
ca56df1e
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
android:layout_marginLeft=
"16dp"
android:layout_marginLeft=
"16dp"
android:layout_marginTop=
"16dp"
android:layout_marginTop=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginRight=
"16dp"
android:text=
"我们依据最新的法律,向您说明
好赚钱
软件的隐私政策,特向您推送本提示。请您阅读并充分理解相关条款。"
android:text=
"我们依据最新的法律,向您说明
尤友
软件的隐私政策,特向您推送本提示。请您阅读并充分理解相关条款。"
android:textColor=
"@color/black"
android:textColor=
"@color/black"
android:textSize=
"14sp"
/>
android:textSize=
"14sp"
/>
...
...
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