总进度及金额 读取
This commit is contained in:
parent
0bf9922be7
commit
114f7befbc
|
|
@ -7,7 +7,6 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.ActionBar
|
|
||||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
import com.ama.core.architecture.util.ResUtil
|
import com.ama.core.architecture.util.ResUtil
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
|
|
@ -40,7 +39,6 @@ class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
|
|
||||||
override fun ViewBinding.initViews() {
|
override fun ViewBinding.initViews() {
|
||||||
titlebar.setTitleText(R.string.benefit)
|
titlebar.setTitleText(R.string.benefit)
|
||||||
loadTaskState()
|
|
||||||
initViewsByTaskState()
|
initViewsByTaskState()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,9 +58,6 @@ class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadTaskState() {
|
|
||||||
val taskStateHelper = TaskManager.instance().boxTaskStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initViewsByTaskState() {
|
private fun initViewsByTaskState() {
|
||||||
initAddSubTaskViews()
|
initAddSubTaskViews()
|
||||||
|
|
@ -161,6 +156,17 @@ class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
isClickable = false
|
isClickable = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 总进度条, 奖励金额
|
||||||
|
val totalProgress = taskStateHelper.getCurrentBoxTotalProgress()
|
||||||
|
progressTasks.setProgress(totalProgress)
|
||||||
|
tvProgressNum.text = "($totalProgress%)"
|
||||||
|
tvHintRewardNum.text = buildString {
|
||||||
|
append(ResUtil.getString(R.string.cash))
|
||||||
|
append(" ")
|
||||||
|
append(taskStateHelper.getStatusBean().tasks[taskStateHelper.getCurrentBoxIndex()].reward_value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,4 +170,25 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getCurrentBoxTotalProgress(): Int {
|
||||||
|
val currentBoxIndex = getCurrentBoxIndex()
|
||||||
|
val boxList = mStateBean.tasks
|
||||||
|
if (currentBoxIndex >= 0 && currentBoxIndex < boxList.size) {
|
||||||
|
var totalFinished = 0
|
||||||
|
var totalRequired = 0
|
||||||
|
val currentBox = boxList[currentBoxIndex]
|
||||||
|
|
||||||
|
currentBox.tasks.forEach {
|
||||||
|
totalFinished += it.finishedNum
|
||||||
|
totalRequired += it.required_count
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalRequired > 0) {
|
||||||
|
val totalProgress = (100 * totalFinished) / totalRequired
|
||||||
|
return if (totalProgress > 100) 100 else totalProgress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue