Commit 61ea2bb2 authored by mengcuiguang's avatar mengcuiguang

优化好兔监听

parent 7b24a2d9
This diff is collapsed.
This diff is collapsed.
......@@ -49,9 +49,10 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
private var littleVideoFragment: YLLittleVideoFragment? = null
private val VEDIO_MAX_COUNT = 12 // 当前缓存视频id最大数
private val vedioIdList by lazy { ArrayList<String>() }//记录播放的视频id
private var isFirstLoadVedio = true // 首次加载视频初始化
private var isClickStop = false // 是否点击一览视频暂停
private var vedioId = "" // 视频id 记录界面切换时是否还给奖励
private var isToCreateReward = true // 是否还有剩余红包 服务器返回
private var isFirstLoadVedio = true // 首次加载视频初始化 本地判断
private var isAward = false // 是否可以领金币 本地判断
// 广告权重相关
private var vedioAdingManager: VedioAdingManager? = null
......@@ -105,9 +106,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
littleVideoFragment?.onResume()
if (!TextUtils.isEmpty(vedioId)) {
resumeDownloadTime(vedioId)
}
}
}
......@@ -121,7 +119,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
super.onPause()
littleVideoFragment?.onPause()
pauseDownloadTime()
// pauseDownloadTime()
}
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
......@@ -173,11 +171,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
homePresenter.getHomeVedioMsg()
}
override fun getHallBaseMsgFail() {
rewardCoin = 0
rewardDoubleCoin = 0
}
override fun getHomeVedioMsgSuc(data: MainVedioMsgBean) {
if (activity == null || requireActivity().isFinishing) {
return
......@@ -187,11 +180,12 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
rewardCoin = data.rewardCoin
rewardDoubleCoin = data.rewardDoubleCoin
isToCreateReward = data.isToCreateReward
if (data.isToCreateReward) {
if (isToCreateReward) {
// 防止界面切换 重置倒计时
// 第一次能过 isFirstLoadVedio 判断好兔先加载视频
if (!isFirstLoadVedio && !cdvvYilanTime.isPlaying) {
if (!isFirstLoadVedio && !cdvvYilanTime.isPlaying && !isAward) {
cdvvYilanTime?.reset()
cdvvYilanTime?.start()
}
......@@ -203,7 +197,9 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun onClick(v: View) {
when (v.id) {
R.id.cdvvYilanTime -> {
if (rewardCoin > 0) {
if (isAward && isToCreateReward) {
isAward = false
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, rewardCoin)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_HOMEVEDIO)
......@@ -228,21 +224,16 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
if (littleVideoFragment == null) {
littleVideoFragment = YLLittleVideoFragment.newInstance()
transaction.add(R.id.yilan_fragment_frame_container, littleVideoFragment!!, YLLittleVideoFragment::class.java.simpleName)
// 设置点击的item播放状态,callback返回true标识用户已经处理了event,返回false,标识使用播放器内部逻辑处理event。
YLPlayerConfig.config().registerPlayerCallBack(object : OnPlayerCallBack {
override fun onStart(p0: String?, videoid: String, p2: String?) {
// 防止网络异常时, 第一次加载倒计时红包
if (isFirstLoadVedio) {
isFirstLoadVedio = false
initTimeview()
}else{
} else {
resumeDownloadTime(videoid)
}
vedioId = videoid
LogUtil.d(TAG,"onStart videoid:${videoid}")
LogUtil.d(TAG, "onStart videoid:${videoid}")
}
override fun onPause(p0: String?, p1: String?, p2: String?) {
......@@ -260,7 +251,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun onLoopComplete(pager: String?, videoID: String, taskID: String?, num: Int) {
addVedioIdList(videoID)
pauseDownloadTime()
LogUtil.d(TAG,"onLoopComplete pager:${pager} videoID:${videoID} taskID:${taskID} num:${num}")
LogUtil.d(TAG, "onLoopComplete pager:${pager} videoID:${videoID} taskID:${taskID} num:${num}")
}
override fun onStuckStart(p0: String?, p1: String?, p2: String?) {
......@@ -298,7 +289,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
* 倒计时红包暂停
*/
private fun pauseDownloadTime() {
isClickStop = true
cdvvYilanTime?.pause()
}
......@@ -312,8 +302,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
return
}
if (isClickStop) {
isClickStop = false
if (!isAward) {
cdvvYilanTime?.resume()
}
}
......@@ -324,7 +313,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
*/
private fun stopDownloadTime() {
// 暂停
isClickStop = true
cdvvYilanTime?.stop()
}
......@@ -342,6 +330,8 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
isFristWacthVideo = false
}
// 转满一圈,可领金币标记
isAward = true
cdvvYilanTime?.showRedbox()
stopDownloadTime()
}
......
package com.mints.goodmoney.utils;
public class URIEncoder {
}
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