每日观看个数 task bean
This commit is contained in:
parent
6ea2af01fe
commit
f4aebf8e9c
|
|
@ -8,6 +8,6 @@ object VididinEvents {
|
|||
|
||||
|
||||
const val Event_HOME_WATCH_Time_TICK = 700
|
||||
const val Event_Finish_Video = 701
|
||||
const val Event_Finish_One_Video = 701
|
||||
|
||||
}
|
||||
|
|
@ -4,21 +4,20 @@ import com.ama.core.architecture.util.DateUtil
|
|||
import com.ama.core.architecture.util.SpUtil
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.manager.taskbeans.DailyStateWatchVideoBean
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
|
||||
|
||||
|
||||
class DailyWatchVideoTaskHelper : BaseTaskHelper() {
|
||||
|
||||
private var mStateBean: DailyStateWatchVideoBean? = null
|
||||
private val mWatchedMap = ConcurrentHashMap<String, Long>()
|
||||
|
||||
|
||||
init {
|
||||
registerEvents( { eventData->
|
||||
val dataPair: Pair<String, Long> = eventData?.mData as Pair<String, Long>
|
||||
addWatchedVideoInfo(dataPair)
|
||||
}, VididinEvents.Event_Finish_Video)
|
||||
handleVideoWatched(dataPair)
|
||||
}, VididinEvents.Event_Finish_One_Video)
|
||||
}
|
||||
|
||||
override fun loadTaskFromSp() {
|
||||
|
|
@ -32,6 +31,7 @@ class DailyWatchVideoTaskHelper : BaseTaskHelper() {
|
|||
|
||||
|
||||
private fun generateTodayTask() {
|
||||
mStateBean?.clearDatas()
|
||||
mStateBean = DailyStateWatchVideoBean(DateUtil.getCurTimeMs())
|
||||
}
|
||||
|
||||
|
|
@ -39,10 +39,13 @@ class DailyWatchVideoTaskHelper : BaseTaskHelper() {
|
|||
return mStateBean != null && DateUtil.isToday(mStateBean?.todayStartMs!!)
|
||||
}
|
||||
|
||||
private fun addWatchedVideoInfo(dataPair: Pair<String, Long>) {
|
||||
mWatchedMap.put(dataPair.first, dataPair.second)
|
||||
|
||||
private fun handleVideoWatched(dataPair: Pair<String, Long>) {
|
||||
mStateBean?.run {
|
||||
addWatchedVideoInfo(dataPair)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +1,32 @@
|
|||
package com.gamedog.vididin.manager.taskbeans
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
|
||||
data class DailyStateWatchVideoBean(
|
||||
var todayStartMs: Long = 0,
|
||||
var watchedVideoNum: Int = 0,
|
||||
): Serializable {
|
||||
|
||||
private val mWatchedMap = ConcurrentHashMap<String, Long>()
|
||||
|
||||
|
||||
|
||||
fun clearDatas() {
|
||||
mWatchedMap.clear()
|
||||
todayStartMs = 0
|
||||
}
|
||||
|
||||
fun addWatchedVideoInfo(dataPair: Pair<String, Long>): Boolean {
|
||||
if (!mWatchedMap.contains(dataPair.first)) {
|
||||
mWatchedMap.put(dataPair.first, dataPair.second)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class RewardConst {
|
|||
companion object {
|
||||
const val HOME_WATCH_DURATION = 5 * 1000L
|
||||
const val HOME_WATCH_REWARD_NUM = 28
|
||||
const val FINISH_RATIO = 0.1F // TODO - temp value, should be 0.8F
|
||||
const val FINISH_RATIO = 0.05F // TODO - temp value, should be 0.8F
|
||||
const val Check_Interval_MS = 50L
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.gamedog.vididin.youtubestatistic
|
|||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.SystemClock
|
||||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.youtubestatistic.RewardConst.Companion.Check_Interval_MS
|
||||
|
|
@ -53,7 +52,7 @@ class TickerTimer() {
|
|||
mTotalMs += Check_Interval_MS
|
||||
if (mTotalMs >= RewardConst.FINISH_RATIO * mVideoDurationMs) {
|
||||
mHasFinishCurVideo = true
|
||||
NotifyMan.instance().sendEvent(VididinEvents.Event_Finish_Video,
|
||||
NotifyMan.instance().sendEvent(VididinEvents.Event_Finish_One_Video,
|
||||
NotifyMan.NotifyData(Pair(mVideoId, System.currentTimeMillis())))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue