夺宝精灵:bug fix

This commit is contained in:
huangjian
2023-02-27 18:54:19 +08:00
parent ec1507ed31
commit a6adad7701
4 changed files with 34 additions and 15 deletions

View File

@@ -46,8 +46,8 @@ class FairyViewModel : BaseViewModel() {
private val _friendsListLiveData = MutableLiveData<List<SimpleUserInfo>>()
val friendsListLiveData: LiveData<List<SimpleUserInfo>> = _friendsListLiveData
private val _sendFairyLiveData = MutableLiveData<Boolean>()
val sendFairyLiveData: LiveData<Boolean> = _sendFairyLiveData
private val _sendFairyLiveData = MutableLiveData<Event<Boolean>>()
val sendFairyLiveData: LiveData<Event<Boolean>> = _sendFairyLiveData
private val _sendFairyRecordLiveData = MutableLiveData<ListResult<SendFairyInfo>>()
val sendFairyRecordLiveData: LiveData<ListResult<SendFairyInfo>> = _sendFairyRecordLiveData
@@ -185,12 +185,12 @@ class FairyViewModel : BaseViewModel() {
fun askForFairy(elfId: Long, targetUid: Long) {
safeLaunch(
onError = {
_sendFairyLiveData.value = false
_sendFairyLiveData.value = Event(false)
it.message.toast()
},
block = {
TreasureFairyModel.askForFairy(elfId, targetUid)
_sendFairyLiveData.value = true
_sendFairyLiveData.value = Event(true)
"已向好友发送索要信息".toast()
}
)
@@ -199,12 +199,12 @@ class FairyViewModel : BaseViewModel() {
fun sendFairy(elfId: Long, targetUid: Long) {
safeLaunch(
onError = {
_sendFairyLiveData.value = false
_sendFairyLiveData.value = Event(false)
it.message.toast()
},
block = {
TreasureFairyModel.sendFairy(elfId, targetUid)
_sendFairyLiveData.value = true
_sendFairyLiveData.value = Event(true)
"赠送成功!".toast()
}
)

View File

@@ -78,16 +78,24 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
ForestFairyDialog.newInstance().show(this)
}
binding.ivOpen1.setOnClickListener {
rotatePrize()
viewModel.drawFairy(1)
if (checkKeyNum(1)) {
rotatePrize()
viewModel.drawFairy(1)
}
}
binding.ivOpen10.setOnClickListener {
rotatePrize()
viewModel.drawFairy(10)
if (checkKeyNum(10)) {
rotatePrize()
viewModel.drawFairy(10)
}
}
binding.ivOpen100.setOnClickListener {
rotatePrize()
viewModel.drawFairy(100)
if (checkKeyNum(100)) {
rotatePrize()
viewModel.drawFairy(100)
}
}
binding.rootView.setOnClickListener { finish() }
binding.viewBg.setOnClickListener {
@@ -177,6 +185,17 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
}
}
private fun checkKeyNum(num: Int): Boolean {
val keyNum = binding.tvKeyNum.text.toString().toInt()
if (keyNum > num) {
return true
}
DialogManager(context).showOkCancelDialog("购买限时装扮活动夺宝券", "去参与", "取消") {
FairyDialogWebViewActivity.start(context, UriProvider.getFairyKey())
}
return false
}
override fun onResume() {
super.onResume()
viewModel.initDrawInfo()

View File

@@ -63,7 +63,7 @@ class MyFairySendDialog : BaseDialog<TreasureFairyDialogMyFairySendBinding>() {
}
viewModel.sendFairyLiveData.observe(viewLifecycleOwner) {
if (it == true) dismissAllowingStateLoss()
if (it.getContentIfNotHandled() == true) dismissAllowingStateLoss()
}
}

View File

@@ -36,12 +36,12 @@
android:gravity="center"
android:paddingStart="8dp"
android:paddingTop="2dp"
android:text="12.2W"
android:textColor="@color/white"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="@id/iv_more"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/iv_more" />
app:layout_constraintTop_toTopOf="@id/iv_more"
tools:text="12.2W" />
<ImageView
android:id="@+id/iv_fairy_treasure"