夺宝精灵:bug fix
This commit is contained in:
@@ -46,8 +46,8 @@ class FairyViewModel : BaseViewModel() {
|
|||||||
private val _friendsListLiveData = MutableLiveData<List<SimpleUserInfo>>()
|
private val _friendsListLiveData = MutableLiveData<List<SimpleUserInfo>>()
|
||||||
val friendsListLiveData: LiveData<List<SimpleUserInfo>> = _friendsListLiveData
|
val friendsListLiveData: LiveData<List<SimpleUserInfo>> = _friendsListLiveData
|
||||||
|
|
||||||
private val _sendFairyLiveData = MutableLiveData<Boolean>()
|
private val _sendFairyLiveData = MutableLiveData<Event<Boolean>>()
|
||||||
val sendFairyLiveData: LiveData<Boolean> = _sendFairyLiveData
|
val sendFairyLiveData: LiveData<Event<Boolean>> = _sendFairyLiveData
|
||||||
|
|
||||||
private val _sendFairyRecordLiveData = MutableLiveData<ListResult<SendFairyInfo>>()
|
private val _sendFairyRecordLiveData = MutableLiveData<ListResult<SendFairyInfo>>()
|
||||||
val sendFairyRecordLiveData: LiveData<ListResult<SendFairyInfo>> = _sendFairyRecordLiveData
|
val sendFairyRecordLiveData: LiveData<ListResult<SendFairyInfo>> = _sendFairyRecordLiveData
|
||||||
@@ -185,12 +185,12 @@ class FairyViewModel : BaseViewModel() {
|
|||||||
fun askForFairy(elfId: Long, targetUid: Long) {
|
fun askForFairy(elfId: Long, targetUid: Long) {
|
||||||
safeLaunch(
|
safeLaunch(
|
||||||
onError = {
|
onError = {
|
||||||
_sendFairyLiveData.value = false
|
_sendFairyLiveData.value = Event(false)
|
||||||
it.message.toast()
|
it.message.toast()
|
||||||
},
|
},
|
||||||
block = {
|
block = {
|
||||||
TreasureFairyModel.askForFairy(elfId, targetUid)
|
TreasureFairyModel.askForFairy(elfId, targetUid)
|
||||||
_sendFairyLiveData.value = true
|
_sendFairyLiveData.value = Event(true)
|
||||||
"已向好友发送索要信息".toast()
|
"已向好友发送索要信息".toast()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -199,12 +199,12 @@ class FairyViewModel : BaseViewModel() {
|
|||||||
fun sendFairy(elfId: Long, targetUid: Long) {
|
fun sendFairy(elfId: Long, targetUid: Long) {
|
||||||
safeLaunch(
|
safeLaunch(
|
||||||
onError = {
|
onError = {
|
||||||
_sendFairyLiveData.value = false
|
_sendFairyLiveData.value = Event(false)
|
||||||
it.message.toast()
|
it.message.toast()
|
||||||
},
|
},
|
||||||
block = {
|
block = {
|
||||||
TreasureFairyModel.sendFairy(elfId, targetUid)
|
TreasureFairyModel.sendFairy(elfId, targetUid)
|
||||||
_sendFairyLiveData.value = true
|
_sendFairyLiveData.value = Event(true)
|
||||||
"赠送成功!".toast()
|
"赠送成功!".toast()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@@ -78,16 +78,24 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
|||||||
ForestFairyDialog.newInstance().show(this)
|
ForestFairyDialog.newInstance().show(this)
|
||||||
}
|
}
|
||||||
binding.ivOpen1.setOnClickListener {
|
binding.ivOpen1.setOnClickListener {
|
||||||
rotatePrize()
|
if (checkKeyNum(1)) {
|
||||||
viewModel.drawFairy(1)
|
rotatePrize()
|
||||||
|
viewModel.drawFairy(1)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
binding.ivOpen10.setOnClickListener {
|
binding.ivOpen10.setOnClickListener {
|
||||||
rotatePrize()
|
if (checkKeyNum(10)) {
|
||||||
viewModel.drawFairy(10)
|
rotatePrize()
|
||||||
|
viewModel.drawFairy(10)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.ivOpen100.setOnClickListener {
|
binding.ivOpen100.setOnClickListener {
|
||||||
rotatePrize()
|
if (checkKeyNum(100)) {
|
||||||
viewModel.drawFairy(100)
|
rotatePrize()
|
||||||
|
viewModel.drawFairy(100)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
binding.rootView.setOnClickListener { finish() }
|
binding.rootView.setOnClickListener { finish() }
|
||||||
binding.viewBg.setOnClickListener {
|
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() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
viewModel.initDrawInfo()
|
viewModel.initDrawInfo()
|
||||||
|
@@ -63,7 +63,7 @@ class MyFairySendDialog : BaseDialog<TreasureFairyDialogMyFairySendBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewModel.sendFairyLiveData.observe(viewLifecycleOwner) {
|
viewModel.sendFairyLiveData.observe(viewLifecycleOwner) {
|
||||||
if (it == true) dismissAllowingStateLoss()
|
if (it.getContentIfNotHandled() == true) dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,12 +36,12 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:paddingStart="8dp"
|
android:paddingStart="8dp"
|
||||||
android:paddingTop="2dp"
|
android:paddingTop="2dp"
|
||||||
android:text="12.2W"
|
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/iv_more"
|
app:layout_constraintBottom_toBottomOf="@id/iv_more"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/iv_more" />
|
app:layout_constraintTop_toTopOf="@id/iv_more"
|
||||||
|
tools:text="12.2W" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_fairy_treasure"
|
android:id="@+id/iv_fairy_treasure"
|
||||||
|
Reference in New Issue
Block a user