Commit 37863e7a authored by mengcuiguang2's avatar mengcuiguang2

1.3.7版本提交,升级最新的广告sdk,删除猎豹游戏,中文在线

parent 33ca2cd5
...@@ -2,9 +2,9 @@ apply plugin: 'com.android.application' ...@@ -2,9 +2,9 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin' //apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'androidx.navigation.safeargs.kotlin' //apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: 'android-aspectjx' //apply plugin: 'android-aspectjx'
android { android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion compileSdkVersion rootProject.ext.androidCompileSdkVersion
...@@ -68,9 +68,9 @@ android { ...@@ -68,9 +68,9 @@ android {
arg("AROUTER_MODULE_NAME", project.getName()) arg("AROUTER_MODULE_NAME", project.getName())
} }
} }
aspectjx { // aspectjx {
exclude 'versions.9' // exclude 'versions.9'
} // }
buildFeatures { buildFeatures {
dataBinding true dataBinding true
...@@ -283,50 +283,50 @@ dependencies { ...@@ -283,50 +283,50 @@ dependencies {
// 激励视频RTA // 激励视频RTA
implementation(name: 'taskwake1.0', ext: 'aar') implementation(name: 'taskwake1.0', ext: 'aar')
// 听读 // 听读
implementation files('libs/Reader17kSDK-release1.1.3.aar') // implementation files('libs/Reader17kSDK-release1.1.3.aar')
implementation files('libs/readerlib-release1.1.aar') // implementation files('libs/readerlib-release1.1.aar')
implementation files('libs/filter-lib-release1.1.aar') // implementation files('libs/filter-lib-release1.1.aar')
compileOnly "com.squareup.inject:assisted-inject-annotations-dagger2:$rootProject.assistedInjectVersion" // compileOnly "com.squareup.inject:assisted-inject-annotations-dagger2:$rootProject.assistedInjectVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion" // kapt "androidx.room:room-compiler:$rootProject.roomVersion"
kapt "com.google.dagger:hilt-android-compiler:$rootProject.hiltVersion" // kapt "com.google.dagger:hilt-android-compiler:$rootProject.hiltVersion"
kapt "androidx.hilt:hilt-compiler:$rootProject.hiltViewModelVersion" // kapt "androidx.hilt:hilt-compiler:$rootProject.hiltViewModelVersion"
kapt "com.squareup.inject:assisted-inject-processor-dagger2:$rootProject.assistedInjectVersion" // kapt "com.squareup.inject:assisted-inject-processor-dagger2:$rootProject.assistedInjectVersion"
implementation "androidx.core:core-ktx:$rootProject.ktxVersion" // implementation "androidx.core:core-ktx:$rootProject.ktxVersion"
implementation "androidx.fragment:fragment-ktx:$rootProject.fragmentVersion" // implementation "androidx.fragment:fragment-ktx:$rootProject.fragmentVersion"
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.lifecycleVersion" // implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion" // implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleVersion" // implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleVersion"
implementation "androidx.navigation:navigation-fragment-ktx:$rootProject.navigationVersion" // implementation "androidx.navigation:navigation-fragment-ktx:$rootProject.navigationVersion"
implementation "androidx.navigation:navigation-ui-ktx:$rootProject.navigationVersion" // implementation "androidx.navigation:navigation-ui-ktx:$rootProject.navigationVersion"
implementation "androidx.paging:paging-runtime:$rootProject.pagingVersion" // implementation "androidx.paging:paging-runtime:$rootProject.pagingVersion"
implementation "androidx.room:room-runtime:$rootProject.roomVersion" // implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "androidx.room:room-ktx:$rootProject.roomVersion" // implementation "androidx.room:room-ktx:$rootProject.roomVersion"
implementation "androidx.viewpager2:viewpager2:$rootProject.viewPagerVersion" // implementation "androidx.viewpager2:viewpager2:$rootProject.viewPagerVersion"
implementation "androidx.work:work-runtime-ktx:$rootProject.workVersion" // implementation "androidx.work:work-runtime-ktx:$rootProject.workVersion"
implementation "com.google.code.gson:gson:$rootProject.gsonVersion" // implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutinesVersion" // implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutinesVersion" // implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutinesVersion"
implementation "com.google.dagger:hilt-android:$rootProject.hiltVersion" // implementation "com.google.dagger:hilt-android:$rootProject.hiltVersion"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$rootProject.hiltViewModelVersion" // implementation "androidx.hilt:hilt-lifecycle-viewmodel:$rootProject.hiltViewModelVersion"
implementation "com.scwang.smart:refresh-header-material:$rootProject.refresh_version" // implementation "com.scwang.smart:refresh-header-material:$rootProject.refresh_version"
implementation 'com.github.pdog18:dimension-extensions:1.0' // implementation 'com.github.pdog18:dimension-extensions:1.0'
implementation 'com.github.zhpanvip:BannerViewPager:3.2.0' // implementation 'com.github.zhpanvip:BannerViewPager:3.2.0'
api "androidx.navigation:navigation-fragment-ktx:$navigationVersion" // api "androidx.navigation:navigation-fragment-ktx:$navigationVersion"
api "androidx.navigation:navigation-ui-ktx:$navigationVersion" // api "androidx.navigation:navigation-ui-ktx:$navigationVersion"
api "androidx.navigation:navigation-dynamic-features-fragment:$navigationVersion" // api "androidx.navigation:navigation-dynamic-features-fragment:$navigationVersion"
implementation 'com.github.warkiz.widget:indicatorseekbar:1.2.9' // implementation 'com.github.warkiz.widget:indicatorseekbar:1.2.9'
implementation 'org.greenrobot:eventbus:3.2.0' // implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'skin.support:skin-support:4.0.5' // implementation 'skin.support:skin-support:4.0.5'
implementation 'skin.support:skin-support-appcompat:4.0.5' // implementation 'skin.support:skin-support-appcompat:4.0.5'
implementation 'skin.support:skin-support-design:4.0.5' // implementation 'skin.support:skin-support-design:4.0.5'
implementation 'skin.support:skin-support-cardview:4.0.5' // implementation 'skin.support:skin-support-cardview:4.0.5'
implementation 'skin.support:skin-support-constraint-layout:4.0.5' // implementation 'skin.support:skin-support-constraint-layout:4.0.5'
implementation "androidx.datastore:datastore-preferences:1.0.0-alpha02" // implementation "androidx.datastore:datastore-preferences:1.0.0-alpha02"
implementation 'com.github.F1ReKing:StatusLayout:1.2.1' // implementation 'com.github.F1ReKing:StatusLayout:1.2.1'
kapt "com.alibaba:arouter-compiler:$arouter_compiler_version" // kapt "com.alibaba:arouter-compiler:$arouter_compiler_version"
implementation "com.alibaba:arouter-api:$arouter_api_version" // implementation "com.alibaba:arouter-api:$arouter_api_version"
implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:4.4.3' // implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:4.4.3'
api 'org.aspectj:aspectjrt:1.9.5' // api 'org.aspectj:aspectjrt:1.9.5'
//小满 //小满
implementation(name: 'adsdk-1.4.3', ext: 'aar') { implementation(name: 'adsdk-1.4.3', ext: 'aar') {
exclude group: "com.miit.sdk" exclude group: "com.miit.sdk"
...@@ -347,8 +347,9 @@ dependencies { ...@@ -347,8 +347,9 @@ dependencies {
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' // androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// 穿山甲广告 4.0.11 // 穿山甲广告 4.0.11
// implementation(name: 'open_ad_sdk_4.0.1.9', ext: 'aar') // implementation 'com.pangle.cn:ads-sdk-pro:4.0.1.9'
implementation 'com.pangle.cn:ads-sdk-pro:4.0.1.9' // implementation 'com.pangle.cn:ads-sdk-pro:3.9.0.5'
implementation 'com.pangle.cn:ads-sdk-pro:4.0.0.6'
implementation(name: 'tools_release', ext: 'aar') implementation(name: 'tools_release', ext: 'aar')
// 广点通广告 腾讯 // 广点通广告 腾讯
implementation(name: 'GDTSDK.unionNormal.4.420.1290', ext: 'aar') implementation(name: 'GDTSDK.unionNormal.4.420.1290', ext: 'aar')
......
...@@ -42,7 +42,6 @@ import com.ximalaya.ting.android.opensdk.util.BaseUtil; ...@@ -42,7 +42,6 @@ import com.ximalaya.ting.android.opensdk.util.BaseUtil;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import dagger.hilt.android.HiltAndroidApp;
import rx.Scheduler; import rx.Scheduler;
import rx.schedulers.Schedulers; import rx.schedulers.Schedulers;
...@@ -51,7 +50,7 @@ import rx.schedulers.Schedulers; ...@@ -51,7 +50,7 @@ import rx.schedulers.Schedulers;
* 作者:孟崔广 * 作者:孟崔广
* 时间:2020/10/09 11:40 * 时间:2020/10/09 11:40
*/ */
@HiltAndroidApp //@HiltAndroidApp
public class MintsApplication extends MultiDexApplication { public class MintsApplication extends MultiDexApplication {
private static MintsApplication mContext; private static MintsApplication mContext;
......
package com.mints.goodmoney.manager;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.Toast;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.TTAppDownloadListener;
import com.bytedance.sdk.openadsdk.TTFeedAd;
import com.bytedance.sdk.openadsdk.TTImage;
import com.bytedance.sdk.openadsdk.TTNativeExpressAd;
import com.bytedance.sdk.openadsdk.TTRewardVideoAd;
import com.chineseall.reader.lib.reader.callbacks.OnAdViewReceiver;
import com.chineseall.reader17ksdk.ChineseAllReaderApplication;
import com.chineseall.reader17ksdk.aop.AspectTest;
import com.chineseall.reader17ksdk.utils.LogUtils;
import com.chineseall.reader17ksdk.utils.book.ScreenUtils;
import com.mints.goodmoney.utils.ToastUtil;
import com.mints.library.utils.json.JsonUtil;
import java.util.List;
/**
* 中文在线 听读 穿山甲广告
*/
public class ReadToutiaoAD {
private static final String tag = "ToutiaoAD";
private TTAdNative mTTAdNative;
private TTRewardVideoAd mttRewardVideoAd;
private View mView;
public void loadAD(final Context context, OnAdViewReceiver receiver, int width, int height, OnClickListener listener) {
LogUtils.d(tag, "load ad");
if (mTTAdNative == null) {
mTTAdNative = TtCsjAdManager.get().createAdNative(context);
}
initFeedAD(receiver, width, height, listener);
}
public void loadVideoAd(Context context, OnAdViewReceiver receiver) {
if (mTTAdNative == null) {
mTTAdNative = TtCsjAdManager.get().createAdNative(context);
}
initVedioAD(context, receiver);
}
private void initFeedAD(OnAdViewReceiver receiver, int width, int height, OnClickListener clickListener) {
//设置广告参数
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_NATIVEEXPRESS_READ) //广告位id
.setSupportDeepLink(true)
.setAdCount(1) //请求广告数量为1到3条
.setExpressViewAcceptedSize(width, height) //必填:期望个性化模板广告view的size,单位dp
.setImageAcceptedSize(400, 150) //这个参数设置即可,不影响个性化模板广告的size
.build();
mTTAdNative.loadNativeExpressAd(adSlot, new TTAdNative.NativeExpressAdListener() {
@Override
public void onError(int code, String message) {
LogUtils.d(tag, "code: " + code + ", " + message);
receiver.onReceive(false, null);
}
@Override
public void onNativeExpressAdLoad(List<TTNativeExpressAd> ads) {
if (ads == null || ads.size() == 0) {
return;
}
LogUtils.d(tag, "onNativeExpressAdLoad : " + ads.size());
TTNativeExpressAd mTTAd = ads.get(0);
bindAdListener(mTTAd, receiver, clickListener);
mTTAd.render();//调用render开始渲染广告
}
});
}
//绑定广告行为
private void bindAdListener(TTNativeExpressAd ad, OnAdViewReceiver receiver, OnClickListener clickListener) {
ad.setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() {
@Override
public void onAdClicked(View view, int type) {
LogUtils.d(tag, "onAdClicked : " + type);
LogUtils.d("onAdClicked");
if (clickListener != null) {
clickListener.onClick();
}
}
@Override
public void onAdShow(View view, int type) {
LogUtils.d(tag, "onAdShow : " + type);
LogUtils.d("onAdShow");
}
@Override
public void onRenderFail(View view, String msg, int code) {
LogUtils.d(tag, "onRenderFail : " + msg + ", " + code);
receiver.onReceive(false, view);
}
@Override
public void onRenderSuccess(View view, float width, float height) {
LogUtils.d(tag, "onRenderSuccess : " + view.getClass().getName());
//返回view的宽高 单位 dp
//在渲染成功回调时展示广告,提升体验
// getAdParamers().parent.removeAllViews();
// getAdParamers().parent.addView(view);
mView = view;
if (mView != null && !AspectTest.views.contains(view.getClass().getName())) {
AspectTest.views.add(view.getClass().getName());
}
receiver.onReceive(true, view);
// adParamers.listener.onADLoaded(com.rice.gluepudding.ad.impl.ToutiaoAD.this);
}
});
//dislike设置
// bindDislike(ad, false);
if (ad.getInteractionType() != TTAdConstant.INTERACTION_TYPE_DOWNLOAD) {
return;
}
//可选,下载监听设置
ad.setDownloadListener(new TTAppDownloadListener() {
@Override
public void onIdle() {
LogUtils.d(tag, "onIdle : ");
// TToast.show(NativeExpressActivity.this, "点击开始下载", Toast.LENGTH_LONG);
}
@Override
public void onDownloadActive(long totalBytes, long currBytes, String fileName, String appName) {
LogUtils.d(tag, "onDownloadActive : ");
// if (!mHasShowDownloadActive) {
// mHasShowDownloadActive = true;
// TToast.show(NativeExpressActivity.this, "下载中,点击暂停", Toast.LENGTH_LONG);
// }
}
@Override
public void onDownloadPaused(long totalBytes, long currBytes, String fileName, String appName) {
LogUtils.d(tag, "onDownloadPaused : ");
// TToast.show(NativeExpressActivity.this, "下载暂停,点击继续", Toast.LENGTH_LONG);
}
@Override
public void onDownloadFailed(long totalBytes, long currBytes, String fileName, String appName) {
LogUtils.d(tag, "onDownloadFailed : ");
// TToast.show(NativeExpressActivity.this, "下载失败,点击重新下载", Toast.LENGTH_LONG);
}
@Override
public void onInstalled(String fileName, String appName) {
LogUtils.d(tag, "onInstalled : ");
// TToast.show(NativeExpressActivity.this, "安装完成,点击图片打开", Toast.LENGTH_LONG);
}
@Override
public void onDownloadFinished(long totalBytes, String fileName, String appName) {
LogUtils.d(tag, "onDownloadFinished : ");
// TToast.show(NativeExpressActivity.this, "点击安装", Toast.LENGTH_LONG);
}
});
}
private void initVedioAD(final Context context, OnAdViewReceiver receiver) {
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_VEDIO_READ)
.setSupportDeepLink(true)
//个性化模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可。仅模板广告需要设置此参数
.setExpressViewAcceptedSize(500, 500)
.setImageAcceptedSize(1080, 1920)
.setUserID(UserManager.getInstance().getUserID())//用户id,必传参数
.setMediaExtra("media_extra")
.setOrientation(TTAdConstant.VERTICAL)
.build();
mTTAdNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
@Override
public void onError(int code, String message) {
LogUtils.i("ToutiaoAd", message);
// adParamers.listener.onAdFailed("error");
receiver.onReceive(false, null);
ToastUtil.show(context,"视频加载失败,请退出重试");
}
//视频广告加载后的视频文件资源缓存到本地的回调
@Override
public void onRewardVideoCached() {
LogUtils.i("ToutiaoAd", "rewardVideoAd video cached");
}
@Override
public void onRewardVideoCached(TTRewardVideoAd ttRewardVideoAd) {
}
//视频广告素材加载到,如title,视频url等,不包括视频文件
@Override
public void onRewardVideoAdLoad(TTRewardVideoAd ad) {
// Log.i("ToutiaoAd","rewardVideoAd loaded");
mttRewardVideoAd = ad;
receiver.onReceive(true, null);
//mttRewardVideoAd.setShowDownLoadBar(false);
}
});
}
public void showVideo(Context context, OnVideoCloseCallBack callBack) {
if (mttRewardVideoAd != null) {
mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() {
@Override
public void onAdShow() {
LogUtils.i("ToutiaoAd", "rewardVideoAd onAdShow");
// adParamers.listener.onADLoaded(com.rice.gluepudding.ad.impl.ToutiaoAD.this);
}
@Override
public void onAdVideoBarClick() {
LogUtils.i("ToutiaoAd", "rewardVideoAd onAdVideoBarClick");
// adParamers.listener.onAdClick();
}
@Override
public void onAdClose() {
LogUtils.i("ToutiaoAd", "rewardVideoAd onAdClose");
if (callBack != null) {
callBack.onClose();
}
// adParamers.listener.onAdDismiss();
// EventBus.getDefault().post(new ADCloseEvent(SharedPreferencesUtil.getInstance().getInt(StringConstants.LOOK_VEDIO_TYPE, LOOK_VEDIO_AD_TYPE.NORMAL)));
}
@Override
public void onVideoComplete() {
LogUtils.i("ToutiaoAd", "rewardVideoAd complete");
// Toast.makeText(context,"恭喜您,观看完毕!",Toast.LENGTH_SHORT).show();
}
@Override
public void onVideoError() {
LogUtils.i("ToutiaoAd", "rewardVideoAd onVideoError");
// if (com.burst.ad_toutiao_lib.BuildConfig.DEBUG){
// Toast.makeText(context, "视频播放错误", Toast.LENGTH_SHORT).show();
// }
// ToastUtil.show(context,"视频加载失败,请退出重试");
}
@Override
public void onRewardVerify(boolean b, int i, String s, int i1, String s1) {
}
@Override
public void onSkippedVideo() {
}
});
mttRewardVideoAd.setDownloadListener(new TTAppDownloadListener() {
@Override
public void onIdle() {
}
@Override
public void onDownloadActive(long totalBytes, long currBytes, String fileName, String appName) {
}
@Override
public void onDownloadPaused(long totalBytes, long currBytes, String fileName, String appName) {
}
@Override
public void onDownloadFailed(long totalBytes, long currBytes, String fileName, String appName) {
}
@Override
public void onDownloadFinished(long totalBytes, String fileName, String appName) {
}
@Override
public void onInstalled(String fileName, String appName) {
}
});
mttRewardVideoAd.showRewardVideoAd((Activity) context);
}
}
public interface OnVideoCloseCallBack {
void onClose();
}
public interface OnClickListener {
void onClick();
}
}
package com.mints.goodmoney.manager;
import android.content.Context;
import android.os.SystemClock;
import android.widget.Toast;
import com.chineseall.reader.lib.reader.callbacks.OnAdViewReceiver;
import com.mints.goodmoney.common.AppConfig;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.utils.LogUtil;
import com.mints.goodmoney.utils.ToastUtil;
import com.qq.e.ads.rewardvideo.RewardVideoAD;
import com.qq.e.ads.rewardvideo.RewardVideoADListener;
import com.qq.e.comm.util.AdError;
import java.util.Map;
/**
* 中文在线 听读 优量汇广告
*/
public class ReadYlhAd {
private Context context;
private RewardVideoAD rewardVideoAD;
private boolean isClickScreen = true; // 是否点击屏幕跳转广告
private OnVideoCloseCallBack callBack;
public void loadVideoAd(Context context, OnAdViewReceiver receiver) {
this.context = context;
initVedioAD(context, receiver);
}
private void initVedioAD(final Context context, OnAdViewReceiver receiver) {
rewardVideoAD = new RewardVideoAD(context, YlhAdManager.INSTANCE.getYLH_AD_VEDIO_READER_POSTID(), new RewardVideoADListener() {
@Override
public void onADLoad() {//广告加载成功,可在此回调后进行广告展示,此时广告过期时间确定,可通过RewardVideoAD.getExpireTimestamp()获取
receiver.onReceive(true, null);
}
@Override
public void onVideoCached() {//视频素材缓存成功,可在此回调后进行广告展示
}
@Override
public void onADShow() {//激励视频广告页面展示,此后RewardVideoAD.hasShown()返回true
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_ZERO, "", "");
}
@Override
public void onADExpose() {//激励视频广告曝光
}
@Override
public void onReward(Map<String, Object> map) {
}
@Override
public void onADClick() {//激励视频广告被点击
if (AppConfig.needReportClickAdEvent) {
TrackManager.getInstance().reportClickAdEvent();
}
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_TWO, "", "");
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
}
@Override
public void onVideoComplete() {//广告视频素材播放完毕
}
@Override
public void onADClose() {//激励视频广告被关闭
if (callBack != null) {
callBack.onClose();
}
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_THREE, "", "");
}
@Override
public void onError(AdError adError) {//广告流程出错,AdError中包含错误码和错误描述
receiver.onReceive(false, null);
ToastUtil.show(context,"视频加载失败,请退出重试");
// Toast.makeText(context, "视频播放错误", Toast.LENGTH_SHORT).show();
if (adError != null) {
LogUtil.d("YlhVideoAdManager", "onError " + adError.getErrorCode() + adError.getErrorMsg());
// 0 成功 1失败 2点击 3-有效展示
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_ONE, String.valueOf(adError.getErrorCode()), adError.getErrorMsg());
}
}
});
rewardVideoAD.loadAD();
}
public void showVideo(Context context,OnVideoCloseCallBack callBack) {
this.callBack = callBack;
try {
if (!rewardVideoAD.hasShown()) {//广告展示检查2:当前广告数据还没有展示过
long delta = 1000;//建议给广告过期时间加个buffer,单位ms,这里demo采用1000ms的buffer
//广告展示检查3:展示广告前判断广告数据未过期
if (SystemClock.elapsedRealtime() < (rewardVideoAD.getExpireTimestamp() - delta)) {
rewardVideoAD.showAD();
} else {
// showToast("广告已过期,请再次请求广告后进行广告展示!");
ToastUtil.show(context,"视频加载失败,请退出重试");
}
} else {
// showToast("此条广告已经展示过,请再次请求广告后进行广告展示!");
ToastUtil.show(context,"视频加载失败,请退出重试");
}
} catch (Exception e) {
e.printStackTrace();
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_ONE, "999999", "Load Fail");
}
}
public interface OnVideoCloseCallBack {
void onClose();
}
}
package com.mints.goodmoney.manager
import android.app.Application
import android.app.Dialog
import android.view.View
import androidx.appcompat.app.AlertDialog
import com.chineseall.reader.lib.reader.callbacks.OnAdViewReceiver
import com.chineseall.reader17ksdk.ChineseAllReaderApplication.Companion.install
import com.chineseall.reader17ksdk.callbacks.AdProvider
import com.chineseall.reader17ksdk.utils.ActivityStackManager
import com.chineseall.reader17ksdk.utils.DensityUtil.dip2px
import com.chineseall.reader17ksdk.utils.DensityUtil.px2dip
import com.chineseall.reader17ksdk.utils.NetworkUtil.isNetworkAvailable
import com.chineseall.reader17ksdk.utils.NetworkUtil.isWifiConnected
import com.chineseall.reader17ksdk.utils.book.ScreenUtils
import com.mints.goodmoney.MintsApplication
/**
* 中文在线 听读
* 作者:孟崔广
* 时间:2021/04/08 14:44
* 邮箱:mengcga@163.com
*/
object ReaderManager {
private const val APP_ID = "1242"
private const val SECRET = "hzq@1242"
private const val APP = "32"
private const val SUBAPP = "0"
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() {
val applicationContext = MintsApplication.getContext()
install(applicationContext, APP_ID, SECRET, APP, SUBAPP, object : AdProvider {
/**
* 阅读⻚弹窗广告确认按钮的点击回调-激励视频
* @param dialog
* @param block 对话框关闭回调,必须调用,否则计时每次切换章节都会出现弹窗
*/
override fun onAdDialogPositiveClick(dialog: Dialog?, function0: Function0<Unit>) {
if (isNetworkAvailable(applicationContext) && !isWifiConnected(applicationContext)) {
AlertDialog.Builder(ActivityStackManager.getInstance().topActivity)
.setTitle("温馨提示")
.setMessage("当前处于移动网络,播放视频会消耗流量,确定播放?")
.setPositiveButton("观看视频") { dialog, which ->
onAdDialogInvoke(function0)
}.setNegativeButton("取消") { dialog, which -> dialog.dismiss() }
.create().show()
return
} else {
onAdDialogInvoke(function0)
}
}
/**
* 阅读⻚首次打开 弹框广告(信息流) 广告宽度 320 高度 260 * @param adViewContainer 广告view的容器
*/
override fun getReaderScreenAd(view: View, receiver: OnAdViewReceiver,
dialog: Dialog?) {
csjAd.loadAD(applicationContext, receiver, 320, 260, ReadToutiaoAD.OnClickListener { dialog!!.dismiss() })
}
/**
* 阅读⻚翻⻚广告(信息流) 广告宽度 320 高度 260
*/
override fun getReaderPageAd(receiver: OnAdViewReceiver) {
csjAd.loadAD(applicationContext, receiver, px2dip(applicationContext, ScreenUtils.getScreenWidth(applicationContext) - dip2px(applicationContext, 30f).toFloat()), px2dip(applicationContext, 854f), null)
}
/**
* 阅读⻚定时弹窗广告 (激励视频)
*/
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
...@@ -21,7 +21,6 @@ import com.mints.goodmoney.mvp.views.MainView ...@@ -21,7 +21,6 @@ import com.mints.goodmoney.mvp.views.MainView
import com.mints.goodmoney.ui.activitys.base.BaseActivity import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.goodmoney.ui.fragment.* import com.mints.goodmoney.ui.fragment.*
import com.mints.goodmoney.utils.LogUtil import com.mints.goodmoney.utils.LogUtil
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
/** /**
...@@ -30,7 +29,6 @@ import kotlinx.android.synthetic.main.activity_main.* ...@@ -30,7 +29,6 @@ import kotlinx.android.synthetic.main.activity_main.*
* 时间:2020/10/9 10:39 * 时间:2020/10/9 10:39
* 邮箱:mengcga@163.com * 邮箱:mengcga@163.com
*/ */
@AndroidEntryPoint
class MainActivity : BaseActivity(), MainView, View.OnClickListener { class MainActivity : BaseActivity(), MainView, View.OnClickListener {
private val audioManager by lazy { getSystemService(Context.AUDIO_SERVICE) as AudioManager } private val audioManager by lazy { getSystemService(Context.AUDIO_SERVICE) as AudioManager }
......
...@@ -4,13 +4,11 @@ import android.os.Bundle ...@@ -4,13 +4,11 @@ import android.os.Bundle
import android.view.View import android.view.View
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction import androidx.fragment.app.FragmentTransaction
import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenFragment
import com.mints.goodmoney.R import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ui.activitys.base.BaseActivity import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.goodmoney.ui.fragment.* import com.mints.goodmoney.ui.fragment.*
import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.activity_wrapper.* import kotlinx.android.synthetic.main.activity_wrapper.*
import kotlinx.android.synthetic.main.header_layout.* import kotlinx.android.synthetic.main.header_layout.*
...@@ -19,7 +17,6 @@ import kotlinx.android.synthetic.main.header_layout.* ...@@ -19,7 +17,6 @@ import kotlinx.android.synthetic.main.header_layout.*
* 作者:孟崔广 * 作者:孟崔广
* 时间:2020/12/10 12:39 * 时间:2020/12/10 12:39
*/ */
@AndroidEntryPoint
class WrapperActivity : BaseActivity(), View.OnClickListener { class WrapperActivity : BaseActivity(), View.OnClickListener {
private var wrapperType = Constant.WRAPPER_TYPE_NEWS private var wrapperType = Constant.WRAPPER_TYPE_NEWS
...@@ -64,10 +61,6 @@ class WrapperActivity : BaseActivity(), View.OnClickListener { ...@@ -64,10 +61,6 @@ class WrapperActivity : BaseActivity(), View.OnClickListener {
// transaction.show(wellChosenFragment) // transaction.show(wellChosenFragment)
// transaction.commitAllowingStateLoss() // transaction.commitAllowingStateLoss()
} }
Constant.WRAPPER_TYPE_BOOK -> {
tv_title.text = "书城"
currentFragment = ReaderFragment()
}
Constant.WRAPPER_TYPE_FRIENDS -> { Constant.WRAPPER_TYPE_FRIENDS -> {
tv_title.text = "瓜分百万现金福利" tv_title.text = "瓜分百万现金福利"
currentFragment = FriendsFragment(true) currentFragment = FriendsFragment(true)
......
...@@ -190,7 +190,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener { ...@@ -190,7 +190,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
homePresenter.comSaveTerminalInfo(ps) homePresenter.comSaveTerminalInfo(ps)
baseApplication.initUm(context) baseApplication.initUm(context)
baseApplication.TalkingDataConfig() baseApplication.TalkingDataConfig()
ReaderManager.init()
// } // }
} }
......
...@@ -18,16 +18,12 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener { ...@@ -18,16 +18,12 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
companion object { companion object {
const val FRAGMENT_TAG_VIDEO = "FRAGMENT_TAG_VIDEO" const val FRAGMENT_TAG_VIDEO = "FRAGMENT_TAG_VIDEO"
const val FRAGMENT_TAG_BOOKSTORE = "FRAGMENT_TAG_BOOKSTORE"
const val FRAGMENT_TAG_NEWS = "FRAGMENT_TAG_NEWS"
const val FRAGMENT_TAG_GAME = "FRAGMENT_TAG_GAME"
const val FRAGMENT_TAG_KYL = "FRAGMENT_TAG_KYL" const val FRAGMENT_TAG_KYL = "FRAGMENT_TAG_KYL"
const val FRAGMENT_TAG_XMLY = "FRAGMENT_TAG_XMLY" const val FRAGMENT_TAG_XMLY = "FRAGMENT_TAG_XMLY"
} }
private var currentFragment: Fragment? = null private var currentFragment: Fragment? = null
private var mainFragment: Fragment? = null private var mainFragment: Fragment? = null
private var bookStoreFragment: Fragment? = null
// private var newsFragment: Fragment? = null // private var newsFragment: Fragment? = null
private var xmlyGameFragment: Fragment? = null private var xmlyGameFragment: Fragment? = null
...@@ -70,17 +66,14 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener { ...@@ -70,17 +66,14 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
currentFragment = mainFragment currentFragment = mainFragment
} }
xtFragmentMoney.setxTabDisplayNum(4) xtFragmentMoney.setxTabDisplayNum(3)
val newTab1 = xtFragmentMoney.newTab() val newTab1 = xtFragmentMoney.newTab()
newTab1.text = "视频" newTab1.text = "视频"
val newTab3 = xtFragmentMoney.newTab()
newTab3.text = "书城"
val newTab4 = xtFragmentMoney.newTab() val newTab4 = xtFragmentMoney.newTab()
newTab4.text = "听书" newTab4.text = "听书"
val newTab6 = xtFragmentMoney.newTab() val newTab6 = xtFragmentMoney.newTab()
newTab6.text = "来电秀" newTab6.text = "来电秀"
xtFragmentMoney.addTab(newTab1) xtFragmentMoney.addTab(newTab1)
xtFragmentMoney.addTab(newTab3)
xtFragmentMoney.addTab(newTab4) xtFragmentMoney.addTab(newTab4)
xtFragmentMoney.addTab(newTab6) xtFragmentMoney.addTab(newTab6)
xtFragmentMoney.addOnTabSelectedListener(this) xtFragmentMoney.addOnTabSelectedListener(this)
...@@ -135,11 +128,6 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener { ...@@ -135,11 +128,6 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
} }
fun selectBook() { fun selectBook() {
xtFragmentMoney.getTabAt(1)?.select()
if (bookStoreFragment == null) {
bookStoreFragment = ReaderFragment()
}
addOrShowFragment(childFragmentManager, bookStoreFragment!!, FRAGMENT_TAG_BOOKSTORE)
} }
fun selectXmly() { fun selectXmly() {
...@@ -173,18 +161,12 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener { ...@@ -173,18 +161,12 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
} }
1 -> { 1 -> {
if (bookStoreFragment == null) {
bookStoreFragment = ReaderFragment()
}
addOrShowFragment(childFragmentManager, bookStoreFragment!!, FRAGMENT_TAG_BOOKSTORE)
}
2 -> {
if (xmlyGameFragment == null) { if (xmlyGameFragment == null) {
xmlyGameFragment = XmlyFragment() xmlyGameFragment = XmlyFragment()
} }
addOrShowFragment(childFragmentManager, xmlyGameFragment!!, FRAGMENT_TAG_XMLY) addOrShowFragment(childFragmentManager, xmlyGameFragment!!, FRAGMENT_TAG_XMLY)
} }
3 -> { 2 -> {
if (kuYinyueFragment == null) { if (kuYinyueFragment == null) {
kuYinyueFragment = KuYinYueFragment() kuYinyueFragment = KuYinYueFragment()
} }
......
package com.mints.goodmoney.ui.fragment
import android.os.Bundle
import android.view.View
import androidx.fragment.app.FragmentTransaction
import com.chineseall.reader17ksdk.ChineseAllReaderApplication
import com.chineseall.reader17ksdk.callbacks.OnReadCallBack
import com.chineseall.reader17ksdk.feature.main.bookshop.wellchosen.WellChosenFragment
import com.mints.goodmoney.R
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.mvp.presenters.BookPresenter
import com.mints.goodmoney.mvp.views.BookView
import com.mints.goodmoney.ui.activitys.AwardActivity
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.SpanUtils
import kotlinx.android.synthetic.main.fragment_main_zy.*
/**
* 描述:听读
* 作者:孟崔广
* 时间:2021/04/08 10:55
*/
class ReaderFragment : LazyLoadBaseFragment(), BookView, OnReadCallBack {
private val wellChosenFragment by lazy { WellChosenFragment("home") }
private val bookPresenter by lazy { BookPresenter() }
override fun getContentViewLayoutID() = R.layout.fragment_main_zy
override fun initViewsAndEvents() {}
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)
}
override fun onFragmentResume() {
super.onFragmentResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
bookPresenter.getReadInfo()
}
}
override fun onDestroy() {
super.onDestroy()
ChineseAllReaderApplication.destory()
bookPresenter.detachView()
}
override fun readSecondsSuc(coin: Int) {
if (coin > 0) {
val bundle = Bundle()
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_ZHANGYUE)
bundle.putInt(Constant.MAIN_CUR_COIN, coin)
readyGo(AwardActivity::class.java, bundle)
}
}
override fun readInfo(sumTime: Int, sumCoin: Int, readTime: Int) {
//阅读{10}分钟,奖励{xx}金币,已读{x}分钟
tvZhangContent.visibility = View.VISIBLE
if (readTime >= sumTime) {
tvZhangContent.text = "今日阅读任务已完成"
} else {
tvZhangContent.text = SpanUtils()
.append("阅读").append("${sumTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟, ")
.append("奖励").append("$sumCoin").setForegroundColor(mContext.resources.getColor(R.color.color_cb4a39)).append("金币, ")
.append("已读").append("${readTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟")
.create()
}
}
override fun onReceive(map: Map<String, Any>) {
val time = map.get("time").toString().toInt()
val seconds = (time / 1000)
// 阅读5秒以上 保存时长
if (seconds > 5) {
bookPresenter.addReadSeconds(seconds)
}
LogUtil.d("ReaderFragment", "time:-->${time}")
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/blue" />
<corners android:radius="5dip" />
</shape>
\ No newline at end of file
buildscript { buildscript {
ext.kotlin_version = '1.3.72' ext.kotlin_version = '1.3.72'
ext { // ext {
// 听读 App dependencies // // 听读 App dependencies
appCompatVersion = '1.1.0' // appCompatVersion = '1.1.0'
assistedInjectVersion = '0.5.2' // assistedInjectVersion = '0.5.2'
constraintLayoutVersion = '2.0.0-beta3' // constraintLayoutVersion = '2.0.0-beta3'
coreTestingVersion = '2.0.0' // coreTestingVersion = '2.0.0'
coroutinesVersion = "1.3.0-M2" // coroutinesVersion = "1.3.0-M2"
espressoVersion = '3.1.1' // espressoVersion = '3.1.1'
fragmentVersion = '1.1.0-alpha09' // fragmentVersion = '1.1.0-alpha09'
glideVersion = '4.10.0' // glideVersion = '4.10.0'
gradleVersion = '4.0.1' // gradleVersion = '4.0.1'
gsonVersion = '2.8.2' // gsonVersion = '2.8.2'
hiltVersion = '2.28.3-alpha' // hiltVersion = '2.28.3-alpha'
hiltViewModelVersion = '1.0.0-alpha02' // hiltViewModelVersion = '1.0.0-alpha02'
junitVersion = '4.12' // junitVersion = '4.12'
kotlinVersion = '1.4.10' // kotlinVersion = '1.4.10'
ktlintVersion = '0.38.1' // ktlintVersion = '0.38.1'
ktxVersion = '1.0.2' // ktxVersion = '1.0.2'
lifecycleVersion = '2.2.0' // lifecycleVersion = '2.2.0'
materialVersion = '1.2.0' // materialVersion = '1.2.0'
navigationVersion = '2.3.1' // navigationVersion = '2.3.1'
okhttpLoggingVersion = '4.7.2' // okhttpLoggingVersion = '4.7.2'
pagingVersion = '3.0.0-alpha09' // pagingVersion = '3.0.0-alpha09'
recyclerViewVersion = '1.2.0-alpha04' // recyclerViewVersion = '1.2.0-alpha04'
retrofitVersion = '2.9.0' // retrofitVersion = '2.9.0'
roomVersion = '2.3.0-alpha01' // roomVersion = '2.3.0-alpha01'
runnerVersion = '1.0.1' // runnerVersion = '1.0.1'
truthVersion = '0.42' // truthVersion = '0.42'
testExtJunit = '1.1.0' // testExtJunit = '1.1.0'
uiAutomatorVersion = '2.2.0' // uiAutomatorVersion = '2.2.0'
viewPagerVersion = '1.0.0' // viewPagerVersion = '1.0.0'
workVersion = '2.1.0' // workVersion = '2.1.0'
kotlin_version = '1.4.10' // kotlin_version = '1.4.10'
arouter_compiler_version = '1.5.1' // arouter_compiler_version = '1.5.1'
arouter_api_version = '1.5.1' // arouter_api_version = '1.5.1'
refresh_version = "2.0.1" // refresh_version = "2.0.1"
} // }
repositories { repositories {
google() google()
...@@ -56,11 +56,11 @@ buildscript { ...@@ -56,11 +56,11 @@ buildscript {
classpath 'com.android.tools.build:gradle:4.0.1' classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 听读 // // 听读
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.1" // classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.1"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.28.3-alpha" // classpath "com.google.dagger:hilt-android-gradle-plugin:2.28.3-alpha"
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10' // classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10'
classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:3.3.1' // classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:3.3.1'
// 穿山甲APPlog // 穿山甲APPlog
classpath 'com.bytedance.applog:RangersAppLog-All-plugin:5.2.6' classpath 'com.bytedance.applog:RangersAppLog-All-plugin:5.2.6'
......
...@@ -16,9 +16,9 @@ android.injected.testOnly=false ...@@ -16,9 +16,9 @@ android.injected.testOnly=false
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true # org.gradle.parallel=true
#DEBUG_URL="http://39.97.65.143:9082/api-gm/" DEBUG_URL="http://39.97.65.143:9082/api-gm/"
#DEBUG_URL="http://192.168.31.194:8101/" #DEBUG_URL="http://192.168.31.194:8101/"
DEBUG_URL="https://api.mints-id.com/api-gm/" #DEBUG_URL="https://api.mints-id.com/api-gm/"
RELEASE_URL="https://api.mints-id.com/api-gm/" RELEASE_URL="https://api.mints-id.com/api-gm/"
RELEASE_KEY_PASSWORD=mints.goodmoney RELEASE_KEY_PASSWORD=mints.goodmoney
......
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