Compare commits
No commits in common. "d7be7c30cb6604048114fa8fc05c67e75b8301ef" and "114f7befbcf389542209e00a4f619422c5d7b269" have entirely different histories.
d7be7c30cb
...
114f7befbc
|
|
@ -10,11 +10,9 @@ object VididinEvents {
|
|||
const val Event_HOME_WATCH_Time_TICK = 700
|
||||
const val Event_Finish_One_Video = 701
|
||||
const val Event_Finish_One_Ad = 702
|
||||
const val Event_Finish_One_Sign = 703
|
||||
const val Event_Finish_One_Zerobuy = 704
|
||||
|
||||
const val EVENT_DAILY_WATCHED_VIDEO_NUM_CHANGED = 705
|
||||
const val EVENT_DAILY_WATCHED_AD_NUM_CHANGED = 706
|
||||
const val EVENT_DAILY_WATCHED_VIDEO_NUM_CHANGED = 703
|
||||
const val EVENT_DAILY_WATCHED_AD_NUM_CHANGED = 704
|
||||
|
||||
|
||||
|
||||
|
|
@ -23,6 +21,5 @@ object VididinEvents {
|
|||
const val Event_AD_TASK_TYPE_Watch_Ad_Daily = 802
|
||||
const val Event_AD_TASK_TYPE_Withdraw = 803
|
||||
const val Event_AD_TASK_TYPE_Complement = 804
|
||||
const val Event_AD_TASK_TYPE_BOX_TASK = 805
|
||||
|
||||
}
|
||||
|
|
@ -10,20 +10,14 @@ import androidx.activity.viewModels
|
|||
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||
import com.ama.core.architecture.util.ResUtil
|
||||
import com.gamedog.vididin.R
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.features.benefit.widget.BenefitTaskItemView
|
||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||
import com.gamedog.vididin.manager.TaskManager
|
||||
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_AD
|
||||
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_VIDEO
|
||||
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_SIGN
|
||||
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_ZERO_BUY
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlin.getValue
|
||||
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_FINISH
|
||||
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_CLAIMED
|
||||
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_EXPIRED
|
||||
import com.gamedog.vididin.router.Router
|
||||
import com.gamedog.vididin.databinding.ActivityBenefitBinding as ViewBinding
|
||||
import com.gamedog.vididin.main.MainUiState as UiState
|
||||
import com.gamedog.vididin.main.MainViewModel as ViewModel
|
||||
|
|
@ -81,7 +75,6 @@ class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
|||
binding.llSubTaskContainer.addView(separateLine, ViewGroup.LayoutParams.MATCH_PARENT, ResUtil.getPixelSize(R.dimen.dp1))
|
||||
|
||||
val subTaskView = BenefitTaskItemView(this@BenefitActivity)
|
||||
subTaskView.setActionFun { handleActionButClicked(subTask.task_type) }
|
||||
val subViewParam = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
subViewParam.topMargin = ResUtil.getPixelSize(R.dimen.dp10)
|
||||
subViewParam.bottomMargin = ResUtil.getPixelSize(R.dimen.dp10)
|
||||
|
|
@ -91,28 +84,6 @@ class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleActionButClicked(taskType: Int) {
|
||||
when (taskType) {
|
||||
BOX_SUB_TASK_TYPE_AD -> {
|
||||
Router.WatchAd.startActivity(this@BenefitActivity, VididinEvents.Event_AD_TASK_TYPE_BOX_TASK, null)
|
||||
}
|
||||
|
||||
BOX_SUB_TASK_TYPE_SIGN -> {
|
||||
// TODO -
|
||||
}
|
||||
|
||||
BOX_SUB_TASK_TYPE_VIDEO -> {
|
||||
|
||||
}
|
||||
|
||||
BOX_SUB_TASK_TYPE_ZERO_BUY -> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun updateSubTasksUI() {
|
||||
val taskStateHelper = TaskManager.instance().boxTaskStatus()
|
||||
val currentBoxIndex = taskStateHelper.getCurrentBoxIndex()
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@ package com.gamedog.vididin.manager.helpers
|
|||
import com.ama.core.architecture.util.DateUtil
|
||||
import com.ama.core.architecture.util.SpUtil
|
||||
import com.gamedog.vididin.R
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.main.fragments.task.BoxTaskRoot
|
||||
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_ZERO_BUY
|
||||
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_SIGN
|
||||
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_AD
|
||||
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_VIDEO
|
||||
import com.gamedog.vididin.manager.taskbeans.TaskStateBox
|
||||
import com.gamedog.vididin.manager.taskbeans.TaskStateBoxRoot
|
||||
import com.gamedog.vididin.manager.taskbeans.TaskStateBoxSub
|
||||
|
|
@ -16,36 +11,11 @@ import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_FINIS
|
|||
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_ONGOING
|
||||
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_CLAIMED
|
||||
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_EXPIRED
|
||||
import kotlin.Pair
|
||||
|
||||
class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
||||
|
||||
override val mSpKey = SpUtil.KEY_TASK_BOX
|
||||
|
||||
init {
|
||||
registerEvents( { eventData->
|
||||
when (eventData?.mEventType) {
|
||||
VididinEvents.Event_Finish_One_Ad -> {
|
||||
handleEvents(BOX_SUB_TASK_TYPE_AD)
|
||||
}
|
||||
|
||||
VididinEvents.Event_Finish_One_Video -> {
|
||||
handleEvents(BOX_SUB_TASK_TYPE_VIDEO)
|
||||
}
|
||||
|
||||
VididinEvents.Event_Finish_One_Sign -> {
|
||||
handleEvents(BOX_SUB_TASK_TYPE_SIGN)
|
||||
}
|
||||
|
||||
VididinEvents.Event_Finish_One_Zerobuy -> {
|
||||
handleEvents(BOX_SUB_TASK_TYPE_ZERO_BUY)
|
||||
}
|
||||
}
|
||||
|
||||
}, VididinEvents.Event_Finish_One_Ad, VididinEvents.Event_Finish_One_Video,
|
||||
VididinEvents.Event_Finish_One_Sign, VididinEvents.Event_Finish_One_Zerobuy)
|
||||
}
|
||||
|
||||
override fun loadTaskFromSp() {
|
||||
val taskStateBeanInSp = SpUtil.instance().getObject<TaskStateBoxRoot>(mSpKey)
|
||||
if (taskStateBeanInSp == null || isBoxRootTaskExpired(taskStateBeanInSp)) {
|
||||
|
|
@ -72,23 +42,6 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
|||
return TaskStateBoxRoot(DateUtil.getTodayStartTimeMs(), boxStateList)
|
||||
}
|
||||
|
||||
|
||||
@Synchronized
|
||||
private fun handleEvents(taskType: Int) {
|
||||
val currentBoxIndex = getCurrentBoxIndex()
|
||||
if (!isBoxAllFinished(currentBoxIndex)) {
|
||||
getCurrentBoxState()?.tasks?.forEachIndexed { index, subTask->
|
||||
if (taskType == subTask.task_type
|
||||
&& !isBoxSubTaskFinished(currentBoxIndex, index)) {
|
||||
subTask.finishedNum++
|
||||
saveState2Sp()
|
||||
// TODO - if need notify
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun isBoxRootTaskExpired(taskStateBoxRoot: TaskStateBoxRoot): Boolean {
|
||||
var totalDurationDays = 0
|
||||
taskStateBoxRoot.tasks.forEach {
|
||||
|
|
@ -132,25 +85,6 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
|||
return -1
|
||||
}
|
||||
|
||||
fun getCurrentBoxState(): TaskStateBox? {
|
||||
val currentBoxIndex = getCurrentBoxIndex()
|
||||
|
||||
if (currentBoxIndex >= 0 && currentBoxIndex < mStateBean.tasks.size) {
|
||||
return mStateBean.tasks[currentBoxIndex]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun isBoxAllFinished(boxIndex: Int) : Boolean {
|
||||
val stateEnum = getBoxStateEnum(boxIndex)
|
||||
return stateEnum == STATE_FINISH || stateEnum == STATE_CLAIMED
|
||||
}
|
||||
|
||||
fun isBoxSubTaskFinished(boxIndex: Int, subTaskIndex: Int) : Boolean {
|
||||
val subTaskState = mStateBean.tasks[boxIndex].tasks[subTaskIndex]
|
||||
return subTaskState.finishedNum >= subTaskState.required_count
|
||||
}
|
||||
|
||||
fun getBoxStateEnum(boxIndex: Int): Int {
|
||||
if (boxIndex >= 0 && boxIndex < mStateBean.tasks.size) {
|
||||
val curBoxState = mStateBean.tasks[boxIndex]
|
||||
|
|
@ -185,49 +119,49 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
|||
fun getSubTaskHintStrRes(boxIndex: Int, subTaskIndex: Int): Int {
|
||||
when (boxIndex) {
|
||||
0-> {
|
||||
when (subTaskIndex) {
|
||||
when (boxIndex) {
|
||||
0-> {
|
||||
return R.string.box_subtask_hint_1_1
|
||||
}
|
||||
|
||||
1-> {
|
||||
return R.string.box_subtask_hint_1_2
|
||||
return R.string.box_subtask_hint_1_1
|
||||
}
|
||||
|
||||
2-> {
|
||||
return R.string.box_subtask_hint_1_3
|
||||
return R.string.box_subtask_hint_1_1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1-> {
|
||||
when (subTaskIndex) {
|
||||
when (boxIndex) {
|
||||
0-> {
|
||||
return R.string.box_subtask_hint_2_1
|
||||
}
|
||||
|
||||
1-> {
|
||||
return R.string.box_subtask_hint_2_2
|
||||
return R.string.box_subtask_hint_2_1
|
||||
}
|
||||
|
||||
2-> {
|
||||
return R.string.box_subtask_hint_2_3
|
||||
return R.string.box_subtask_hint_2_1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2-> {
|
||||
when (subTaskIndex) {
|
||||
when (boxIndex) {
|
||||
0-> {
|
||||
return R.string.box_subtask_hint_3_1
|
||||
}
|
||||
|
||||
1-> {
|
||||
return R.string.box_subtask_hint_3_2
|
||||
return R.string.box_subtask_hint_3_1
|
||||
}
|
||||
|
||||
2-> {
|
||||
return R.string.box_subtask_hint_3_3
|
||||
return R.string.box_subtask_hint_3_1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ama.core.architecture.util.DateUtil
|
|||
import com.ama.core.architecture.util.SpUtil
|
||||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.main.fragments.task.Task
|
||||
import com.gamedog.vididin.manager.taskbeans.TaskStateWatchAd
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ data class TaskStateBoxSub(
|
|||
val task_type: Int, // This added by self for decide which task should be execute, detail see: #TaskManager.companion
|
||||
|
||||
// new added
|
||||
var finishedNum: Int = 0,
|
||||
val finishedNum: Int = 0,
|
||||
): Serializable
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue