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
94b1fd50
Commit
94b1fd50
authored
Dec 28, 2020
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加信息流广告互换逻辑
parent
aada2af8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
159 additions
and
137 deletions
+159
-137
PreLoadExpressManager.kt
...a/com/mints/goodmoney/ad/express/PreLoadExpressManager.kt
+49
-0
TTPreLoadExpressManager.java
...m/mints/goodmoney/ad/express/TTPreLoadExpressManager.java
+5
-7
YlhPreLoadExpressManager.java
.../mints/goodmoney/ad/express/YlhPreLoadExpressManager.java
+0
-127
YlhPreLoadExpressManager.kt
...om/mints/goodmoney/ad/express/YlhPreLoadExpressManager.kt
+96
-0
AwardActivity.kt
...in/java/com/mints/goodmoney/ui/activitys/AwardActivity.kt
+6
-2
MainFragment.kt
...main/java/com/mints/goodmoney/ui/fragment/MainFragment.kt
+3
-1
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/express/PreLoadExpressManager.kt
0 → 100644
View file @
94b1fd50
package
com.mints.goodmoney.ad.express
import
android.widget.FrameLayout
object
PreLoadExpressManager
{
// 是否是穿山甲信息流
@Volatile
private
var
isTTExpressAd
=
false
@Volatile
private
var
mAdFrameLayout
:
FrameLayout
?
=
null
// init {
// YlhPreLoadExpressManager.setListener(this)
// }
fun
loadADFrameLayout
()
{
if
(
isTTExpressAd
)
{
TTPreLoadExpressManager
.
getInstance
().
loadTtFrameLayout
()
}
else
{
YlhPreLoadExpressManager
.
loadYlhFrameLayout
()
}
}
fun
getADFrameLayout
():
FrameLayout
?
{
mAdFrameLayout
=
if
(
isTTExpressAd
)
{
TTPreLoadExpressManager
.
getInstance
().
ttFrameLayout
}
else
{
YlhPreLoadExpressManager
.
getYlhFrameLayout
()
}
isTTExpressAd
=
!
isTTExpressAd
return
mAdFrameLayout
}
// override fun onTTAdLoadSuc(adFrameLayout: FrameLayout?) {
// mAdFrameLayout = adFrameLayout
// }
//
// override fun onYlhAdLoadSuc(adFrameLayout: FrameLayout?) {
// mAdFrameLayout = adFrameLayout
// }
}
interface
ADLoadSuccessListener
{
fun
onTTAdLoadSuc
(
adFrameLayout
:
FrameLayout
?)
fun
onYlhAdLoadSuc
(
adFrameLayout
:
FrameLayout
?)
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/express/TTPreLoadExpressManager.java
View file @
94b1fd50
...
...
@@ -21,18 +21,16 @@ public class TTPreLoadExpressManager {
return
_inst
;
}
private
TTPreLoadExpressManager
()
{
// init();
}
private
void
init
()
{
ttNativeExpressManager
=
new
TTNativeExpressManager
();
ttNativeExpressManager
.
initTTAd
(
false
);
}
public
void
onDestroy
(){
ttNativeExpressManager
.
onTTAdDestroy
();
ttNativeExpressManager
=
null
;
public
void
onDestroy
()
{
if
(
ttNativeExpressManager
!=
null
)
{
ttNativeExpressManager
.
onTTAdDestroy
();
ttNativeExpressManager
=
null
;
}
}
public
FrameLayout
getTtFrameLayout
()
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/express/YlhPreLoadExpressManager.java
deleted
100644 → 0
View file @
aada2af8
package
com
.
mints
.
goodmoney
.
ad
.
express
;
import
android.content.Context
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.Toast
;
import
com.mints.goodmoney.MintsApplication
;
import
com.mints.goodmoney.common.AppConfig
;
import
com.mints.goodmoney.manager.TTNativeExpressManager
;
import
com.mints.goodmoney.manager.TtCsjAdManager
;
import
com.mints.goodmoney.manager.YlhAdManager
;
import
com.mints.goodmoney.utils.LogUtil
;
import
com.qq.e.ads.cfg.VideoOption
;
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.constants.AdPatternType
;
import
com.qq.e.comm.util.AdError
;
import
java.util.List
;
/**
* 优量汇信息流
*/
public
class
YlhPreLoadExpressManager
implements
NativeExpressAD
.
NativeExpressADListener
{
private
static
YlhPreLoadExpressManager
_inst
;
private
NativeExpressAD
nativeExpressAD
;
private
NativeExpressADView
nativeExpressADView
;
public
static
YlhPreLoadExpressManager
getInstance
()
{
if
(
_inst
==
null
)
{
_inst
=
new
YlhPreLoadExpressManager
();
}
return
_inst
;
}
private
YlhPreLoadExpressManager
()
{
init
();
}
private
void
init
()
{
}
public
void
onDestroy
()
{
// 使用完了每一个NativeExpressADView之后都要释放掉资源
if
(
nativeExpressADView
!=
null
)
{
nativeExpressADView
.
destroy
();
}
}
private
void
refreshAd
()
{
try
{
nativeExpressAD
=
new
NativeExpressAD
(
MintsApplication
.
getContext
(),
getMyADSize
(),
YlhAdManager
.
INSTANCE
.
YLH_AD_APPID
,
YlhAdManager
.
INSTANCE
.
getYLH_AD_NATIVEEXPRESS_AWARD
(),
this
);
// 这里的Context必须为Activity
nativeExpressAD
.
loadAD
(
1
);
}
catch
(
NumberFormatException
e
)
{
LogUtil
.
d
(
"YlhPreLoadExpressManager"
,
"ad size invalid."
);
}
}
private
ADSize
getMyADSize
()
{
int
w
=
ADSize
.
FULL_WIDTH
;
int
h
=
ADSize
.
AUTO_HEIGHT
;
return
new
ADSize
(
w
,
h
);
}
@Override
public
void
onADClicked
(
NativeExpressADView
nativeExpressADView
)
{
}
@Override
public
void
onADCloseOverlay
(
NativeExpressADView
nativeExpressADView
)
{
}
@Override
public
void
onADClosed
(
NativeExpressADView
nativeExpressADView
)
{
}
@Override
public
void
onADExposure
(
NativeExpressADView
nativeExpressADView
)
{
}
@Override
public
void
onADLeftApplication
(
NativeExpressADView
nativeExpressADView
)
{
}
@Override
public
void
onADLoaded
(
List
<
NativeExpressADView
>
adList
)
{
// 释放前一个展示的NativeExpressADView的资源
if
(
nativeExpressADView
!=
null
)
{
nativeExpressADView
.
destroy
();
}
nativeExpressADView
=
adList
.
get
(
0
);
// 广告可见才会产生曝光,否则将无法产生收益。
// container.addView(nativeExpressADView);
nativeExpressADView
.
render
();
}
@Override
public
void
onADOpenOverlay
(
NativeExpressADView
nativeExpressADView
)
{
}
@Override
public
void
onRenderFail
(
NativeExpressADView
nativeExpressADView
)
{
}
@Override
public
void
onRenderSuccess
(
NativeExpressADView
nativeExpressADView
)
{
}
@Override
public
void
onNoAD
(
AdError
adError
)
{
}
}
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/express/YlhPreLoadExpressManager.kt
0 → 100644
View file @
94b1fd50
package
com.mints.goodmoney.ad.express
import
android.widget.FrameLayout
import
com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.manager.YlhAdManager
import
com.mints.goodmoney.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
{
private
var
ylhFrameLayout
:
FrameLayout
?
=
null
private
var
nativeExpressAD
:
NativeExpressAD
?
=
null
private
var
nativeExpressADView
:
NativeExpressADView
?
=
null
// private var mADLoadSuccessListener: ADLoadSuccessListener? = null
//
// fun setListener(adLoadSuccessListener: ADLoadSuccessListener) {
// mADLoadSuccessListener = adLoadSuccessListener
// }
fun
getYlhFrameLayout
():
FrameLayout
?
{
return
ylhFrameLayout
}
fun
loadYlhFrameLayout
()
{
val
context
=
MintsApplication
.
getContext
()
try
{
ylhFrameLayout
=
FrameLayout
(
context
)
nativeExpressAD
=
NativeExpressAD
(
MintsApplication
.
getContext
(),
ADSize
(
320
,
ADSize
.
AUTO_HEIGHT
),
YlhAdManager
.
YLH_AD_NATIVEEXPRESS_AWARD
,
object
:
NativeExpressAD
.
NativeExpressADListener
{
override
fun
onNoAD
(
p0
:
AdError
?)
{
}
override
fun
onADClicked
(
p0
:
NativeExpressADView
?)
{
}
override
fun
onADCloseOverlay
(
p0
:
NativeExpressADView
?)
{
}
override
fun
onADClosed
(
p0
:
NativeExpressADView
?)
{
}
override
fun
onADExposure
(
p0
:
NativeExpressADView
?)
{
}
override
fun
onADLeftApplication
(
p0
:
NativeExpressADView
?)
{
}
override
fun
onADLoaded
(
p0
:
MutableList
<
NativeExpressADView
>?)
{
// 释放前一个展示的NativeExpressADView的资源
nativeExpressADView
?.
destroy
()
nativeExpressADView
=
p0
?.
get
(
0
)
if
(
ylhFrameLayout
!!
.
childCount
>
0
)
{
ylhFrameLayout
!!
.
removeAllViews
()
}
// val frameLayout = FrameLayout(context)
// mADLoadSuccessListener?.onYlhAdLoadSuc(frameLayout)
// 广告可见才会产生曝光,否则将无法产生收益。
ylhFrameLayout
!!
.
addView
(
nativeExpressADView
)
nativeExpressADView
!!
.
render
()
}
override
fun
onADOpenOverlay
(
p0
:
NativeExpressADView
?)
{
}
override
fun
onRenderFail
(
p0
:
NativeExpressADView
?)
{
}
override
fun
onRenderSuccess
(
p0
:
NativeExpressADView
?)
{
}
})
nativeExpressAD
?.
loadAD
(
1
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
/**
* 在页面销毁时调用 destroy
*/
fun
onDestroy
()
{
// 使用完了每一个NativeExpressADView之后都要释放掉资源
nativeExpressADView
?.
destroy
()
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/AwardActivity.kt
View file @
94b1fd50
...
...
@@ -5,11 +5,13 @@ import android.text.TextUtils
import
android.view.KeyEvent
import
android.view.View
import
com.mints.goodmoney.R
import
com.mints.goodmoney.ad.express.PreLoadExpressManager
import
com.mints.goodmoney.ad.video.VedioAdingManager
import
com.mints.goodmoney.common.AppConfig
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.common.DeviceInfo.Companion.instance
import
com.mints.goodmoney.ad.express.TTPreLoadExpressManager
import
com.mints.goodmoney.ad.express.YlhPreLoadExpressManager
import
com.mints.goodmoney.manager.UserManager
import
com.mints.goodmoney.mvp.model.VedioAdingBean
import
com.mints.goodmoney.mvp.presenters.AwardPresenter
...
...
@@ -326,7 +328,8 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
mTimer
=
null
try
{
TTPreLoadExpressManager
.
getInstance
().
loadTtFrameLayout
()
// TTPreLoadExpressManager.getInstance().loadTtFrameLayout()
PreLoadExpressManager
.
loadADFrameLayout
()
}
catch
(
e
:
java
.
lang
.
Exception
)
{
e
.
printStackTrace
()
}
...
...
@@ -334,6 +337,7 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
SoundPoolUtil
.
getInstance
().
onDestory
()
TTPreLoadExpressManager
.
getInstance
().
onDestroy
()
YlhPreLoadExpressManager
.
onDestroy
()
flAwardAd
?.
removeAllViews
()
vedioAdingManager
.
setVedioAdingListener
(
null
)
vedioAdingManager
.
onDestory
()
...
...
@@ -504,7 +508,7 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
try
{
if
(
flAwardAd
!=
null
)
{
flAwardAd
.
removeAllViews
()
flAwardAd
.
addView
(
TTPreLoadExpressManager
.
getInstance
().
ttFrameLayout
)
flAwardAd
.
addView
(
PreLoadExpressManager
.
getADFrameLayout
()
)
}
}
catch
(
e
:
Exception
)
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MainFragment.kt
View file @
94b1fd50
...
...
@@ -14,6 +14,7 @@ import com.daimajia.androidanimations.library.YoYo
import
com.daimajia.androidanimations.library.YoYo.YoYoString
import
com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.R
import
com.mints.goodmoney.ad.express.PreLoadExpressManager
import
com.mints.goodmoney.ad.express.TTPreLoadExpressManager
import
com.mints.goodmoney.ad.express.TTPreLoadExpressXmlyManager
import
com.mints.goodmoney.ad.video.VedioAdingManager
...
...
@@ -90,7 +91,8 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
vedioAdingManager
=
VedioAdingManager
.
getInstance
(
activity
)
// 奖励页预加载 信息流广告
TTPreLoadExpressManager
.
getInstance
().
loadTtFrameLayout
()
// TTPreLoadExpressManager.getInstance().loadTtFrameLayout()
PreLoadExpressManager
.
loadADFrameLayout
()
// 刷新喜马拉雅信息流
TTPreLoadExpressXmlyManager
.
getInstance
().
loadTtFrameLayout
()
...
...
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