夺宝精灵:bug fix
This commit is contained in:
@@ -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()
|
||||
}
|
||||
)
|
||||
|
@@ -78,17 +78,25 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
ForestFairyDialog.newInstance().show(this)
|
||||
}
|
||||
binding.ivOpen1.setOnClickListener {
|
||||
if (checkKeyNum(1)) {
|
||||
rotatePrize()
|
||||
viewModel.drawFairy(1)
|
||||
}
|
||||
|
||||
}
|
||||
binding.ivOpen10.setOnClickListener {
|
||||
if (checkKeyNum(10)) {
|
||||
rotatePrize()
|
||||
viewModel.drawFairy(10)
|
||||
}
|
||||
}
|
||||
|
||||
binding.ivOpen100.setOnClickListener {
|
||||
if (checkKeyNum(100)) {
|
||||
rotatePrize()
|
||||
viewModel.drawFairy(100)
|
||||
}
|
||||
}
|
||||
binding.rootView.setOnClickListener { finish() }
|
||||
binding.viewBg.setOnClickListener {
|
||||
//do nothing
|
||||
@@ -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()
|
||||
|
@@ -63,7 +63,7 @@ class MyFairySendDialog : BaseDialog<TreasureFairyDialogMyFairySendBinding>() {
|
||||
}
|
||||
|
||||
viewModel.sendFairyLiveData.observe(viewLifecycleOwner) {
|
||||
if (it == true) dismissAllowingStateLoss()
|
||||
if (it.getContentIfNotHandled() == true) dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"
|
||||
|
Reference in New Issue
Block a user