Commit 79677b7a authored by mengcuiguang's avatar mengcuiguang

gromore 降低快手sdk版本

parent 9e6d9c92
......@@ -369,5 +369,6 @@ dependencies {
// 广点通广告 腾讯
implementation(name: 'GDTSDK.unionNormal.4.351.1221', ext: 'aar')
// 快手
implementation(name: 'kssdk-all--3.3.16-publishRelease-9ffe2b94e', ext: 'aar')
implementation(name: 'kssdk-ad-3.3.9', ext: 'aar')
// implementation(name: 'kssdk-all--3.3.16-publishRelease-9ffe2b94e', ext: 'aar')
}
......@@ -10,14 +10,10 @@ 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
......@@ -26,6 +22,7 @@ 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
......@@ -43,6 +40,11 @@ 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
......@@ -62,11 +64,12 @@ 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
......@@ -78,10 +81,6 @@ 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
......@@ -126,7 +125,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
override fun onHiddenChanged(hidden: Boolean) {
ksFragment?.onHiddenChanged(hidden)
littleVideoFragment?.onHiddenChanged(hidden)
if (hidden) {
onPause()
......@@ -154,7 +153,8 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
}
ksFragment?.onResume()
registerPlayerCallBack()
littleVideoFragment?.onResume()
}
}
......@@ -170,13 +170,16 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun onPause() {
super.onPause()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
YLPlayerConfig.config().unRegisterPlayerCallback()
}
// 福袋动画停止
stopRedbox()
// 倒计时红包暂停
pauseDownloadTime()
destroyTimerRedbox()
ksFragment?.onPause()
littleVideoFragment?.onPause()
if (isToCreateReward) {
// 防止界面切换 重置红包动画
......@@ -189,7 +192,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
ksFragment?.userVisibleHint = isVisibleToUser
littleVideoFragment?.userVisibleHint = isVisibleToUser
}
override fun onDestroyView() {
......@@ -205,6 +208,9 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun onDestroy() {
super.onDestroy()
// 广告回调解绑
YLUIConfig.getInstance().unRegisterAdListener()
YLPlayerConfig.config().unRegisterPlayerCallback()
homePresenter.detachView()
}
......@@ -218,13 +224,6 @@ 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
}
......@@ -351,103 +350,70 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
/**
* 快手视频初始化
* 一览视频初始化
*/
private fun showLittle() {
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")
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
if (littleVideoFragment == null) {
littleVideoFragment = YLLittleVideoFragment.newInstance()
transaction.add(R.id.yilan_fragment_frame_container, littleVideoFragment!!, YLLittleVideoFragment::class.java.simpleName)
} else {
transaction.show(ksFragment!!)
transaction.show(littleVideoFragment!!)
}
transaction.commitAllowingStateLoss()
}
private fun registerPlayerCallBack() {
mKsContentPage?.let {
it.setPageListener(object : KsContentPage.PageListener {
override fun onPagePause(p0: KsContentPage.ContentItem?) {
LogUtil.d("onPagePause")
}
override fun onPageResume(p0: KsContentPage.ContentItem?) {
LogUtil.d("onPageResume")
}
override fun onPageEnter(p0: KsContentPage.ContentItem?) {
LogUtil.d("onPageEnter")
}
override fun onPageLeave(p0: KsContentPage.ContentItem?) {
LogUtil.d("onPageLeave")
}
})
// 视频播放回调
it.setVideoListener(object : KsContentPage.VideoListener {
override fun onVideoPlayCompleted(p0: KsContentPage.ContentItem?) {
LogUtil.d("onVideoPlayCompleted")
addVideoIdList(p0!!.id)
pauseDownloadTime()
YLPlayerConfig.config().registerPlayerCallBack(object : OnPlayerCallBack {
override fun onStart(pager: String, videoid: String, p2: String?) {
// 防止网络异常时, 第一次加载倒计时红包
if (isFirstLoadVideo) {
isFirstLoadVideo = false
initTimeview()
} else {
resumeDownloadTime(videoid)
}
}
override fun onVideoPlayPaused(p0: KsContentPage.ContentItem?) {
LogUtil.d("onVideoPlayPaused")
override fun onPause(pager: String, p1: String?, p2: String?) {
pauseDownloadTime()
}
override fun onResume(pager: String, videoid: String, p2: String?) {
resumeDownloadTime(videoid)
}
pauseDownloadTime()
}
override fun onComplete(pager: String, videoid: String, p2: String?) {
override fun onVideoPlayStart(p0: KsContentPage.ContentItem?) {
LogUtil.d("onVideoPlayStart")
}
// 防止网络异常时, 第一次加载倒计时红包
if (isFirstLoadVideo) {
isFirstLoadVideo = false
initTimeview()
} else {
resumeDownloadTime(p0!!.id)
}
}
override fun onLoopComplete(pager: String?, videoID: String, taskID: String?, num: Int) {
// LogUtil.d(TAG, "registerPlayerCallBack onLoopComplete")
addVideoIdList(videoID)
pauseDownloadTime()
}
override fun onVideoPlayError(p0: KsContentPage.ContentItem?, p1: Int, p2: Int) {
LogUtil.d("onVideoPlayError")
override fun onStuckStart(pager: String, p1: String?, p2: String?) {
}
pauseDownloadTime()
}
override fun onStuckEnd(pager: String, p1: String?, p2: String?) {
}
override fun onVideoPlayResume(p0: KsContentPage.ContentItem?) {
LogUtil.d("onVideoPlayResume")
override fun onError(pager: String, p1: String?, p2: String?) {
// 防止网络异常时, 第一次加载倒计时红包
if (isFirstLoadVideo) {
isFirstLoadVideo = false
initTimeview()
} else {
resumeDownloadTime(p0!!.id)
}
}
})
pauseDownloadTime()
}
}
override fun onStop(pager: String, p1: String?, p2: String?) {
// LogUtil.d(TAG, "registerPlayerCallBack onStop")
// pauseDownloadTime()
}
})
}
private fun initListener() {
val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
params.setMargins(0, 0, 0, BubbleUtils.dp2px(410))
params.setMargins(0, 0, 0, BubbleUtils.dp2px(270))
cdvvYilanTime.layoutParams = params
val paramsRedBox = FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT)
......@@ -458,14 +424,57 @@ 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中
......
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