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
ae631a04
Commit
ae631a04
authored
Apr 09, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加穿山甲广告
parent
7af44bbb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
25 deletions
+51
-25
MintsApplication.java
...p/src/main/java/com/mints/goodmoney/MintsApplication.java
+1
-1
ReadYlhAd.java
.../src/main/java/com/mints/goodmoney/manager/ReadYlhAd.java
+10
-12
ReaderManager.kt
...rc/main/java/com/mints/goodmoney/manager/ReaderManager.kt
+33
-5
ReaderFragment.kt
...in/java/com/mints/goodmoney/ui/fragment/ReaderFragment.kt
+7
-7
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/MintsApplication.java
View file @
ae631a04
...
...
@@ -150,7 +150,7 @@ public class MintsApplication extends MultiDexApplication {
bindLogger
();
// 中文在线 听读
ReaderManager
.
init
(
this
);
ReaderManager
.
INSTANCE
.
init
(
this
);
// 子线程初始化三方SDK
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/ReadYlhAd.java
View file @
ae631a04
package
com
.
mints
.
goodmoney
.
manager
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.os.SystemClock
;
import
android.widget.Toast
;
import
com.bytedance.sdk.openadsdk.TTAppDownloadListener
;
import
com.bytedance.sdk.openadsdk.TTRewardVideoAd
;
import
com.chineseall.reader.lib.reader.callbacks.OnAdViewReceiver
;
import
com.chineseall.reader17ksdk.utils.LogUtils
;
import
com.mints.goodmoney.common.AppConfig
;
import
com.mints.goodmoney.common.Constant
;
import
com.mints.goodmoney.utils.LogUtil
;
...
...
@@ -16,19 +12,23 @@ import com.qq.e.ads.rewardvideo.RewardVideoAD;
import
com.qq.e.ads.rewardvideo.RewardVideoADListener
;
import
com.qq.e.comm.util.AdError
;
/**
* 中文在线 听读 优量汇广告
*/
public
class
ReadYlhAd
{
private
Context
context
;
private
RewardVideoAD
rewardVideoAD
;
private
boolean
isClickScreen
=
true
;
// 是否点击屏幕跳转广告
private
OnVideoCloseCallBack
callBack
;
public
void
loadVideoAd
(
Context
context
,
OnAdViewReceiver
receiver
,
OnVideoCloseCallBack
callBack
)
{
public
void
loadVideoAd
(
Context
context
,
OnAdViewReceiver
receiver
)
{
this
.
context
=
context
;
initVedioAD
(
context
,
receiver
,
callBack
);
initVedioAD
(
context
,
receiver
);
}
private
void
initVedioAD
(
final
Context
context
,
OnAdViewReceiver
receiver
,
OnVideoCloseCallBack
callBack
)
{
private
void
initVedioAD
(
final
Context
context
,
OnAdViewReceiver
receiver
)
{
rewardVideoAD
=
new
RewardVideoAD
(
context
,
YlhAdManager
.
INSTANCE
.
getYLH_AD_VEDIO_DRINK_POSTID
(),
new
RewardVideoADListener
()
{
@Override
public
void
onADLoad
()
{
//广告加载成功,可在此回调后进行广告展示,此时广告过期时间确定,可通过RewardVideoAD.getExpireTimestamp()获取
...
...
@@ -89,6 +89,7 @@ public class ReadYlhAd {
@Override
public
void
onError
(
AdError
adError
)
{
//广告流程出错,AdError中包含错误码和错误描述
receiver
.
onReceive
(
false
,
null
);
Toast
.
makeText
(
context
,
"视频播放错误"
,
Toast
.
LENGTH_SHORT
).
show
();
if
(
adError
!=
null
)
{
LogUtil
.
d
(
"YlhVideoAdManager"
,
"onError "
+
adError
.
getErrorCode
()
+
adError
.
getErrorMsg
());
...
...
@@ -102,7 +103,8 @@ public class ReadYlhAd {
rewardVideoAD
.
loadAD
();
}
public
void
showVideo
()
{
public
void
showVideo
(
Context
context
,
OnVideoCloseCallBack
callBack
)
{
this
.
callBack
=
callBack
;
try
{
if
(!
rewardVideoAD
.
hasShown
())
{
//广告展示检查2:当前广告数据还没有展示过
long
delta
=
1000
;
//建议给广告过期时间加个buffer,单位ms,这里demo采用1000ms的buffer
...
...
@@ -124,8 +126,4 @@ public class ReadYlhAd {
public
interface
OnVideoCloseCallBack
{
void
onClose
();
}
public
interface
OnClickListener
{
void
onClick
();
}
}
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/ReaderManager.kt
View file @
ae631a04
...
...
@@ -21,9 +21,16 @@ import com.chineseall.reader17ksdk.utils.book.ScreenUtils
* 邮箱:mengcga@163.com
*/
object
ReaderManager
{
@JvmStatic
private
val
csjAd
by
lazy
{
ReadToutiaoAD
()
}
private
val
ylhAd
by
lazy
{
ReadYlhAd
()
}
private
const
val
csjVedioAD
:
String
=
"CSJ"
private
const
val
ylhVedioAD
:
String
=
"Ylh"
private
var
curVedioAd
:
String
=
""
private
var
isCsjAd
:
Boolean
=
true
fun
init
(
applicationContext
:
Application
)
{
val
csjAd
=
ReadToutiaoAD
()
install
(
applicationContext
,
"1242"
,
"hzq@1242"
,
"32"
,
"0"
,
object
:
AdProvider
{
/**
* 阅读⻚弹窗广告确认按钮的点击回调-激励视频
...
...
@@ -35,10 +42,13 @@ object ReaderManager {
AlertDialog
.
Builder
(
ActivityStackManager
.
getInstance
().
topActivity
)
.
setTitle
(
"温馨提示"
)
.
setMessage
(
"当前处于移动网络,播放视频会消耗流量,确定播放?"
)
.
setPositiveButton
(
"观看视频"
)
{
dialog
,
which
->
csjAd
.
showVideo
(
ActivityStackManager
.
getInstance
().
topActivity
)
{
function0
.
invoke
()
}
}.
setNegativeButton
(
"取消"
)
{
dialog
,
which
->
dialog
.
dismiss
()
}.
create
().
show
()
.
setPositiveButton
(
"观看视频"
)
{
dialog
,
which
->
onAdDialogInvoke
(
function0
)
}.
setNegativeButton
(
"取消"
)
{
dialog
,
which
->
dialog
.
dismiss
()
}
.
create
().
show
()
return
}
else
{
csjAd
.
showVideo
(
ActivityStackManager
.
getInstance
().
topActivity
)
{
function0
.
invoke
()
}
onAdDialogInvoke
(
function0
)
}
}
...
...
@@ -61,8 +71,26 @@ object ReaderManager {
* 阅读⻚定时弹窗广告 (激励视频)
*/
override
fun
getReaderDialogAd
(
view
:
View
,
receiver
:
OnAdViewReceiver
,
dialog
:
Dialog
?)
{
if
(
isCsjAd
)
{
curVedioAd
=
csjVedioAD
csjAd
.
loadVideoAd
(
ActivityStackManager
.
getInstance
().
topActivity
,
receiver
)
}
else
{
curVedioAd
=
ylhVedioAD
ylhAd
.
loadVideoAd
(
ActivityStackManager
.
getInstance
().
topActivity
,
receiver
)
}
// isCsjAd = !isCsjAd
}
})
}
private
fun
onAdDialogInvoke
(
function0
:
()
->
Unit
)
{
when
(
curVedioAd
){
csjVedioAD
->{
csjAd
.
showVideo
(
ActivityStackManager
.
getInstance
().
topActivity
)
{
function0
.
invoke
()}
}
ylhVedioAD
->{
ylhAd
.
showVideo
(
ActivityStackManager
.
getInstance
().
topActivity
)
{
function0
.
invoke
()
}
}
}
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/ReaderFragment.kt
View file @
ae631a04
...
...
@@ -32,13 +32,13 @@ class ReaderFragment : LazyLoadBaseFragment(), BookView, OnReadCallBack {
override
fun
onFragmentFirstVisible
()
{
bookPresenter
.
attachView
(
this
)
//
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
//
transaction.add(R.id.fragment, wellChosenFragment, ReaderFragment::class.java.simpleName)
//
transaction.show(wellChosenFragment)
//
transaction.commitAllowingStateLoss()
//
//
//间隔30秒 回调一次 间隔任意设置
//
ChineseAllReaderApplication.setOnReadCallBack(this, 30 * 1000)
val
transaction
:
FragmentTransaction
=
supportFragmentManager
.
beginTransaction
()
transaction
.
add
(
R
.
id
.
fragment
,
wellChosenFragment
,
ReaderFragment
::
class
.
java
.
simpleName
)
transaction
.
show
(
wellChosenFragment
)
transaction
.
commitAllowingStateLoss
()
//间隔30秒 回调一次 间隔任意设置
ChineseAllReaderApplication
.
setOnReadCallBack
(
this
,
30
*
1000
)
}
override
fun
onFragmentResume
()
{
...
...
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