Commit 96064363 authored by jyx's avatar jyx

好兔更换快手内容联盟,添加高额任务权重逻辑

parent 17ae2018
......@@ -263,9 +263,9 @@ dependencies {
implementation(name: 'xrsdk-release_tbs', ext: 'aar')
implementation(name: 'xrsharesdk-release_tbs', ext: 'aar')
implementation(name: 'windAd-2.25.0', ext: 'aar')
implementation 'com.scwang.smart:refresh-layout-kernel:2.0.3'
implementation 'com.scwang.smart:refresh-header-classics:2.0.3'
implementation 'com.scwang.smart:refresh-footer-classics:2.0.3'
implementation 'com.scwang.smart:refresh-layout-kernel:2.0.3'
implementation 'com.scwang.smart:refresh-header-classics:2.0.3'
implementation 'com.scwang.smart:refresh-footer-classics:2.0.3'
// 枫岚
implementation(name: 'mh-adsdk', ext: 'aar')
implementation(name: 'mh-adsdk-ext', ext: 'aar')
......@@ -287,7 +287,7 @@ dependencies {
implementation(name: 'tzsdk_core-3.0.0-20200807131516-release', ext: 'aar')
implementation(name: 'tzsdk_reporter-3.0.0-20200807131516-release', ext: 'aar')
// 快手
implementation(name: 'kssdk-ad-3.3.6-publishRelease', ext: 'aar')
implementation(name: 'kssdk-all--3.3.16-publishRelease-9ffe2b94e', ext: 'aar')
// 抖音滑动LayoutManager
implementation(name: 'LayoutManagerGroup', ext: 'aar')
// 蘑菇星球
......@@ -327,7 +327,7 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutinesVersion"
implementation "com.google.dagger:hilt-android:$rootProject.hiltVersion"
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.zhpanvip:BannerViewPager:3.2.0'
api "androidx.navigation:navigation-fragment-ktx:$navigationVersion"
......@@ -347,8 +347,8 @@ dependencies {
implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:4.4.3'
api 'org.aspectj:aspectjrt:1.9.5'
//小满
implementation ("com.bx:adsdk:1.4.2.2"){
exclude group:"com.miit.sdk"
implementation("com.bx:adsdk:1.4.2.2") {
exclude group: "com.miit.sdk"
transitive = true
changing = true
}
......
package com.mints.goodmoney.ad.express
import android.annotation.SuppressLint
import android.content.DialogInterface
import android.text.TextUtils
import android.util.Log
import android.view.LayoutInflater
......@@ -95,7 +96,7 @@ object KsPreLoadExpressManager {
}
override fun onVideoPlayError(what: Int, extra: Int) {
LogUtil.d("KsPreLoadExpressManager","id=${what} extra=${extra}")
LogUtil.d("KsPreLoadExpressManager", "id=${what} extra=${extra}")
}
})
......@@ -191,6 +192,10 @@ object KsPreLoadExpressManager {
// Toast.makeText(mContext, "广告" + ad.appName + "展示", Toast.LENGTH_SHORT).show()
}
}
override fun handleDownloadDialog(p0: DialogInterface.OnClickListener?): Boolean {
return false
}
})
// 广告描述
......
......@@ -120,6 +120,8 @@ class KsVideoAdManager private constructor(activity: Activity) :
}
}
override fun onRequestResult(p0: Int) {}
})
......
......@@ -6,8 +6,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.text.TextUtils;
import com.mints.goodmoney.MintsApplication;
import com.mints.goodmoney.ad.video.base.VideoAdStatusListener;
import com.mints.goodmoney.common.AppConfig;
import com.mints.goodmoney.common.Constant;
......@@ -17,8 +15,6 @@ import com.mints.goodmoney.mvp.model.WeightBean;
import com.mints.goodmoney.service.AppInstallService;
import com.mints.goodmoney.utils.AppUtil;
import com.mints.goodmoney.utils.LogUtil;
import com.mints.goodmoney.utils.ToastUtil;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashSet;
......@@ -64,8 +60,6 @@ public class VideoAdingManager {
// 是否是高额视频任务
private boolean isHighWeight = false;
private boolean isTTVideoAd = false;
private int highIndex = 0;//0-穿山甲 1-优量汇 2-快手
private Activity activity;
private boolean isVideoAdDownload = false;// 是否点击广告下载 true-点击
......@@ -235,31 +229,52 @@ public class VideoAdingManager {
/**
* 高额任务广告类型
*
* @return _
* @return
*/
private String getHighWeight() {
// isTTVideoAd = !isTTVideoAd;
// if (isTTVideoAd) {
// return Constant.CSJ_VEDIO_AD;
// } else {
// return Constant.YLH_VEDIO_AD;
// }
String adType = "";
switch (highIndex) {
case 0:
highIndex = 1;
adType = Constant.CSJ_VEDIO_AD;
break;
case 1:
highIndex = 2;
adType = Constant.YLH_VEDIO_AD;
break;
case 2:
highIndex = 0;
adType = Constant.KS_VEDIO_AD;
break;
public String getHighWeight() {
int weight = 0;
if (weightList != null) {
weightList.clear();
}
return adType;
// 穿山甲
if (AppConfig.csjHighVideoAdCount > 0) {
weightList.add(new WeightBean(AppConfig.csjHighVideoAdCount, Constant.CSJ_VEDIO_AD));
weight = weight + AppConfig.csjHighVideoAdCount;
LogUtil.d(TAG, "高额任务 -> 权重值:csjVideoWeight:" + AppConfig.csjHighVideoAdCount);
}
// 优量汇
if (AppConfig.ylhHighVideoAdCount > 0) {
weightList.add(new WeightBean(AppConfig.ylhHighVideoAdCount, Constant.YLH_VEDIO_AD));
weight = weight + AppConfig.ylhHighVideoAdCount;
LogUtil.d(TAG, "高额任务 -> 权重值:ylhVideoWeight:" + AppConfig.ylhHighVideoAdCount);
}
// 快手
if (AppConfig.ksHighVideoAdCount > 0) {
weightList.add(new WeightBean(AppConfig.ksHighVideoAdCount, Constant.KS_VEDIO_AD));
weight = weight + AppConfig.ksHighVideoAdCount;
LogUtil.d(TAG, "高额任务 -> 权重值:ksVideoWeight:" + AppConfig.ksHighVideoAdCount);
}
// 权重随机
if (weightList != null && weightList.size() > 0 && weight > 0) {
LogUtil.d(TAG, "高额任务 -> 1、权重总值:" + weight);
Random r = new Random();
int randomWeight = r.nextInt(weight) + 1;
LogUtil.d(TAG, "高额任务 -> 2、权重随机值:" + randomWeight);
for (WeightBean weightBean : weightList) {
randomWeight -= weightBean.getWeight();
if (randomWeight <= 0) {
LogUtil.d(TAG, "高额任务 -> 3、权重结果:" + weightBean.getType());
return weightBean.getType();
}
}
}
return Constant.CSJ_VEDIO_AD;
}
/**
......
......@@ -100,6 +100,20 @@ public class AppConfig {
* rtaVideo 剩余广告播放数
*/
public static int rtaVideoAdCount = 0;
/**
* 高额任务和超级翻倍 csjVideo 剩余广告播放数
*/
public static int csjHighVideoAdCount = 0;
/**
* 高额任务和超级翻倍 ylhVideo 剩余广告播放数
*/
public static int ylhHighVideoAdCount = 0;
/**
* 高额任务和超级翻倍 ksVideo 剩余广告播放数
*/
public static int ksHighVideoAdCount = 0;
/**
* 高额试玩任务标识
......
......@@ -23,6 +23,9 @@ object KsManager {
/* vedio-postid */
const val KS_AD_VEDIO_POSTID = 5746000022
/* 内容联盟id */
const val KS_CONTENT_POSTID = 5746000049
/**
* 初始化
*/
......
......@@ -13,6 +13,7 @@ public class UserTaskMsgBean implements Serializable {
private UserRiskAppsBean userRiskApps;
private AdcodeBean adcode_v1 = null;
private FlowAdRulesBean flowAdRules;
private HighRatePlanBean highRatePlan;
private String ip;
private String channel;
......@@ -135,4 +136,30 @@ public class UserTaskMsgBean implements Serializable {
public FlowAdRulesBean getFlowAdRules() {
return flowAdRules;
}
public HighRatePlanBean getHighRatePlan() {
return highRatePlan;
}
public void setHighRatePlan(HighRatePlanBean highRatePlan) {
this.highRatePlan = highRatePlan;
}
public static class HighRatePlanBean implements Serializable {
private int YLH;
private int KS;
private int CSJ;
public int getYLH() {
return YLH;
}
public int getKS() {
return KS;
}
public int getCSJ() {
return CSJ;
}
}
}
......@@ -425,6 +425,7 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
// 是否开启应用使用情况权限
if (AppUtil.isOpenUsageStats()) {
registerBroad()
videoAdingManager.setIsHighWeight(true)
awardVideo()
} else {
AppTryPlayManager.openAppUsageStats(this)
......
......@@ -29,6 +29,7 @@ class SplashKsADActivity : BaseActivity() {
* 记录拉取广告的时间
*/
private val handler = Handler(Looper.getMainLooper())
override fun getContentViewLayoutID(): Int {
return R.layout.activity_splash_ylh
}
......@@ -100,6 +101,8 @@ class SplashKsADActivity : BaseActivity() {
next()
}
override fun onRequestResult(p0: Int) {}
override fun onSplashScreenAdLoad(p0: KsSplashScreenAd?) {
LogUtil.d(TAG, "onSplashScreenAdLoad")
......
......@@ -10,10 +10,14 @@ import android.view.Gravity
import android.view.View
import android.widget.FrameLayout
import android.widget.LinearLayout
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.daimajia.androidanimations.library.YoYo.YoYoString
import com.kwad.sdk.api.KsAdSDK
import com.kwad.sdk.api.KsContentPage
import com.kwad.sdk.api.KsScene
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.express.PreLoadExpressManager
......@@ -22,7 +26,6 @@ import com.mints.goodmoney.ad.video.VideoAdingManager
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.*
import com.mints.goodmoney.mvp.model.BaseResponse
import com.mints.goodmoney.mvp.model.FlowAdRulesBean
import com.mints.goodmoney.mvp.model.MainVideoMsgBean
import com.mints.goodmoney.mvp.model.UserTaskMsgBean
......@@ -40,11 +43,6 @@ import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.TimeRender
import com.mints.library.utils.CommonUtils
import com.yilan.sdk.player.ylplayer.YLPlayerConfig
import com.yilan.sdk.player.ylplayer.callback.OnPlayerCallBack
import com.yilan.sdk.ui.configs.YLUIConfig
import com.yilan.sdk.ui.little.YLLittleVideoFragment
import com.yilan.sdk.ylad.YLAdListener
import kotlinx.android.synthetic.main.layout_red_bag.*
import kotlinx.android.synthetic.main.layout_red_box.*
import net.grandcentrix.tray.AppPreferences
......@@ -64,12 +62,11 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
private var bindWxDialog: BindWxDialog? = null
private var userMsgBean: UserTaskMsgBean? = null
private lateinit var baseResponse: BaseResponse<UserTaskMsgBean>
// private lateinit var baseResponse: BaseResponse<UserTaskMsgBean>
// 视频相关
private var rewardDoubleCoin = 0 // 大金币
private var rewardCoin = 0 // 小金币
private var littleVideoFragment: YLLittleVideoFragment? = null
private val videoMaxCount = 12 // 当前缓存视频id最大数
private val videoIdList by lazy { ArrayList<String>() }//记录播放的视频id
......@@ -81,6 +78,10 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
// 广告权重相关
private var videoAdingManager: VideoAdingManager? = null
// 快手视频相关
private var ksFragment: Fragment? = null
private var mKsContentPage: KsContentPage? = null
// 福袋相关
private var rope: YoYoString? = null
private var mRedBoxTimer: CountDownTimerSupport? = null
......@@ -125,7 +126,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
override fun onHiddenChanged(hidden: Boolean) {
littleVideoFragment?.onHiddenChanged(hidden)
ksFragment?.onHiddenChanged(hidden)
if (hidden) {
onPause()
......@@ -153,8 +154,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
}
registerPlayerCallBack()
littleVideoFragment?.onResume()
ksFragment?.onResume()
}
}
......@@ -170,16 +170,13 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun onPause() {
super.onPause()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
YLPlayerConfig.config().unRegisterPlayerCallback()
}
// 福袋动画停止
stopRedbox()
// 倒计时红包暂停
pauseDownloadTime()
destroyTimerRedbox()
littleVideoFragment?.onPause()
ksFragment?.onPause()
if (isToCreateReward) {
// 防止界面切换 重置红包动画
......@@ -192,7 +189,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
littleVideoFragment?.userVisibleHint = isVisibleToUser
ksFragment?.userVisibleHint = isVisibleToUser
}
override fun onDestroyView() {
......@@ -208,9 +205,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun onDestroy() {
super.onDestroy()
// 广告回调解绑
YLUIConfig.getInstance().unRegisterAdListener()
YLPlayerConfig.config().unRegisterPlayerCallback()
homePresenter.detachView()
}
......@@ -224,6 +218,13 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
userMsgBean = data
// 高额任务及超级翻倍次数
if (data.highRatePlan != null) {
AppConfig.csjHighVideoAdCount = data.highRatePlan.csj
AppConfig.ylhHighVideoAdCount = data.highRatePlan.ylh
AppConfig.ksHighVideoAdCount = data.highRatePlan.ks
}
if (userMsgBean?.shareNews != null) {
AppConfig.wzReadCoin = userMsgBean!!.shareNews.readCoin
}
......@@ -350,70 +351,103 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
/**
* 一览视频初始化
* 快手视频初始化
*/
private fun showLittle() {
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
if (littleVideoFragment == null) {
littleVideoFragment = YLLittleVideoFragment.newInstance()
transaction.add(R.id.yilan_fragment_frame_container, littleVideoFragment!!, YLLittleVideoFragment::class.java.simpleName)
val adScene = KsScene.Builder(KsManager.KS_CONTENT_POSTID).build()
mKsContentPage = KsAdSDK.getLoadManager().loadContentPage(adScene)
registerPlayerCallBack()
val transaction: FragmentTransaction = childFragmentManager.beginTransaction()
if (ksFragment == null) {
ksFragment = mKsContentPage?.fragment
transaction.add(R.id.yilan_fragment_frame_container, ksFragment!!, "ks_fragment")
} else {
transaction.show(littleVideoFragment!!)
transaction.show(ksFragment!!)
}
transaction.commitAllowingStateLoss()
}
private fun registerPlayerCallBack() {
YLPlayerConfig.config().registerPlayerCallBack(object : OnPlayerCallBack {
override fun onStart(pager: String, videoid: String, p2: String?) {
// 防止网络异常时, 第一次加载倒计时红包
if (isFirstLoadVideo) {
isFirstLoadVideo = false
initTimeview()
} else {
resumeDownloadTime(videoid)
mKsContentPage?.let {
it.setPageListener(object : KsContentPage.PageListener {
override fun onPagePause(p0: KsContentPage.ContentItem?) {
LogUtil.d("onPagePause")
}
}
override fun onPause(pager: String, p1: String?, p2: String?) {
pauseDownloadTime()
}
override fun onPageResume(p0: KsContentPage.ContentItem?) {
LogUtil.d("onPageResume")
}
override fun onResume(pager: String, videoid: String, p2: String?) {
resumeDownloadTime(videoid)
}
override fun onPageEnter(p0: KsContentPage.ContentItem?) {
LogUtil.d("onPageEnter")
override fun onComplete(pager: String, videoid: String, p2: String?) {
}
}
override fun onLoopComplete(pager: String?, videoID: String, taskID: String?, num: Int) {
// LogUtil.d(TAG, "registerPlayerCallBack onLoopComplete")
addVideoIdList(videoID)
pauseDownloadTime()
}
override fun onPageLeave(p0: KsContentPage.ContentItem?) {
LogUtil.d("onPageLeave")
}
})
override fun onStuckStart(pager: String, p1: String?, p2: String?) {
}
override fun onStuckEnd(pager: String, p1: String?, p2: String?) {
}
// 视频播放回调
it.setVideoListener(object : KsContentPage.VideoListener {
override fun onVideoPlayCompleted(p0: KsContentPage.ContentItem?) {
LogUtil.d("onVideoPlayCompleted")
override fun onError(pager: String, p1: String?, p2: String?) {
pauseDownloadTime()
}
addVideoIdList(p0!!.id)
pauseDownloadTime()
}
override fun onStop(pager: String, p1: String?, p2: String?) {
// LogUtil.d(TAG, "registerPlayerCallBack onStop")
// pauseDownloadTime()
}
})
override fun onVideoPlayPaused(p0: KsContentPage.ContentItem?) {
LogUtil.d("onVideoPlayPaused")
pauseDownloadTime()
}
override fun onVideoPlayStart(p0: KsContentPage.ContentItem?) {
LogUtil.d("onVideoPlayStart")
// 防止网络异常时, 第一次加载倒计时红包
if (isFirstLoadVideo) {
isFirstLoadVideo = false
initTimeview()
} else {
resumeDownloadTime(p0!!.id)
}
}
override fun onVideoPlayError(p0: KsContentPage.ContentItem?, p1: Int, p2: Int) {
LogUtil.d("onVideoPlayError")
pauseDownloadTime()
}
override fun onVideoPlayResume(p0: KsContentPage.ContentItem?) {
LogUtil.d("onVideoPlayResume")
// 防止网络异常时, 第一次加载倒计时红包
if (isFirstLoadVideo) {
isFirstLoadVideo = false
initTimeview()
} else {
resumeDownloadTime(p0!!.id)
}
}
})
}
}
private fun initListener() {
val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
params.setMargins(0, 0, 0, BubbleUtils.dp2px(270))
params.setMargins(0, 0, 0, BubbleUtils.dp2px(410))
cdvvYilanTime.layoutParams = params
val paramsRedBox = FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT)
......@@ -424,57 +458,14 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
rl_fragment_main_redbox.setOnClickListener(this)
rl_fragment_main_redbox.isClickable = false
// 广告回调
YLUIConfig.getInstance().registerAdListener(object : YLAdListener() {
override fun onSuccess(p0: String?, p1: Int, p2: String?, p3: String?) {
}
override fun onError(p0: String?, p1: Int, p2: String?, p3: Int, p4: String?, p5: String?) {
}
override fun onRenderError(p0: String?, p1: Int, p2: String?, p3: Int, p4: String?, p5: String?) {
}
override fun onShow(p0: String?, p1: Int, p2: String?, p3: String) {
resumeAdTime()
}
override fun onClick(p0: String?, p1: Int, p2: String?, p3: String?) {}
override fun onSkip(p0: String?, p1: Int, p2: String?, p3: String?) {}
override fun onTimeOver(p0: String?, p1: Int, p2: String?, p3: String?) {}
override fun onClose(p0: String?, p1: Int, p2: String?, p3: String?) {}
override fun onAdEmpty(p0: String?, p1: Int, p2: String?, p3: String?) {}
override fun onVideoStart(p0: String?, p1: Int, p2: String?, p3: String) {
}
override fun onVideoPause(p0: String?, p1: Int, p2: String?, p3: String?) {
pauseDownloadTime()
}
override fun onVideoResume(p0: String?, p1: Int, p2: String?, p3: String?) {
resumeAdTime()
}
override fun onVideoComplete(p0: String?, p1: Int, p2: String?, p3: String?) {
pauseDownloadTime()
}
override fun onVideoError(p0: String?, p1: Int, p2: String?, p3: String?) {}
})
}
private fun resumeAdTime() {
// 视频未转满 且 界面切换时可继续加进度
if (!isAward) {
cdvvYilanTime?.resume()
}
}
// private fun resumeAdTime() {
// // 视频未转满 且 界面切换时可继续加进度
// if (!isAward) {
// cdvvYilanTime?.resume()
// }
// }
/**
* 将播放的id记录到list中
......
......@@ -324,6 +324,13 @@ class MyFragment : BaseFragment(),
return
}
// 高额任务及超级翻倍次数
if (data.highRatePlan != null) {
AppConfig.csjHighVideoAdCount = data.highRatePlan.csj
AppConfig.ylhHighVideoAdCount = data.highRatePlan.ylh
AppConfig.ksHighVideoAdCount = data.highRatePlan.ks
}
if (data.shareNews != null) {
AppConfig.wzReadCoin = data.shareNews.readCoin
}
......
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