体现可选择
This commit is contained in:
parent
3b2b78dd95
commit
1b35da0a4e
|
|
@ -8,6 +8,9 @@ import com.ama.core.architecture.appBase.AppViewsActivity
|
|||
import com.ama.core.architecture.util.ResUtil
|
||||
import com.ama.core.architecture.util.setOnClickBatch
|
||||
import com.gamedog.vididin.R
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.core.login.login.AccountManager
|
||||
import com.gamedog.vididin.features.withdraw.widget.WithDrawItemView
|
||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||
import com.gamedog.vididin.router.Router
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
|
@ -23,37 +26,46 @@ class WithDrawActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), On
|
|||
override val mViewModel: ViewModel by viewModels()
|
||||
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||
|
||||
private val mItemViewList: MutableList<WithDrawItemView> = mutableListOf()
|
||||
private var mCurSelectedIndex: Int = 0
|
||||
|
||||
|
||||
|
||||
override fun ViewBinding.initWindowInsets() {
|
||||
setImmerseRootView(contentRoot)
|
||||
}
|
||||
|
||||
override fun ViewBinding.initViews() {
|
||||
|
||||
with(binding) {
|
||||
withdraw01.setNumAndAction(ResUtil.getString(R.string.cash) + " " + 0.1, {
|
||||
withdraw01.setNumAndAction(0, 0.1F,
|
||||
{ itemIndex->
|
||||
updateUIItemSelectStates(itemIndex)
|
||||
})
|
||||
|
||||
})
|
||||
withdraw01.setSelected()
|
||||
withdraw10.setNumAndAction(1, 10F,
|
||||
{ itemIndex->
|
||||
updateUIItemSelectStates(itemIndex)
|
||||
})
|
||||
|
||||
withdraw10.setNumAndAction(ResUtil.getString(R.string.cash) + " " + 10, {
|
||||
withdraw20.setNumAndAction(2, 20F,
|
||||
{ itemIndex->
|
||||
updateUIItemSelectStates(itemIndex)
|
||||
})
|
||||
|
||||
})
|
||||
withdraw50.setNumAndAction(3, 50F,
|
||||
{ itemIndex->
|
||||
updateUIItemSelectStates(itemIndex)
|
||||
})
|
||||
|
||||
withdraw20.setNumAndAction(ResUtil.getString(R.string.cash) + " " + 20, {
|
||||
withdraw100.setNumAndAction(4, 100F,
|
||||
{ itemIndex->
|
||||
updateUIItemSelectStates(itemIndex)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
withdraw50.setNumAndAction(ResUtil.getString(R.string.cash) + " " + 50, {
|
||||
|
||||
})
|
||||
|
||||
withdraw100.setNumAndAction(ResUtil.getString(R.string.cash) + " " + 100, {
|
||||
|
||||
})
|
||||
|
||||
withdraw300.setNumAndAction(ResUtil.getString(R.string.cash) + " " + 300, {
|
||||
|
||||
})
|
||||
withdraw300.setNumAndAction(5, 300F,
|
||||
{ itemIndex->
|
||||
updateUIItemSelectStates(itemIndex)
|
||||
})
|
||||
|
||||
withdrawPix2.setIconAndText(R.mipmap.pix2, R.string.pix2, {
|
||||
|
||||
|
|
@ -61,7 +73,7 @@ class WithDrawActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), On
|
|||
|
||||
|
||||
|
||||
|
||||
updateUIItemSelectStates(0)
|
||||
setOnClickBatch(tvSacar, withdrawRecord) {
|
||||
when(this) {
|
||||
tvSacar -> {
|
||||
|
|
@ -74,10 +86,31 @@ class WithDrawActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), On
|
|||
}
|
||||
}
|
||||
|
||||
mItemViewList.add(withdraw01)
|
||||
mItemViewList.add(withdraw10)
|
||||
mItemViewList.add(withdraw20)
|
||||
mItemViewList.add(withdraw50)
|
||||
mItemViewList.add(withdraw100)
|
||||
mItemViewList.add(withdraw300)
|
||||
|
||||
updateUICashTotal()
|
||||
}
|
||||
|
||||
private fun updateUIItemSelectStates(itemIndex: Int) {
|
||||
mCurSelectedIndex = itemIndex
|
||||
mItemViewList.forEachIndexed { index, view ->
|
||||
view.setSelectedState(index == mCurSelectedIndex)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateUICashTotal() {
|
||||
binding.tvCashTotal.text = AccountManager.getCash().toString()
|
||||
}
|
||||
|
||||
override fun ViewBinding.initListeners() {
|
||||
//TODO("Not yet implemented")
|
||||
registerEvents({ data->
|
||||
updateUICashTotal()
|
||||
}, VididinEvents.Event_Account_Cash_Changed)
|
||||
}
|
||||
|
||||
override fun ViewBinding.initObservers() {
|
||||
|
|
|
|||
|
|
@ -14,24 +14,33 @@ class WithDrawItemView @JvmOverloads constructor(
|
|||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
private var mItemIndex: Int = 0
|
||||
private var mIsSelected = false
|
||||
private var mCashNum: Float = 0F
|
||||
private var mBinding: ViewBinding
|
||||
|
||||
|
||||
init {
|
||||
mBinding = ViewBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
mBinding.run {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun setNumAndAction(number: String, clickAction: ()->Unit) {
|
||||
mBinding.tvWithdrawNum.text = number
|
||||
/**
|
||||
* For withdraw number in top area
|
||||
*/
|
||||
fun setNumAndAction(itemIndex: Int, cashNum: Float, clickAction: (Int)->Unit) {
|
||||
mItemIndex = itemIndex
|
||||
mCashNum = cashNum
|
||||
mBinding.tvWithdrawNum.text = cashNum.toString()
|
||||
mBinding.root.setOnClickListener {
|
||||
clickAction.invoke()
|
||||
clickAction.invoke(mItemIndex)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For bank item in bottom area
|
||||
*/
|
||||
fun setIconAndText(iconRes: Int, textRes: Int, clickAction: ()->Unit) {
|
||||
mBinding.tvWithdrawNum.text = ResUtil.getString(textRes)
|
||||
mBinding.ivItemIcon.setImageResource(iconRes)
|
||||
|
|
@ -40,8 +49,9 @@ class WithDrawItemView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun setSelected() {
|
||||
mBinding.root.setBackgroundResource(R.drawable.withdraw_item_bg_selected)
|
||||
fun setSelectedState(isSelected: Boolean) {
|
||||
mIsSelected = isSelected
|
||||
mBinding.root.setBackgroundResource(if (mIsSelected) R.drawable.withdraw_item_bg_selected else R.drawable.withdraw_item_bg_unselected)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,17 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textSize="21sp"
|
||||
android:textColor="@color/yellow_46"
|
||||
android:text="@string/cash01"
|
||||
android:text="@string/cash"
|
||||
android:layout_marginStart="5dp"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_cash_total"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="21sp"
|
||||
android:textColor="@color/yellow_46"
|
||||
android:text="0"
|
||||
android:layout_marginStart="5dp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
Loading…
Reference in New Issue