Commit 7094a647 authored by mengcuiguang's avatar mengcuiguang

添加听读广告

parent ae631a04
......@@ -671,6 +671,10 @@
# ===================== 听读 START ================
-keep class com.chineseall.reader17ksdk.**{*;}
-keep class com.chineseall.reader.utils.**{*;}
......
......@@ -23,105 +23,29 @@ import com.mints.library.utils.json.JsonUtil;
import java.util.List;
/**
* 中文在线 听读 穿山甲广告
*/
public class ReadToutiaoAD {
private static final String tag = "ToutiaoAD";
//开屏广告加载超时时间,建议大于200
private static final int AD_TIME_OUT = 3000;
private TTAdNative mTTAdNative;
private Context context;
private TTFeedAd feedAd; //信息流回调类
private TTRewardVideoAd mttRewardVideoAd;
private View mView;
public String getIcon() {
if (feedAd == null) {
return null;
}
TTImage ttImage = feedAd.getIcon();
if (ttImage != null && ttImage.getImageUrl() != null) {
return ttImage.getImageUrl();
}
return null;
}
public String getImage() {
if (feedAd == null) {
return null;
}
List<TTImage> list = feedAd.getImageList();
if (list != null && list.size() > 0) {
TTImage ttImage = list.get(0);
if (ttImage != null && ttImage.getImageUrl() != null) {
return ttImage.getImageUrl();
}
}
return null;
}
public String getTitle() {
if (feedAd == null) {
return null;
}
return feedAd.getTitle();
}
public String getDesc() {
if (feedAd == null) {
return null;
}
return feedAd.getDescription();
}
public String getUrl() {
return null;
}
public boolean isApp() {
return false;
}
public View getView() {
return mView;
}
public List<String> getImageList() {
return null;
}
// @Override
public void loadAD(final Context context, OnAdViewReceiver receiver, int width, int height, OnClickListener listener) {
this.context = context;
LogUtils.d(tag, "load ad");
if (mTTAdNative == null) {
mTTAdNative = TtCsjAdManager.get().createAdNative(context);
}
// if (ADConfig.TYPE_NATIVE.equals(adParamers.type)){
//信息流
// initNativeAD();
// }else if(ADConfig.TYPE_SPLASH.equals(adParamers.type)){
// 开屏
// initSplashAD();
// }else if(ADConfig.TYPE_INTERSTITIAL.equals(adParamers.type)){
//插屏广告
// initInteractionAD((Activity) context);
// }else if (ADConfig.TYPE_VIDEO.equals(adParamers.type)){
// initVedioAD(context);
// }else if (ADConfig.TYPE_FEED.equals(adParamers.type)){
initFeedAD(receiver, width, height, listener);
// }
initFeedAD(receiver, width, height, listener);
}
public void loadVideoAd(Context context, OnAdViewReceiver receiver) {
this.context = context;
if (mTTAdNative == null) {
mTTAdNative = TtCsjAdManager.get().createAdNative(context);
}
......@@ -129,8 +53,6 @@ public class ReadToutiaoAD {
}
private void initFeedAD(OnAdViewReceiver receiver, int width, int height, OnClickListener clickListener) {
// DensityUtil.px2dip(context, ScreenUtils.getScreenWidth(context) - DensityUtil.dip2px(context, 30)), DensityUtil.px2dip(context, 854)
//设置广告参数
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_NATIVEEXPRESS_AWARD) //广告位id
......@@ -144,8 +66,6 @@ public class ReadToutiaoAD {
public void onError(int code, String message) {
LogUtils.d(tag, "code: " + code + ", " + message);
receiver.onReceive(false, null);
// TToast.show(NativeExpressActivity.this, "load error : " + code + ", " + message);
// getAdParamers().parent.removeAllViews();
}
@Override
......@@ -249,7 +169,6 @@ public class ReadToutiaoAD {
}
private void initVedioAD(final Context context, OnAdViewReceiver receiver) {
// SharedPreferencesUtil.getInstance().putBoolean(StringConstants.VIDEO_TASK_FINISH, false);
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_VEDIO_READ)
.setSupportDeepLink(true)
......@@ -379,171 +298,4 @@ public class ReadToutiaoAD {
public interface OnClickListener {
void onClick();
}
// private void initInteractionAD(final Activity context) {
// //插屏广告请求类型数据
// AdSlot adSlot = new AdSlot.Builder()
// .setCodeId(adParamers.key)
// .setSupportDeepLink(true)
// .setImageAcceptedSize(600, 600)
// .build();
// //调用插屏广告异步请求接口
// mTTAdNative.loadInteractionAd(adSlot, new TTAdNative.InteractionAdListener() {
// @Override
// public void onError(int i, String s) {
//
// }
//
// @Override
// public void onInteractionAdLoad(TTInteractionAd ttInteractionAd) {
// ttInteractionAd.setAdInteractionListener(new TTInteractionAd.AdInteractionListener() {
// @Override
// public void onAdClicked() {
// adParamers.listener.onAdClick();
// }
//
// @Override
// public void onAdShow() {
// adParamers.listener.onADLoaded(com.rice.gluepudding.ad.impl.ToutiaoAD.this);
// }
//
// @Override
// public void onAdDismiss() {
//
// }
// });
// //弹出插屏广告
// ttInteractionAd.showInteractionAd(context);
// }
// });
// }
//
// private void initSplashAD() {
// //开屏广告参数
// AdSlot adSlot = new AdSlot.Builder()
// .setCodeId(adParamers.key)
// .setSupportDeepLink(true)
// .setImageAcceptedSize(ScreenUtils.getScreenWidth(), ScreenUtils.getScreenHeight())
// .build();
// mTTAdNative.loadSplashAd(adSlot, new TTAdNative.SplashAdListener() {
// @Override
// public void onError(int code, String message) {
// //开屏广告请求失败
// adParamers.listener.onAdFailed(message);
// }
//
// @Override
// public void onTimeout() {
// //开屏广告请求超时
// adParamers.listener.onAdFailed("请求超时了");
// }
//
// @Override
// public void onSplashAdLoad(TTSplashAd ttSplashAd) {
//
// //开屏广告请求成功了
// if(ttSplashAd == null){
// return;
// }
//
// adParamers.listener.onADLoaded(com.rice.gluepudding.ad.impl.ToutiaoAD.this);
//
// //获取SplashView
// View view = ttSplashAd.getSplashView();
// adParamers.parent.removeAllViews();
// //把SplashView 添加到ViewGroup中
// adParamers.parent.addView(view);
//
// //设置不显示SDK自带的跳过和倒计时
// ttSplashAd.setNotAllowSdkCountdown();
//
// ttSplashAd.setSplashInteractionListener(new TTSplashAd.AdInteractionListener() {
// @Override
// public void onAdClicked(View view, int i) {
// //广告点击了
// adParamers.listener.onAdClick();
// }
//
// @Override
// public void onAdShow(View view, int i) {
// //广告显示了
//// adParamers.listener.onADLoaded(ToutiaoAD.this);
// }
//
// @Override
// public void onAdSkip() {
// //广告跳过
// adParamers.listener.onAdDismiss();
// }
//
// @Override
// public void onAdTimeOver() {
// //开屏广告倒计时结束
// adParamers.listener.onAdDismiss();
// }
// });
// }
// },AD_TIME_OUT);
// }
// private void initNativeAD() {
// //feed广告请求类型参数
// AdSlot adSlot = new AdSlot.Builder()
// .setCodeId(adParamers.key)
// .setSupportDeepLink(true)
// .setImageAcceptedSize(640, 320)
// .setAdCount(1)
// .build();
// mTTAdNative.loadFeedAd(adSlot, new TTAdNative.FeedAdListener() {
// @Override
// public void onError(int code, String message) {
// adParamers.listener.onAdFailed(message);
// }
//
// @Override
// public void onFeedAdLoad(List<TTFeedAd> ads) {
// if(ads != null && ads.size() > 0){
// feedAd = ads.get(0);
// adParamers.listener.onADLoaded(com.rice.gluepudding.ad.impl.ToutiaoAD.this);
// }else{
// adParamers.listener.onAdFailed("没有广告");
// }
// }
// });
// }
// @Override
public boolean onExposured(View view) {
// if (ADConfig.TYPE_NATIVE.equals(adParamers.type)){
//
// if(feedAd != null){
// feedAd.registerViewForInteraction(adParamers.parent, adParamers.clickViewList, null, new TTNativeAd.AdInteractionListener() {
// @Override
// public void onAdClicked(View view, TTNativeAd ttNativeAd) {
//// adParamers.listener.onAdClick();
// }
//
// @Override
// public void onAdCreativeClick(View view, TTNativeAd ttNativeAd) {
//
// }
//
// @Override
// public void onAdShow(TTNativeAd ttNativeAd) {
// if(ttNativeAd != null){
// //广告显示了
//// adParamers.listener.onAdShow(com.rice.gluepudding.ad.impl.ToutiaoAD.this);
// }
// }
// });
//
// }
// }
return false;
}
// @Override
public boolean onClicked(View view) {
return false;
}
}
......@@ -21,6 +21,11 @@ import com.chineseall.reader17ksdk.utils.book.ScreenUtils
* 邮箱:mengcga@163.com
*/
object ReaderManager {
private const val APP_ID = "1242"
private const val SECRET = "hzq"
private const val APP = "32"
private const val SUBAPP = "0"
private val csjAd by lazy { ReadToutiaoAD() }
private val ylhAd by lazy { ReadYlhAd() }
......@@ -31,7 +36,7 @@ object ReaderManager {
private var isCsjAd: Boolean = true
fun init(applicationContext: Application) {
install(applicationContext, "1242", "hzq@1242", "32", "0", object : AdProvider {
install(applicationContext, APP_ID, SECRET, APP, SUBAPP, object : AdProvider {
/**
* 阅读⻚弹窗广告确认按钮的点击回调-激励视频
* @param dialog
......@@ -78,17 +83,17 @@ object ReaderManager {
curVedioAd = ylhVedioAD
ylhAd.loadVideoAd(ActivityStackManager.getInstance().topActivity, receiver)
}
// isCsjAd = !isCsjAd
isCsjAd = !isCsjAd
}
})
}
private fun onAdDialogInvoke(function0: () -> Unit) {
when(curVedioAd){
csjVedioAD ->{
csjAd.showVideo(ActivityStackManager.getInstance().topActivity) {function0.invoke()}
when (curVedioAd) {
csjVedioAD -> {
csjAd.showVideo(ActivityStackManager.getInstance().topActivity) { function0.invoke() }
}
ylhVedioAD ->{
ylhVedioAD -> {
ylhAd.showVideo(ActivityStackManager.getInstance().topActivity) { function0.invoke() }
}
}
......
......@@ -19,6 +19,7 @@ import kotlinx.android.synthetic.main.header_layout.*
* 作者:孟崔广
* 时间:2020/12/10 12:39
*/
@AndroidEntryPoint
class WrapperActivity : BaseActivity(), View.OnClickListener {
private var wrapperType = Constant.WRAPPER_TYPE_NEWS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment