直接翻页 也计数广告显示逻辑
This commit is contained in:
parent
5d49ce6a96
commit
0ffbda3334
|
|
@ -19,7 +19,6 @@ import com.ama.core.architecture.highlightpro.parameter.MarginOffset
|
|||
import com.ama.core.architecture.highlightpro.shape.OvalShape
|
||||
import com.ama.core.architecture.util.ResUtil
|
||||
import com.ama.core.architecture.util.ResUtil.dp
|
||||
import com.ama.core.architecture.util.SpUtil
|
||||
import com.ama.core.architecture.util.setStatusBarDarkFont
|
||||
import com.ama.core.common.widget.PopMenuView
|
||||
import com.gamedog.statisticreporter.StatisticUtil
|
||||
|
|
@ -53,6 +52,9 @@ import com.gamedog.vididin.main.fragments.home.YoutubeUiState as UiState
|
|||
class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwitchTabListener, OnFragmentBackgroundListener {
|
||||
private var mWatchedVideoTotal = 0
|
||||
private var mSwipedVideoTotal = 0
|
||||
private var mLastShowedRewardedAd = true
|
||||
|
||||
|
||||
private var mHasShowGuide: Boolean = false
|
||||
private var mTotalMs: Long = 0L
|
||||
override val mViewModel: ViewModel by viewModels()
|
||||
|
|
@ -177,20 +179,37 @@ class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwit
|
|||
}
|
||||
|
||||
private fun handleEventOneVideoWatched() {
|
||||
mWatchedVideoTotal ++
|
||||
mWatchedVideoTotal++
|
||||
|
||||
val loopCount = VIDEO_NUM_GAP_FOR_AD_NORMAL + VIDEO_NUM_GAP_FOR_AD_REWARD
|
||||
val positionInCycle = mWatchedVideoTotal % loopCount
|
||||
if (mWatchedVideoTotal % VIDEO_NUM_GAP_FOR_AD_WATCHED == 0) {
|
||||
if (mLastShowedRewardedAd) {
|
||||
showInterstitialAd {}
|
||||
} else {
|
||||
handleShouldShowAdDialog()
|
||||
}
|
||||
|
||||
if (positionInCycle == 0) {
|
||||
handleShouldShowAdDialog()
|
||||
} else if (positionInCycle == VIDEO_NUM_GAP_FOR_AD_NORMAL) {
|
||||
showInterstitialAd {}
|
||||
// reset state
|
||||
mLastShowedRewardedAd = !mLastShowedRewardedAd
|
||||
mWatchedVideoTotal = 0
|
||||
mSwipedVideoTotal = 0
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleEventOneVideoSwiped() {
|
||||
// TODO
|
||||
mSwipedVideoTotal ++
|
||||
|
||||
if (mSwipedVideoTotal % VIDEO_NUM_GAP_FOR_AD_SWIPED == 0) {
|
||||
if (mLastShowedRewardedAd) {
|
||||
showInterstitialAd {}
|
||||
} else {
|
||||
handleShouldShowAdDialog()
|
||||
}
|
||||
|
||||
// reset state
|
||||
mLastShowedRewardedAd = !mLastShowedRewardedAd
|
||||
mWatchedVideoTotal = 0
|
||||
mSwipedVideoTotal = 0
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleWatchTimeTick() {
|
||||
|
|
@ -315,8 +334,8 @@ class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwit
|
|||
}
|
||||
|
||||
companion object {
|
||||
const val VIDEO_NUM_GAP_FOR_AD_NORMAL = 3
|
||||
const val VIDEO_NUM_GAP_FOR_AD_REWARD = 5
|
||||
const val VIDEO_NUM_GAP_FOR_AD_WATCHED = 3
|
||||
const val VIDEO_NUM_GAP_FOR_AD_SWIPED = 5
|
||||
|
||||
internal fun newInstance() = HomeFragment()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,9 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fun getVideoId(): String? {
|
||||
return mVideoData?.id
|
||||
}
|
||||
|
||||
fun loadVideo() {
|
||||
if (null == mPlayerView) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue