添加subBean状态机
This commit is contained in:
parent
8f2786b5b9
commit
f889dc5072
|
|
@ -7,10 +7,12 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity
|
||||
import com.ama.core.architecture.util.AndroidUtil
|
||||
import com.ama.core.architecture.util.CommonItemDecoration
|
||||
import com.ama.core.architecture.util.ResUtil
|
||||
import com.ama.core.architecture.util.setOnClickBatch
|
||||
import com.gamedog.vididin.VidiConst
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.beans.WatchAdNotifyBean
|
||||
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog
|
||||
import com.gamedog.vididin.manager.WithdrawItemBean
|
||||
import com.gamedog.vididin.manager.WithdrawManager
|
||||
import com.gamedog.vididin.router.Router
|
||||
|
|
@ -44,7 +46,15 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
setOnClickBatch(flAction) {
|
||||
when(this) {
|
||||
flAction -> {
|
||||
gotoWatchAd()
|
||||
when (mCurItem.subItemList[mCurItem.selectedSubIndex].withdrawState) {
|
||||
0 -> {
|
||||
gotoWatchAd()
|
||||
}
|
||||
|
||||
1 -> {
|
||||
WithdrawInfoConfirmDialog(this@WithDrawSubActivity).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,7 +73,7 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
|
||||
VididinEvents.EVENT_WITHDRAW_SUB_ITEM_PROGRESS_UPDATED -> {
|
||||
if ((data.mData as Int) == mCurItem.selectedSubIndex) {
|
||||
progressBar.setProgress(mCurItem.subItemList[mCurItem.selectedSubIndex].currentProgress)
|
||||
updateProgressUI()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +111,43 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateProgressUI() {
|
||||
with(binding) {
|
||||
val subBean = mCurItem.subItemList[mCurItem.selectedSubIndex]
|
||||
val curProgress = subBean.currentProgress
|
||||
progressBar.setProgress(curProgress)
|
||||
|
||||
tvAction.setCompoundDrawables(if (curProgress < 100) ResUtil.getDrawable(R.mipmap.task_video) else null, null, null, null)
|
||||
if (curProgress < 100) {
|
||||
tvAction.setText(R.string.withdraw_cash_out)
|
||||
tvAction.isClickable = true
|
||||
flAction.alpha = 1F
|
||||
} else {
|
||||
var actionText = R.string.withdraw_cash_out
|
||||
when(subBean.withdrawState) {
|
||||
0 -> {
|
||||
actionText = R.string.withdraw_cash_out
|
||||
tvAction.isClickable = true
|
||||
flAction.alpha = 1F
|
||||
}
|
||||
|
||||
1 -> {
|
||||
actionText = R.string.pending
|
||||
tvAction.isClickable = false
|
||||
flAction.alpha = 0.6F
|
||||
}
|
||||
|
||||
2 -> {
|
||||
actionText = R.string.withdraw_success
|
||||
tvAction.isClickable = false
|
||||
flAction.alpha = 0.6F
|
||||
}
|
||||
}
|
||||
tvAction.setText(actionText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun ViewBinding.initObservers() {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import com.gamedog.vididin.core.login.login.AccountManager
|
|||
import com.vididin.real.money.game.databinding.DialogWithdrawInfoConfirmBinding as ViewBinding
|
||||
|
||||
|
||||
class WithdrawInfoConfirmDialog(context: Activity, ) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||
class WithdrawInfoConfirmDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||
|
||||
private var mWithdrawCashNum: Float = 0F
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ama.core.architecture.util.AndroidUtil
|
|||
import com.ama.core.architecture.util.SpUtil
|
||||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.manager.WithdrawManager.Companion.STATE_NEED_WATCH_AD
|
||||
|
||||
|
||||
class WithdrawManager private constructor() {
|
||||
|
|
@ -22,6 +23,12 @@ class WithdrawManager private constructor() {
|
|||
companion object {
|
||||
const val EACH_SUB_ITEM_CASH_NUM: Float = 1F
|
||||
|
||||
const val STATE_NEED_WATCH_AD: Int = 0
|
||||
const val STATE_COULD_WITHDRAW: Int = 1
|
||||
const val STATE_WITHDRAWING: Int = 2
|
||||
const val STATE_HAS_WITHDRAWED: Int = 3
|
||||
|
||||
|
||||
@Volatile
|
||||
private var instance: WithdrawManager? = null
|
||||
fun instance(): WithdrawManager {
|
||||
|
|
@ -97,12 +104,21 @@ class WithdrawManager private constructor() {
|
|||
val needEarnProgress = 100 - subBean.startProgress
|
||||
if (subBean.hasEarnMoneyByAd >= subBean.cashTotal) {
|
||||
subBean.currentProgress = 100
|
||||
// update state
|
||||
if (subBean.withdrawState == STATE_NEED_WATCH_AD) {
|
||||
subBean.withdrawState = STATE_COULD_WITHDRAW
|
||||
}
|
||||
} else {
|
||||
val newProgress = subBean.startProgress + (needEarnProgress * (subBean.hasEarnMoneyByAd / subBean.cashTotal)).toInt()
|
||||
subBean.currentProgress = if (newProgress >= 100) 99 else newProgress
|
||||
}
|
||||
}
|
||||
|
||||
fun updateSubBeanState(subBean: WithdrawSubItem, newState: Int) {
|
||||
subBean.withdrawState = newState
|
||||
saveInfos2Sp(mItemList)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -112,6 +128,7 @@ data class WithdrawItemBean(
|
|||
var totalProgress: Int = 0,
|
||||
val subItemList: List<WithdrawSubItem> = emptyList(),
|
||||
var selectedSubIndex: Int = 0,
|
||||
val startMs: Long = 0,
|
||||
)
|
||||
|
||||
data class WithdrawSubItem(
|
||||
|
|
@ -120,4 +137,5 @@ data class WithdrawSubItem(
|
|||
val startProgress: Int = 0,
|
||||
var currentProgress: Int = 0,
|
||||
var hasEarnMoneyByAd: Float = 0F,
|
||||
var withdrawState: Int = STATE_NEED_WATCH_AD,
|
||||
)
|
||||
|
|
@ -183,11 +183,12 @@
|
|||
android:layout_marginTop="5dp"
|
||||
android:padding="12dp">
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_action"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/saque"
|
||||
android:text="@string/withdraw_cash_out"
|
||||
android:layout_gravity="center"
|
||||
android:drawableStart="@mipmap/task_video"
|
||||
android:drawablePadding="10dp"
|
||||
|
|
|
|||
|
|
@ -138,7 +138,9 @@
|
|||
<string name="withdraw_fail_reach_day_limit">Your have reached the times limit.</string>
|
||||
<string name="withdraw_fail_unkown_error">0utros Erro</string>
|
||||
<string name="withdraw_sub_top_hint">Valor do saque</string>
|
||||
<string name="saque">Saque Já</string>
|
||||
<string name="withdraw_cash_out">Sacar Agora</string>
|
||||
<string name="pending">Pendente</string>
|
||||
<string name="withdraw_success">Suceder</string>
|
||||
<string name="withdraw_sub_top_hint_2">100%! Pix lmediato na Sua Contal!</string>
|
||||
<string name="regras">Regras</string>
|
||||
<string name="with_draw_sub_hint">1. Grandes quantias em dinheiro sro distribuidas em vários dias;todas asrecompensas sao reais e válidas.\n2. Assistir a videos na p¡gina atual pode aumentar o progresso datarefa. Quando oprogresso atingir 100%, a recompensa diária emdinheiro pode ser reivindicada.\n3. Após reivindicar uma recompensa com sucesso, vocé podereceber a proximarecompensa em dinheiro no dia sequinte.4. Se a reivindicacao falhar, verifique se as informac\'es da contaestaopreenchidas corretamente e tente reivindicar a recompensaem dinheironovamente.\n5.Se houver comportamento de fraude, o sistema banirá a contae a colocara na</string>
|
||||
|
|
|
|||
Loading…
Reference in New Issue