Commit 592c0a79 authored by jyx's avatar jyx

多多短剧已

parent 5a87a336
...@@ -7,7 +7,7 @@ android { ...@@ -7,7 +7,7 @@ android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion compileSdkVersion rootProject.ext.androidCompileSdkVersion
buildToolsVersion rootProject.ext.androidBuildToolsVersion buildToolsVersion rootProject.ext.androidBuildToolsVersion
defaultConfig { defaultConfig {
applicationId "com.duben.speedplayletu" applicationId "com.duben.duoduoplayletu"
minSdkVersion rootProject.ext.androidMinSdkVersion minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 719 versionCode 719
......
...@@ -124,16 +124,16 @@ ...@@ -124,16 +124,16 @@
#忽略警告 #忽略警告
-dontwarn com.duben.speedplayletu.mvp.model.** -dontwarn com.duben.duoduoplayletu.mvp.model.**
#保留实体类 #保留实体类
-keep class com.duben.speedplayletu.mvp.model.** { -keep class com.duben.duoduoplayletu.mvp.model.** {
*; *;
} }
#忽略警告 #忽略警告
-dontwarn com.duben.speedplayletu.ui.widgets.** -dontwarn com.duben.duoduoplayletu.ui.widgets.**
#保留实体类 #保留实体类
-keep class com.duben.speedplayletu.ui.widgets.** { -keep class com.duben.duoduoplayletu.ui.widgets.** {
*; *;
} }
...@@ -323,7 +323,7 @@ ...@@ -323,7 +323,7 @@
public static **[] values(); public static **[] values();
public static ** valueOf(java.lang.String); public static ** valueOf(java.lang.String);
} }
-keep public class com.duben.speedplayletu.R$*{ -keep public class com.duben.duoduoplayletu.R$*{
public static final int *; public static final int *;
} }
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.duben.speedplayletu"> package="com.duben.duoduoplayletu">
<!-- 健康运动 --> <!-- 健康运动 -->
<uses-permission <uses-permission
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
<!-- 自有下载 --> <!-- 自有下载 -->
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
android:authorities="com.duben.speedplayletu.fileprovider" android:authorities="com.duben.duoduoplayletu.fileprovider"
android:exported="false" android:exported="false"
android:grantUriPermissions="true"> android:grantUriPermissions="true">
<meta-data <meta-data
......
package com.duben.duoduoplayletu;
import android.content.Context;
import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
import com.downloader.PRDownloader;
import com.downloader.PRDownloaderConfig;
import com.duben.duoduoplayletu.ad.TTAdManagerHolder;
import com.duben.duoduoplayletu.common.Constant;
import com.duben.duoduoplayletu.manager.CsjAppLogManager;
import com.duben.duoduoplayletu.manager.TXCSDKService;
import com.duben.duoduoplayletu.manager.TalkingDataManager;
import com.duben.duoduoplayletu.net.LoanService;
import com.duben.duoduoplayletu.net.V6Service;
import com.duben.duoduoplayletu.utils.AppPreferencesManager;
import com.duben.duoduoplayletu.utils.ForegroundOrBackground;
import com.duben.duoduoplayletu.utils.MateUtils;
import com.duben.oaid.MiitHelper;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.FormatStrategy;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;
import com.tencent.bugly.crashreport.CrashReport;
import rx.Scheduler;
import rx.schedulers.Schedulers;
/**
* 描述:Application
* 作者:孟崔广
* 时间:2020/6/15 17:40
*/
public class MintsApplication extends MultiDexApplication {
private static Context mContext;
public static String OAID = "";
private static LocalBroadcastManager mLocalBroadcatManager;
private Scheduler defaultSubscribeScheduler;
private LoanService loanService;
private V6Service v6Service;
/**
* 获取全局context
*/
public static Context getContext() {
return mContext;
}
@Override
public void onCreate() {
super.onCreate();
mContext = this.getApplicationContext();
// 三方配置
thirdConfig();
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
/**
* 三方配置
*/
public void thirdConfig() {
// 未同意权限弹窗,不进行SDK初始化
if (AppPreferencesManager.INSTANCE.get()
.getBoolean(Constant.LOAN_PERMISSION_FLAG, true)) return;
// 判断应用是否在前台
ForegroundOrBackground.init(this);
initMiitHelper();
TTAdManagerHolder.init(this);
TXCSDKService.init(this);
CsjAppLogManager.INSTANCE.init(this);
TalkingDataManager.INSTANCE.init(this);
// PR下载附件
initPRDownloader();
//logger
BindLogger();
// bugly
CrashReport.initCrashReport(this, "d035276c5b", BuildConfig.DEBUG);
}
/**
* PR下载附件
*/
private void initPRDownloader() {
PRDownloaderConfig config = PRDownloaderConfig.newBuilder()
.setDatabaseEnabled(true)
.build();
PRDownloader.initialize(this, config);
}
/**
* 自定义logger
*/
private void BindLogger() {
//自定义logger
FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
.showThreadInfo(false) //是否选择显示线程信息,默认为true
.methodCount(0) //方法数显示多少行,默认2行
.methodOffset(7) //隐藏方法内部调用到偏移量,默认5
// .logStrategy(customLog) //打印日志的策略,默认LogCat
.tag("mints---network") //自定义TAG全部标签,默认PRETTY_LOGGER
.build();
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));
}
/**
* app退出
*/
public void exitApp() {
Intent intent = new Intent();
intent.setAction(Constant.ACTION_EXIT_APP);
intent.addCategory(Intent.CATEGORY_DEFAULT);
MintsApplication.getLocalBroadcastManager().sendBroadcast(intent);
System.gc();
}
/**
* 获得LocalBroadcastManager对象
*
* @return LocalBroadcastManager对象
*/
public static LocalBroadcastManager getLocalBroadcastManager() {
if (mLocalBroadcatManager == null) {
mLocalBroadcatManager = LocalBroadcastManager.getInstance(mContext);
}
return mLocalBroadcatManager;
}
public LoanService getLoanService() {
if (loanService == null) {
loanService = LoanService.Factory.create(this);
}
return loanService;
}
public V6Service getV6Service() {
if (v6Service == null) {
v6Service = V6Service.Factory.create();
}
return v6Service;
}
public Scheduler defaultSubscribeScheduler() {
if (defaultSubscribeScheduler == null) {
defaultSubscribeScheduler = Schedulers.io();
}
return defaultSubscribeScheduler;
}
/**
* 移动安装联盟 获取OAID等设备标识符
*/
private void initMiitHelper() {
try {
MiitHelper miitHelper = new MiitHelper(new MiitHelper.AppIdsUpdater() {
@Override
public void onIdsValid(String ids) {
MintsApplication.OAID = ids;
System.out.println("123123123 oaid=" + ids);
}
});
miitHelper.getDeviceIds(MintsApplication.getContext(), true, true, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.duben.duoduoplayletu.ad
import android.app.Activity
import com.duben.duoduoplayletu.ad.splash.SplashManager
import com.duben.duoduoplayletu.ad.video.InMoneyVideo
import com.duben.duoduoplayletu.manager.UserManager
/**
* 预加载-全屏及激励视频管理类
*/
class AdManager {
companion object {
const val AD_NO_SHOWTIME_OUT = 50 // 广告请示成功但在规定时间内未展示
const val AD_REQUEST_TIME_OUT = 1 // 广告预加载时长超时
val instance: AdManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
AdManager()
}
}
/**
* 根据服务器概率预加载广告
*
* isPreLoad:是否是预加载调用,需要躲避监听
*/
fun preLoadAd(activity: Activity, isPreLoad: Boolean = false) {
InMoneyVideo.getInstance().preLoadAd(activity, isPreLoad)
}
/**
* 根据预加载类型 展示广告
*/
fun showAd(
activity: Activity,
carrierType: String,
AdStatusListener: AdStatusListener?,
) {
InMoneyVideo.getInstance()
.showRewardAd(
activity,
AdStatusListener,
carrierType,
)
}
}
\ No newline at end of file
package com.duben.duoduoplayletu.ad
import java.util.HashMap
interface AdStatusListener {
fun adSuccess()
fun adFail()
fun adClose(vo : HashMap<String, Any>?)
}
\ No newline at end of file
package com.duben.duoduoplayletu.ad
import android.app.Activity
import com.duben.duoduoplayletu.ad.video.InMoneyVideoNoPre
import java.util.HashMap
/**
* 实时加载激励视频、全屏
*/
object NoPreAdManager {
private val TAG = NoPreAdManager::class.java.simpleName
fun loadVideoAd(
activity: Activity,
carrierType: String,
listener: AdStatusListener?
) {
val adNoProListener = object : AdStatusListener {
override fun adFail() {
listener?.adFail()
}
override fun adSuccess() {
listener?.adSuccess()
}
override fun adClose(vo : HashMap<String, Any>?) {
listener?.adClose(vo)
}
}
InMoneyVideoNoPre.getInstance().loadAd(activity, adNoProListener, carrierType)
}
}
\ No newline at end of file
package com.duben.duoduoplayletu.ad;
import android.content.Context;
import android.util.Log;
import com.bytedance.hume.readapk.HumeSDK;
import com.bytedance.sdk.openadsdk.TTAdConfig;
import com.bytedance.sdk.openadsdk.TTAdManager;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.TTCustomController;
import com.bytedance.sdk.openadsdk.mediation.init.MediationConfigUserInfoForSegment;
import com.bytedance.sdk.openadsdk.mediation.init.MediationPrivacyConfig;
import com.duben.duoduoplayletu.BuildConfig;
import com.duben.duoduoplayletu.MintsApplication;
import com.duben.duoduoplayletu.common.Constant;
import com.duben.duoduoplayletu.utils.AppPreferencesManager;
import com.duben.duoduoplayletu.utils.DeviceUuidFactory;
import com.duben.duoduoplayletu.utils.LogUtil;
import java.util.HashMap;
import java.util.Map;
/**
* 可以用一个单例来保存TTAdManager实例,在需要初始化sdk的时候调用
*/
public class TTAdManagerHolder {
private static final String TT_AD_APPID = BuildConfig.GROMORE_APP_ID;
private static final String TT_AD_NAME = Constant.MINTS_APP_NAME;
private static final String TAG = "TTAdManagerHolder";
private static boolean sInit;
public static TTAdManager get() {
return TTAdSdk.getAdManager();
}
public static void init(final Context context) {
//初始化穿山甲SDK
doInit(context);
}
//step1:接入网盟广告sdk的初始化操作,详情见接入文档和穿山甲平台说明
private static void doInit(Context context) {
if (!sInit) {
//TTAdSdk.init(context, buildConfig(context));
//setp1.1:初始化SDK
TTAdSdk.init(context, buildConfig(context));
//setp1.2:启动SDK
TTAdSdk.start(new TTAdSdk.Callback() {
@Override
public void success() {
Log.i(TAG, "success: " + TTAdSdk.isInitSuccess());
}
@Override
public void fail(int code, String msg) {
Log.i(TAG, "fail: code = " + code + " msg = " + msg);
}
});
sInit = true;
}
}
private static TTAdConfig buildConfig(Context context) {
return new TTAdConfig.Builder()
/**
* 注:需要替换成在媒体平台申请的appID ,切勿直接复制
*/
.appId(TT_AD_APPID)
.appName(TT_AD_NAME)
/**
* 上线前需要关闭debug开关,否则会影响性能
*/
.debug(BuildConfig.DEBUG)
/**
* 使用聚合功能此开关必须设置为true,默认为false,不会初始化聚合模板,聚合功能会吟唱
*/
.useMediation(true)
.customController(getTTCustomController()) //如果您需要设置隐私策略请参考该api
// .setMediationConfig(new MediationConfig.Builder() //可设置聚合特有参数详细设置请参考该api
// .setMediationConfigUserInfoForSegment(getUserInfoForSegment())//如果您需要配置流量分组信息请参考该api
// .build())
.build();
}
private static MediationConfigUserInfoForSegment getUserInfoForSegment(){
MediationConfigUserInfoForSegment userInfo = new MediationConfigUserInfoForSegment();
userInfo.setUserId(new DeviceUuidFactory().getDeviceUuid().toString());
userInfo.setGender(MediationConfigUserInfoForSegment.GENDER_MALE);
// userInfo.setChannel("msdk-channel");
userInfo.setSubChannel(HumeSDK.getChannel(MintsApplication.getContext()));
// userInfo.setAge(999);
// userInfo.setUserValueGroup("msdk-demo-user-value-group");
Map<String, String> customInfos = new HashMap<>();
// customInfos.put("aaaa", "test111");
// customInfos.put("bbbb", "test222");
userInfo.setCustomInfos(customInfos);
return userInfo;
}
private static TTCustomController getTTCustomController(){
return new TTCustomController() {
@Override
public boolean isCanUsePhoneState() {
return false;
}
@Override
public boolean isCanUseWifiState() {
return false;
}
@Override
public String getMacAddress() {
return "";
}
@Override
public boolean isCanUseWriteExternal() {
return false;
}
@Override
public String getDevOaid() {
return "";
}
@Override
public boolean isCanUseAndroidId() {
return false;
}
@Override
public String getAndroidId() {
return "";
}
@Override
public MediationPrivacyConfig getMediationPrivacyConfig() {
return new MediationPrivacyConfig() {
@Override
public boolean isCanUseOaid() {
return false;
}
@Override
public boolean isLimitPersonalAds() {
if (AppPreferencesManager.INSTANCE.get()
.getBoolean(Constant.LOAN_PERMISSION_FLAG, true)) return false;
return super.isLimitPersonalAds();
}
@Override
public boolean isProgrammaticRecommend() {
if (AppPreferencesManager.INSTANCE.get()
.getBoolean(Constant.LOAN_PERMISSION_FLAG, true)) return false;
return super.isProgrammaticRecommend();
}
};
}
@Override
public boolean isCanUsePermissionRecordAudio() {
if (AppPreferencesManager.INSTANCE.get()
.getBoolean(Constant.LOAN_PERMISSION_FLAG, true)) return false;
return super.isCanUsePermissionRecordAudio();
}
};
}
}
package com.duben.duoduoplayletu.ad.banner
import android.app.Activity
import android.view.View
import android.widget.FrameLayout
import com.bytedance.sdk.openadsdk.*
import com.bytedance.sdk.openadsdk.mediation.ad.IMediationNativeAdInfo
import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot
import com.bytedance.sdk.openadsdk.mediation.ad.MediationNativeToBannerListener
import com.duben.duoduoplayletu.MintsApplication
import com.duben.duoduoplayletu.common.Constant
import com.duben.duoduoplayletu.manager.TrackManager
import com.duben.duoduoplayletu.utils.LogUtil
import com.duben.duoduoplayletu.utils.UIUtils
import java.lang.ref.WeakReference
import com.duben.duoduoplayletu.BuildConfig
/**
* banner
*/
object BannerManager {
private val TAG = BannerManager::class.java.simpleName
private var weakFrameLayout: WeakReference<FrameLayout>? = null
private var weakActivity: WeakReference<Activity>? = null
private var bannerAd: TTNativeExpressAd? = null
fun loadAd(act: Activity?, view: FrameLayout?) {
weakActivity = WeakReference<Activity>(act)
weakFrameLayout = WeakReference<FrameLayout>(view)
LogUtil.d(TAG, "gromore banner广告-> 1、进入加载")
/** 这里是简单的banner请求adSlot设置,如果需要更多的设置,可参考AdUtils.kt中bannerAdSlot函数部分。 */
var adSlot: AdSlot = AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_BANNER_CODE)
// .setImageAcceptedSize(UIUtils.dp2px(weakActivity?.get(), 300f), UIUtils.dp2px(weakActivity?.get(), 45f)) // 单位px
// .setImageAcceptedSize(
// UIUtils.getAdWidth2(MintsApplication.getContext()).toInt(),
// 0
// )
// 单位px
.supportRenderControl() //支持模板样式
.setExpressViewAcceptedSize(
UIUtils.getAdWidth2(MintsApplication.getContext()),
0f
)//设置模板宽高(dp)
.setUserID("1234")
.setMediationAdSlot(
MediationAdSlot.Builder()
/**
* banner混出自渲染信息流时,需要提供该转换listener,将信息流自渲染素材转成view。模板类型无需处理
* 如果未使用banner混出信息流功能,则无需设置MediationNativeToBannerListener。
* 如要使用混出功能,可参考AdUtils.kt类中getCSJMBannerViewFromNativeAd函数部分。
*/
.setMediationNativeToBannerListener(object : MediationNativeToBannerListener() {
override fun getMediationBannerViewFromNativeAd(adInfo: IMediationNativeAdInfo): View? {
return null
}
})
.build()
)
.build()
var adNativeLoader: TTAdNative = TTAdSdk.getAdManager().createAdNative(weakActivity?.get())
adNativeLoader.loadBannerExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
override fun onNativeExpressAdLoad(ads: MutableList<TTNativeExpressAd>?) {
LogUtil.d(TAG, "banner广告-> 2、 load success: " + if (ads == null) "0" else ads?.size)
ads?.let {
if (it.size > 0) {
val ad: TTNativeExpressAd = it[0]
bannerAd = ad
bannerAd?.setExpressInteractionListener(object :
TTNativeExpressAd.ExpressAdInteractionListener {
override fun onAdClicked(view: View?, type: Int) {
}
override fun onAdShow(view: View?, type: Int) {
if (bannerAd != null && bannerAd!!.mediationManager != null && bannerAd!!.mediationManager.showEcpm != null
&& bannerAd!!.mediationManager.showEcpm.ecpm != null) {
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE3
vo["cpmFen"] = bannerAd!!.mediationManager.showEcpm.ecpm
TrackManager.getInstance().cmtEcpm(vo)
}
}
override fun onRenderFail(view: View?, msg: String?, code: Int) {
}
override fun onRenderSuccess(view: View?, width: Float, height: Float) {
}
})
bannerAd?.setDislikeCallback(
weakActivity?.get(),
object : TTAdDislike.DislikeInteractionCallback {
override fun onShow() {
}
override fun onSelected(
position: Int,
value: String?,
enforce: Boolean
) {
weakFrameLayout?.get()?.removeAllViews()
}
override fun onCancel() {
}
})
showAd()
}
}
}
override fun onError(code: Int, message: String?) {
LogUtil.e(TAG, "banner广告-> 2、 load fail: $code, $message")
}
})
}
private fun showAd() {
val bannerView: View? = bannerAd?.expressAdView
if (bannerView != null && weakFrameLayout != null) {
val bannerContainer = weakFrameLayout!!.get()
bannerContainer!!.removeAllViews()
bannerContainer!!.addView(bannerView)
}
}
}
\ No newline at end of file
package com.duben.duoduoplayletu.ad.express
import android.widget.FrameLayout
/**
*
* @des 信息流回调
*/
interface ExpressAdCallback {
fun loadSuccess(adView: FrameLayout?)
fun renderSuccess(adView: FrameLayout?): Boolean
fun loadFail()
}
\ No newline at end of file
package com.duben.duoduoplayletu.ad.splash
import android.app.Activity
import android.view.View
import android.widget.FrameLayout
import com.bytedance.sdk.openadsdk.*
import com.bytedance.sdk.openadsdk.mediation.MediationConstant
import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot
import com.bytedance.sdk.openadsdk.mediation.ad.MediationSplashRequestInfo
import com.duben.duoduoplayletu.MintsApplication
import com.duben.duoduoplayletu.ad.AdStatusListener
import com.duben.duoduoplayletu.common.Constant
import com.duben.duoduoplayletu.manager.TrackManager
import com.duben.duoduoplayletu.utils.LogUtil
import com.duben.duoduoplayletu.utils.UIUtils
import java.lang.ref.WeakReference
import java.util.HashMap
import com.duben.duoduoplayletu.BuildConfig
/**
* 应用内-网赚开屏
*/
object SplashManager {
// 兜底配置
val pangleSplashBottom = object :
MediationSplashRequestInfo(
MediationConstant.ADN_PANGLE, "889457860",
BuildConfig.GROMORE_APP_ID, ""
) {} //ok
private val TAG = SplashManager::class.java.simpleName
private var mTTSplashAd: TTSplashAd? = null
private const val AD_TIME_OUT = 5000 //开屏广告加载超时时间
private var isLoadSuccess = 0 //0-加载失败/未加载 1-加载中 2-加载成功
private var isShowAd = false // 是否显示广告
private var adStatusListener: AdStatusListener? = null
/**
* 预加载开屏广告
*/
fun preLoadAd(activity: Activity) {
val weakActivity = WeakReference<Activity>(activity)
LogUtil.d(TAG, "gromore 开屏广告-> 1、进入预加载")
if (isLoadSuccess == 1) {
return
}
val adNativeLoader = TTAdSdk.getAdManager().createAdNative(weakActivity.get())
val adslot = AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_SPLASH_CODE)
.setImageAcceptedSize(
UIUtils.getScreenWidth(MintsApplication.getContext()),
UIUtils.getScreenHeight(MintsApplication.getContext())
)
.setMediationAdSlot(
MediationAdSlot.Builder()
.setMediationSplashRequestInfo(pangleSplashBottom)
.build()
)
.build()
adNativeLoader.loadSplashAd(adslot, object : TTAdNative.SplashAdListener {
override fun onError(p0: Int, p1: String?) {
LogUtil.e(
TAG,
"gromore 开屏广告--> 3、Gromore onSplashAdLoadFail adErrorCode=${p0} " + p1
)
isLoadSuccess = 0
}
override fun onTimeout() {
LogUtil.d(TAG, "gromore 开屏广告--> 3、Gromore onAdLoadTimeout")
isLoadSuccess = 0
}
override fun onSplashAdLoad(p0: TTSplashAd?) {
LogUtil.d(TAG, "gromore 开屏广告--> 3、Gromore onSplashAdLoadSuccess")
LogUtil.d("SplashNewActivity-->", "333333--> ad show")
isLoadSuccess = 2
mTTSplashAd = p0
}
})
}
/**
* 展示开屏广告
*/
fun showAd(activity: Activity, view: FrameLayout, adStatusListener: AdStatusListener?) {
this.adStatusListener = adStatusListener
isShowAd = false
if (mTTSplashAd != null && isLoadSuccess == 2) {
LogUtil.d(TAG, "gromore 开屏广告--> 准备调用show")
mTTSplashAd?.let {
it.setSplashInteractionListener(adInteractionListener)
// it.setSplashClickEyeListener(object: ISplashClickEyeListener {
// override fun onSplashClickEyeAnimationStart() {
// }
//
// override fun onSplashClickEyeAnimationFinish() {
// }
//
// override fun isSupportSplashClickEye(isSupport: Boolean): Boolean {
// var dp = it.splashClickEyeSizeToDp
//
// // 点睛相关处理
// val minWindowSizeFromSdk: IntArray = it.getSplashClickEyeSizeToDp()
// val flContent=it.splashView
// val params: ViewGroup.LayoutParams = flContent.getLayoutParams() as ViewGroup.LayoutParams
// params.height = UIUtils.dp2px(activity, minWindowSizeFromSdk[1].toFloat())
// params.width = UIUtils.dp2px(activity, minWindowSizeFromSdk[0].toFloat())
// flContent.setLayoutParams(params)
// flContent.setBackgroundResource(R.color.common_half_alpha)
// flContent.translationX = 200f
// flContent.translationY = 200f
// it.splashClickEyeAnimationFinish()
// return false
// }
// })
// it.setSplashCardListener(object : ISplashCardListener {
// override fun onSplashEyeReady() {
// it.splashClickEyeAnimationFinish()
// }
//
// override fun onSplashClickEyeClose() {
// adStatusListener?.adClose(null)
// }
//
// override fun setSupportSplashClickEye(isSupport: Boolean) {
// }
//
// override fun getActivity(): Activity {
// return activity
// }
//
// })
view.addView(it.splashView)
}
} else {
LogUtil.d(
TAG,
"gromore 开屏广告--> 准备调用show 失败 mTTSplashAd=${mTTSplashAd} isLoadSuccess=${isLoadSuccess}"
)
adStatusListener?.adFail()
}
// 状态重置
isLoadSuccess = 0
}
/**
* 广告是否加载成功
*/
fun isSuccessStatus() = isLoadSuccess == 2
val adInteractionListener = object : TTSplashAd.AdInteractionListener {
override fun onAdClicked(p0: View?, p1: Int) {
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdClicked ")
}
override fun onAdShow(p0: View?, p1: Int) {
isShowAd = true
LogUtil.d(TAG, "gromore 开屏广告--> 6、onAdShow ")
mTTSplashAd?.let {
if (it.mediationManager != null && it.mediationManager.showEcpm != null&& it.mediationManager.showEcpm.ecpm != null) {
val vo = HashMap<String, Any>()
vo["cpmFen"] = it.mediationManager.showEcpm.ecpm
vo["adType"] = Constant.GRO_MORE_ADTYPE0
TrackManager.getInstance().cmtEcpm(vo)
}
}
}
override fun onAdSkip() {
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdSkip ")
adStatusListener?.adClose(null)
}
override fun onAdTimeOver() {
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdDismiss ")
adStatusListener?.adClose(null)
}
}
/**
* 是否展示广告
*/
fun getAdStatus() = isShowAd
}
\ No newline at end of file
package com.duben.duoduoplayletu.ad.video;
import android.app.Activity;
import android.os.Bundle;
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.TTRewardVideoAd;
import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot;
import com.duben.duoduoplayletu.BuildConfig;
import com.duben.duoduoplayletu.ad.AdManager;
import com.duben.duoduoplayletu.ad.AdStatusListener;
import com.duben.duoduoplayletu.common.Constant;
import com.duben.duoduoplayletu.manager.TrackManager;
import com.duben.duoduoplayletu.utils.AppPreferencesManager;
import com.duben.duoduoplayletu.utils.LogUtil;
import com.duben.duoduoplayletu.utils.TimeRender;
import java.lang.ref.WeakReference;
import java.util.HashMap;
/**
* GroMore激励视频广告
* <p>
* 注意*****这个类有预加载逻辑,不能复用
*/
public class InMoneyVideo {
private static final String TAG = InMoneyVideo.class.getSimpleName();
private static InMoneyVideo _inst;
public static InMoneyVideo getInstance() {
if (_inst == null) {
_inst = new InMoneyVideo();
}
return _inst;
}
private InMoneyVideo() {
}
private String carrierType = "";
// 当前播放的广告
private String nowAdcode = "";
private String nowEcpm = "";
private String nowAdSource = "";
private int isLoadSuccess = 0; // 0-加载失败/未加载 1-加载中 2-加载成功
private long adLoadTime = 0; // 广告展示时间,45分钟后当前广告失效,重新预加载广告
private long adPreingTime = 0; // 防止预加载超时 2分钟
private TTRewardVideoAd mttRewardAd;
private WeakReference<Activity> weakActivity;
private boolean isPreLoad = false;//是否是预加载调用,需要躲避监听
private AdStatusListener adStatusListener;
/**
* 激励视频
*/
public void preLoadAd(Activity activity, boolean isPreLoad) {
this.isPreLoad = isPreLoad;
boolean isOversped = TimeRender.INSTANCE.isOverspedMin(adLoadTime, AdManager.AD_NO_SHOWTIME_OUT);
boolean isPreingOversped = TimeRender.INSTANCE.isOverspedMin(adPreingTime, AdManager.AD_REQUEST_TIME_OUT);
this.weakActivity = new WeakReference(activity);
LogUtil.d(TAG, "gromore预加载 激励视频广告-> 1、进入预加载 isPreLoad[为true是预加载调用]=" + isPreLoad);
if ((isLoadSuccess == 0 // 加载失败
|| (adLoadTime > 0 && isOversped) // 超过45分钟
|| (adPreingTime > 0 && isPreingOversped
&& isLoadSuccess == 1)) // 预加载超时
&& this.weakActivity.get() != null) {
adPreingTime = System.currentTimeMillis();
isLoadSuccess = 1;
LogUtil.d(TAG, "gromore预加载 激励视频广告-> 2、执行预加载去了=" + isLoadSuccess);
preLoadAd(activity);
}
}
public void showRewardAd(Activity _activity, AdStatusListener adStatusListener
, String carrier) {
this.carrierType = carrier;
this.adStatusListener = adStatusListener;
this.weakActivity = new WeakReference(_activity);
if (isLoadSuccess == 0) {
LogUtil.e(TAG, "gromore预加载 激励视频广告--> showRewardAd isLoadSuccess=" + isLoadSuccess);
if (this.adStatusListener != null)
this.adStatusListener.adFail();
return;
}
// 请求未超过1分钟且上一个广告还在异步加载中,这次触发展示广告回调还没回来则返回
boolean isPreingOversped = TimeRender.INSTANCE.isOverspedMin(adPreingTime, AdManager.AD_REQUEST_TIME_OUT);
if (isLoadSuccess == 1 && isPreingOversped) {
LogUtil.e(TAG, "gromore预加载 激励视频广告-->请求未超过1分钟且上一个广告还在异步加载中 isLoadSuccess=" + isLoadSuccess + " isPreingOversped=" + isPreingOversped);
if (this.adStatusListener != null)
this.adStatusListener.adFail();
return;
}
// 预加载广告成功 且 预加载广告时长未超过45分钟
boolean isOversped = TimeRender.INSTANCE.isOverspedMin(adLoadTime, AdManager.AD_NO_SHOWTIME_OUT);
if (isLoadSuccess == 2 && !isOversped && mttRewardAd != null
&& mttRewardAd.getMediationManager().isReady()
&& this.weakActivity.get() != null) {
mttRewardAd.showRewardVideoAd(weakActivity.get());
mttRewardAd.setRewardAdInteractionListener(mTTRewardedAdListener);
} else {
if (this.adStatusListener != null)
this.adStatusListener.adFail();
LogUtil.e(TAG, "gromore预加载 激励视频广告--> 5、展示广告时失败了,广告可能超时45分钟 onError ");
}
// 广告加载完成状态重置
isLoadSuccess = 0;
}
private void preLoadAd(Activity activity) {
TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(activity);
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_VIDEO_CODE)
.setUserID("")
.setOrientation(TTAdConstant.VERTICAL)
.setMediationAdSlot(
new MediationAdSlot.Builder()
.setRewardAmount(2000)
.setRewardName("")
.build()
).build();
adNativeLoader.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
@Override
public void onError(int i, String s) {
isLoadSuccess = 0;
LogUtil.e(TAG, "gromore预加载 激励视频广告-->onError " + i + s + "isPreLoad[为true是预加载调用]=" + isPreLoad);
// isPreLoad=true 表示是预加载调用 不需要调用监听回调
if (!isPreLoad) {
if (adStatusListener != null) {
adStatusListener.adFail();
}
}
isPreLoad = false;
}
@Override
public void onRewardVideoAdLoad(TTRewardVideoAd ttRewardVideoAd) {
}
@Override
public void onRewardVideoCached() {
}
@Override
public void onRewardVideoCached(TTRewardVideoAd ttRewardVideoAd) {
LogUtil.d(TAG, "gromore预加载 激励视频广告--> 4、onRewardVideoCached ");
isLoadSuccess = 2;
adLoadTime = System.currentTimeMillis();
if (adStatusListener != null) {
adStatusListener.adSuccess();
}
mttRewardAd = ttRewardVideoAd;
}
});
}
private final TTRewardVideoAd.RewardAdInteractionListener mTTRewardedAdListener = new TTRewardVideoAd.RewardAdInteractionListener() {
@Override
public void onAdShow() {
if (mttRewardAd != null) {
if (mttRewardAd.getMediationManager() != null && mttRewardAd.getMediationManager().getShowEcpm() != null) {
nowAdcode = mttRewardAd.getMediationManager().getShowEcpm().getSlotId();
nowEcpm = mttRewardAd.getMediationManager().getShowEcpm().getEcpm();
nowAdSource = mttRewardAd.getMediationManager().getShowEcpm().getSdkName();
HashMap<String, Object> vo = new HashMap<>();
vo.put("adType", Constant.GRO_MORE_ADTYPE2);
vo.put("ecpm", nowEcpm);
TrackManager.getInstance().cmtEcpm(vo);
}
}
LogUtil.d(TAG, "gromore预加载 激励视频广告-->onAdShow");
if (weakActivity.get() != null) {
LogUtil.d(TAG, "gromore预加载 激励视频广告->onAdShow 触发预加载下次广告");
AdManager.Companion.getInstance().preLoadAd(weakActivity.get(), true);
}
}
@Override
public void onAdVideoBarClick() {
LogUtil.d(TAG, "gromore预加载 激励视频广告-->onAdVideoBarClick");
}
@Override
public void onAdClose() {
LogUtil.d(TAG, "gromore预加载 激励视频广告-->onAdClose");
HashMap<String, Object> vo = new HashMap<>();
vo.put("adcode", nowAdcode);
vo.put("ecpm", nowEcpm);
vo.put("adSource", nowAdSource);
vo.put("carrierType", carrierType);
vo.put("adid", BuildConfig.GROMORE_VIDEO_CODE);
if (adStatusListener != null) {
adStatusListener.adClose(vo);
}
adStatusListener = null;
}
@Override
public void onVideoComplete() {
LogUtil.d(TAG, "gromore预加载 激励视频广告-->onVideoComplete");
}
@Override
public void onVideoError() {
isLoadSuccess = 0;
LogUtil.e(TAG, "gromore预加载 激励视频广告-->onVideoError");
if (adStatusListener != null) {
adStatusListener.adFail();
}
}
@Override
public void onRewardVerify(boolean b, int i, String s, int i1, String s1) {
}
@Override
public void onRewardArrived(boolean b, int i, Bundle bundle) {
}
@Override
public void onSkippedVideo() {
}
};
}
package com.duben.duoduoplayletu.ad.video;
import android.app.Activity;
import android.os.Bundle;
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.TTRewardVideoAd;
import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot;
import com.duben.duoduoplayletu.BuildConfig;
import com.duben.duoduoplayletu.ad.AdManager;
import com.duben.duoduoplayletu.ad.AdStatusListener;
import com.duben.duoduoplayletu.common.Constant;
import com.duben.duoduoplayletu.manager.TrackManager;
import com.duben.duoduoplayletu.utils.AppPreferencesManager;
import com.duben.duoduoplayletu.utils.LogUtil;
import java.lang.ref.WeakReference;
import java.util.HashMap;
/**
* **实时加载
* <p>
* 应用内-GroMore激励视频广告
*/
public class InMoneyVideoNoPre {
private static final String TAG = InMoneyVideoNoPre.class.getSimpleName();
private static InMoneyVideoNoPre _inst;
public static InMoneyVideoNoPre getInstance() {
if (_inst == null) {
_inst = new InMoneyVideoNoPre();
}
return _inst;
}
private InMoneyVideoNoPre() {
}
private String carrierType = "";
// 当前播放的广告
private String nowAdcode = "";
private String nowEcpm = "";
private String nowAdSource = "";
private TTRewardVideoAd mttRewardAd;
private WeakReference<Activity> weakActivity;
private AdStatusListener adStatusListener;
/**
* 激励视频
*/
public void loadAd(Activity _activity, AdStatusListener adStatusListener, String carrier) {
this.carrierType = carrier;
this.adStatusListener = adStatusListener;
this.weakActivity = new WeakReference(_activity);
preLoadAd(_activity);
}
private void preLoadAd(Activity activity) {
TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(activity);
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_VIDEO_CODE)
.setUserID("")
.setOrientation(TTAdConstant.VERTICAL)
.setMediationAdSlot(
new MediationAdSlot.Builder()
.setRewardAmount(2000)
.setRewardName("")
.build()
).build();
adNativeLoader.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
@Override
public void onError(int i, String s) {
LogUtil.e(TAG, "gromore实时加载 激励视频广告-->onError " + i + s);
if (adStatusListener != null) {
adStatusListener.adFail();
}
}
@Override
public void onRewardVideoAdLoad(TTRewardVideoAd ttRewardVideoAd) {
}
@Override
public void onRewardVideoCached() {
}
@Override
public void onRewardVideoCached(TTRewardVideoAd ttRewardVideoAd) {
LogUtil.d(TAG, "gromore实时加载 激励视频广告--> 4、onRewardVideoCached");
mttRewardAd = ttRewardVideoAd;
if (mttRewardAd != null && weakActivity != null && mttRewardAd.getMediationManager().isReady()) {
mttRewardAd.setRewardAdInteractionListener(mTTRewardedAdListener);
mttRewardAd.showRewardVideoAd(weakActivity.get());
} else {
LogUtil.e(TAG, "gromore实时加载 onRewardVideoCached onError ");
if (adStatusListener != null) {
adStatusListener.adFail();
}
}
}
});
}
private final TTRewardVideoAd.RewardAdInteractionListener mTTRewardedAdListener = new TTRewardVideoAd.RewardAdInteractionListener() {
@Override
public void onAdShow() {
if (adStatusListener != null) {
adStatusListener.adSuccess();
}
if (mttRewardAd != null) {
if (mttRewardAd.getMediationManager() != null && mttRewardAd.getMediationManager().getShowEcpm() != null) {
nowAdcode = mttRewardAd.getMediationManager().getShowEcpm().getSlotId();
nowEcpm = mttRewardAd.getMediationManager().getShowEcpm().getEcpm();
nowAdSource = mttRewardAd.getMediationManager().getShowEcpm().getSdkName();
HashMap<String, Object> vo = new HashMap<>();
vo.put("adType", Constant.GRO_MORE_ADTYPE2);
vo.put("ecpm", nowEcpm);
TrackManager.getInstance().cmtEcpm(vo);
}
}
LogUtil.d(TAG, "gromore实时加载 激励视频广告-->onAdShow");
// 预加载
if (weakActivity.get() != null) {
LogUtil.d(TAG, "gromore实时加载 激励视频广告->onAdShow 触发预加载下次广告");
AdManager.Companion.getInstance().preLoadAd(weakActivity.get(), true);
}
}
@Override
public void onAdVideoBarClick() {
}
@Override
public void onAdClose() {
LogUtil.d(TAG, "gromore实时加载 激励视频广告-->onAdClose nowAdcode=" + nowAdcode);
HashMap<String, Object> vo = new HashMap<>();
vo.put("adcode", nowAdcode);
vo.put("ecpm", nowEcpm);
vo.put("adSource", nowAdSource);
vo.put("carrierType", carrierType);
vo.put("adid", BuildConfig.GROMORE_VIDEO_CODE);
if (adStatusListener != null) {
adStatusListener.adClose(vo);
}
adStatusListener = null;
}
@Override
public void onVideoComplete() {
LogUtil.d(TAG, "gromore实时加载 激励视频广告-->onVideoComplete");
}
@Override
public void onVideoError() {
if (adStatusListener != null) {
adStatusListener.adFail();
}
LogUtil.e(TAG, "gromore实时加载 激励视频广告-->onVideoError");
}
@Override
public void onRewardVerify(boolean b, int i, String s, int i1, String s1) {
}
@Override
public void onRewardArrived(boolean b, int i, Bundle bundle) {
}
@Override
public void onSkippedVideo() {
}
};
}
package com.duben.duoduoplayletu.common;
/**
* 描述:配置app设置开关
* 作者:孟崔广
* 时间:2023/06/22 17:51
*/
public class AppConfig {
/**
* 是否正在执行更新
*/
public static boolean app_updateing = false;
/**
* app应用首页 0-主页 1-position 2-我
*/
public static int fragmentClickFlag = 0;
public static int vedioId = 0;
// 退出登录首页刷新
public static boolean exitLoginMainRefresh = false;
// 进入过支付界面
public static boolean enterVipAct = false;
public static boolean enterAlipay = false;
public static boolean showVipVedio = false;
public static boolean showVipAdDialog = false;
public static String detailDialogUnlockText = "";
public static long splashTime = 0L;
public static double firstVipPrice = 0.0;
}
package com.duben.duoduoplayletu.manager
import com.duben.duoduoplayletu.common.DeviceInfo
/**
* 描述:模拟器校验
* 作者:孟崔广
*/
object SimulatorManager {
/**
* 是否是模拟器 0-不是模拟器
*/
fun isEmulator(): Int {
try {
return if (DeviceInfo.instance.isEmulator()) 1 else 0
} catch (e: Exception) {
e.printStackTrace()
}
return 0
}
}
\ No newline at end of file
package com.duben.duoduoplayletu.mvp.views
interface BackCashView : BaseView {
fun reqfundSuc()
fun reqfundFail(msg: String)
}
\ No newline at end of file
This diff is collapsed.
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