修复 "寻爱之旅"活动页面 UI 以及 余额不足未弹出充值弹窗
This commit is contained in:
BIN
app/src/main/res/drawable-xhdpi/bg_add_num_bg.webp
Normal file
BIN
app/src/main/res/drawable-xhdpi/bg_add_num_bg.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1016 B |
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB |
@@ -9,12 +9,12 @@ import android.view.WindowManager
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.base.Event
|
||||
import com.yizhuan.erban.databinding.TreasureBoxDialogLoveLackBinding
|
||||
import com.yizhuan.erban.event.BoxLoveEvent
|
||||
import com.yizhuan.erban.treasurefairy.dialog.FairyBuySuccessDialog
|
||||
import com.yizhuan.erban.treasure_box.widget.dialog.TreasureBoxDialog.Companion.newInstance
|
||||
import com.yizhuan.treasure_box.bean.UserTicketInfo
|
||||
import com.yizhuan.treasure_box.model.BoxModel
|
||||
import com.yizhuan.xchat_android_core.exception.FailReasonException
|
||||
import com.yizhuan.xchat_android_core.utils.StringUtils
|
||||
import com.yizhuan.xchat_android_library.common.SpConstants
|
||||
import com.yizhuan.xchat_android_library.common.util.SPUtils
|
||||
@@ -57,14 +57,14 @@ class BoxLoveLackDialog : BaseDialog<TreasureBoxDialogLoveLackBinding>() {
|
||||
|
||||
binding?.ivSub?.setOnClickListener {
|
||||
val editNum =
|
||||
(StringUtils.toInt(binding?.editNum?.text.toString(), 0) - 1).coerceAtLeast(1)
|
||||
(StringUtils.toInt(binding?.editNum?.text.toString(), 0) - 10).coerceAtLeast(1)
|
||||
binding?.editNum?.setText(editNum.toString())
|
||||
binding?.tvPrizeName?.text = (editNum * ticketPrice).toString()
|
||||
}
|
||||
|
||||
binding?.ivAdd?.setOnClickListener {
|
||||
val editNum =
|
||||
(StringUtils.toInt(binding?.editNum?.text.toString(), 0) + 1).coerceAtMost(9999)
|
||||
(StringUtils.toInt(binding?.editNum?.text.toString(), 0) + 10).coerceAtMost(200)
|
||||
binding?.editNum?.setText(editNum.toString())
|
||||
binding?.tvPrizeName?.text = (editNum * ticketPrice).toString()
|
||||
}
|
||||
@@ -79,7 +79,8 @@ class BoxLoveLackDialog : BaseDialog<TreasureBoxDialogLoveLackBinding>() {
|
||||
if (TimeUtils.isToday(date)) {
|
||||
BoxModel.get()
|
||||
.buyTicket(num)
|
||||
.compose<UserTicketInfo>(bindToLifecycle<UserTicketInfo>())
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError { dealError(it) }
|
||||
.subscribe { userTicketInfo: UserTicketInfo ->
|
||||
ToastUtils.show("購買成功")
|
||||
dismissAllowingStateLoss()
|
||||
@@ -124,6 +125,18 @@ class BoxLoveLackDialog : BaseDialog<TreasureBoxDialogLoveLackBinding>() {
|
||||
})
|
||||
}
|
||||
|
||||
private fun dealError(error: Throwable) {
|
||||
if (error is FailReasonException) {
|
||||
if (error.code == BoxModel.ERROR_CODE_DIAMOND) {
|
||||
newInstance().show(context)
|
||||
} else {
|
||||
SingleToastUtil.showToast(error.message)
|
||||
}
|
||||
} else {
|
||||
SingleToastUtil.showToast(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
EventBus.getDefault().post(BoxLoveEvent())
|
||||
|
@@ -12,8 +12,10 @@ import com.yizhuan.erban.databinding.TreasureBoxDialogBuyLoveBinding
|
||||
import com.yizhuan.erban.event.BoxLoveEvent
|
||||
import com.yizhuan.treasure_box.bean.UserTicketInfo
|
||||
import com.yizhuan.treasure_box.model.BoxModel
|
||||
import com.yizhuan.xchat_android_core.exception.FailReasonException
|
||||
import com.yizhuan.xchat_android_library.common.SpConstants
|
||||
import com.yizhuan.xchat_android_library.common.util.SPUtils
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import com.yizhuan.xchat_android_library.utils.TimeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
@@ -65,7 +67,7 @@ class BuyLoveDialog : BaseDialog<TreasureBoxDialogBuyLoveBinding>() {
|
||||
BoxModel.get()
|
||||
.buyTicket(num)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError { ToastUtils.show(it.message) }
|
||||
.doOnError { dealError(it) }
|
||||
.subscribe { userTicketInfo: UserTicketInfo ->
|
||||
ToastUtils.show("購買成功")
|
||||
dismissAllowingStateLoss()
|
||||
@@ -74,7 +76,7 @@ class BuyLoveDialog : BaseDialog<TreasureBoxDialogBuyLoveBinding>() {
|
||||
BoxModel.get()
|
||||
.buyTicket(num)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError { ToastUtils.show(it.message) }
|
||||
.doOnError { dealError(it) }
|
||||
.subscribe { userTicketInfo: UserTicketInfo ->
|
||||
BuyLoveSuccessDialog.newInstance(num).show(context)
|
||||
dismissAllowingStateLoss()
|
||||
@@ -84,14 +86,25 @@ class BuyLoveDialog : BaseDialog<TreasureBoxDialogBuyLoveBinding>() {
|
||||
BoxModel.get()
|
||||
.buyTicket(num)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError { ToastUtils.show(it.message) }
|
||||
.doOnError { dealError(it) }
|
||||
.subscribe { userTicketInfo: UserTicketInfo ->
|
||||
BuyLoveSuccessDialog.newInstance(num).show(context)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun dealError(error: Throwable) {
|
||||
if (error is FailReasonException) {
|
||||
if (error.code == BoxModel.ERROR_CODE_DIAMOND) {
|
||||
TreasureBoxDialog.newInstance().show(context)
|
||||
} else {
|
||||
SingleToastUtil.showToast(error.message)
|
||||
}
|
||||
} else {
|
||||
SingleToastUtil.showToast(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
|
@@ -6,23 +6,26 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View
|
||||
<ImageView
|
||||
android:id="@+id/view_bg"
|
||||
android:layout_width="240dp"
|
||||
android:layout_height="300dp"
|
||||
android:background="@drawable/treasure_box_bg_love_lack"
|
||||
android:layout_width="@dimen/dp_240"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/treasure_box_bg_love_lack"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.6" />
|
||||
|
||||
<View
|
||||
<ImageView
|
||||
android:id="@+id/view_buy_love"
|
||||
android:layout_width="136dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginBottom="@dimen/dp_30"
|
||||
android:background="@drawable/treasure_box_buy_love"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_48"
|
||||
android:layout_marginEnd="@dimen/dp_48"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/treasure_box_buy_love"
|
||||
app:layout_constraintEnd_toEndOf="@+id/view_bg"
|
||||
app:layout_constraintStart_toStartOf="@+id/view_bg"
|
||||
app:layout_constraintTop_toTopOf="@+id/view_bg" />
|
||||
@@ -52,8 +55,8 @@
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_prize_icon"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_width="@dimen/dp_80"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:scaleType="centerCrop"
|
||||
@@ -84,8 +87,8 @@
|
||||
android:id="@+id/ll_add_num"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
android:layout_marginTop="@dimen/dp_4"
|
||||
android:background="@drawable/ic_add_num_bg"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:background="@drawable/bg_add_num_bg"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="@+id/view_bg"
|
||||
app:layout_constraintStart_toStartOf="@+id/view_bg"
|
||||
@@ -93,17 +96,17 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_sub"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_width="@dimen/dp_40"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:layout_marginTop="@dimen/dp_4"
|
||||
android:src="@drawable/treasure_box_sub_normal" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_num"
|
||||
android:layout_width="66dp"
|
||||
android:layout_height="23dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="center"
|
||||
android:inputType="number"
|
||||
@@ -115,9 +118,9 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_add"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="@dimen/dp_4"
|
||||
android:layout_width="@dimen/dp_40"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/dp_2"
|
||||
android:src="@drawable/treasure_box_add_normal" />
|
||||
|
||||
@@ -125,8 +128,8 @@
|
||||
|
||||
<com.coorchice.library.SuperTextView
|
||||
android:id="@+id/tv_buy"
|
||||
android:layout_width="152dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_width="@dimen/dp_152"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:background="@drawable/btn_box_buy"
|
||||
android:gravity="center"
|
||||
|
@@ -13,6 +13,7 @@ import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
|
||||
import com.yizhuan.xchat_android_core.R;
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.exception.FailReasonException;
|
||||
import com.yizhuan.xchat_android_core.patriarch.exception.PmRoomLimitException;
|
||||
import com.yizhuan.xchat_android_core.super_admin.model.exception.SAdminCannotGameException;
|
||||
import com.yizhuan.xchat_android_library.rxbus.RxBus;
|
||||
@@ -80,16 +81,21 @@ public class RxHelper {
|
||||
if (result.isSuccess()) {
|
||||
if (result.getData() != null) {
|
||||
return Single.just(result.getData());
|
||||
} else {
|
||||
if (handle != null && handle.createT() != null) {
|
||||
return Single.just(handle.createT());
|
||||
}
|
||||
Logger.e(ResUtil.getString(R.string.utils_net_rxhelper_02));
|
||||
return Single.error(new Throwable(ResUtil.getString(R.string.utils_net_rxhelper_03)));
|
||||
}
|
||||
} else {
|
||||
return Single.error(new Throwable(getValidMessage(result)));
|
||||
|
||||
if (handle != null && handle.createT() != null) {
|
||||
return Single.just(handle.createT());
|
||||
}
|
||||
Logger.e(ResUtil.getString(R.string.utils_net_rxhelper_02));
|
||||
return Single.error(new Throwable(ResUtil.getString(R.string.utils_net_rxhelper_03)));
|
||||
}
|
||||
|
||||
if (result.getCode() != 0) {
|
||||
return Single.error(new FailReasonException(result.getMessage(), result.getCode()));
|
||||
}
|
||||
|
||||
return Single.error(new Throwable(getValidMessage(result)));
|
||||
|
||||
}).compose(handleSchedulers()).compose(handleException());
|
||||
}
|
||||
|
||||
@@ -265,9 +271,9 @@ public class RxHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 青少年时长限制。。。实在 太多接口要处理
|
||||
* 写一个通用的
|
||||
*
|
||||
* @param <T> -
|
||||
* @return -
|
||||
*/
|
||||
@@ -286,6 +292,7 @@ public class RxHelper {
|
||||
|
||||
/**
|
||||
* 超管不能玩游戏
|
||||
*
|
||||
* @param <T> -
|
||||
* @return -
|
||||
*/
|
||||
|
@@ -93,7 +93,7 @@ public class BoxModel extends BaseModel implements IBoxModel {
|
||||
@Override
|
||||
public Single<UserTicketInfo> buyTicket(int num) {
|
||||
return api.buyTicket(num)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleCommon())
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user