Commit 52aaa9c8 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 33556277
...@@ -167,6 +167,7 @@ public class ShaiziPresenter extends BasePresenter<ShaiziView> { ...@@ -167,6 +167,7 @@ public class ShaiziPresenter extends BasePresenter<ShaiziView> {
int code = baseResponse.getStatus(); int code = baseResponse.getStatus();
switch (code) { switch (code) {
case 200://成功 case 200://成功
view.drawCashSuc();
break; break;
default: default:
view.showToast(baseResponse.getMessage()); view.showToast(baseResponse.getMessage());
......
...@@ -13,4 +13,6 @@ public interface ShaiziView extends BaseView { ...@@ -13,4 +13,6 @@ public interface ShaiziView extends BaseView {
void getShaiziMsgHomefail(); void getShaiziMsgHomefail();
void drawCashSuc();
} }
...@@ -23,7 +23,8 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView { ...@@ -23,7 +23,8 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView {
private var moneys: Double = 0.0 private var moneys: Double = 0.0
private val shaiziPresenter by lazy { ShaiziPresenter() } private val shaiziPresenter by lazy { ShaiziPresenter() }
private var starttime: Long? = null private var starttime: Long? = null
private var shaiziFlag: Int = 0 // 骰子大小 0-小 1-大 private var shaiziFlag: Int = 0 // 骰子大小 0-小 1-
private var dialog: Dialog? = null
override fun getContentViewLayoutID() = R.layout.activity_shaizi override fun getContentViewLayoutID() = R.layout.activity_shaizi
...@@ -88,10 +89,10 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView { ...@@ -88,10 +89,10 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView {
6 -> Glide.with(context).load(R.mipmap.iv_tx_sz6).into(iv_saizi); 6 -> Glide.with(context).load(R.mipmap.iv_tx_sz6).into(iv_saizi);
} }
if(success==1){ if (success == 1) {
showresultDialog("恭喜您!", "本次开奖结果为小,您的收益已翻倍!",true) showresultDialog("恭喜您!", "本次开奖结果为小,您的收益已翻倍!", true)
} else { } else {
showresultDialog("很遗憾!", "本次开奖结果为大,您未中奖,金币已收回。",false) showresultDialog("很遗憾!", "本次开奖结果为大,您未中奖,金币已收回。", false)
} }
// if (shaiziFlag == 1) { // if (shaiziFlag == 1) {
// if (count >= 4) { // if (count >= 4) {
...@@ -117,13 +118,13 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView { ...@@ -117,13 +118,13 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView {
*/ */
private fun showresultDialog(s: String, s1: String, b: Boolean) { private fun showresultDialog(s: String, s1: String, b: Boolean) {
DialogUtils.showWinDialog(this@ShaiziActivity, s, s1, object : DialogListener() { DialogUtils.showWinDialog(this@ShaiziActivity, s, s1, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) { override fun onClick(mydialog: Dialog?, v: View?) {
when (v?.id) { when (v?.id) {
R.id.tv_know -> { R.id.tv_know -> {
//向服务器传递 提现金额 骰子Id //向服务器传递 提现金额 骰子Id
if (b) shaiziPresenter.saveTerminalInfo(moneys, diceId!!) if (b) shaiziPresenter.saveTerminalInfo(moneys, diceId!!)
dialog?.dismiss()
finish() dialog = mydialog
} }
} }
} }
...@@ -163,7 +164,7 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView { ...@@ -163,7 +164,7 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView {
diceId = data.diceId diceId = data.diceId
//执行延时,旋转骰子,显示结果 //执行延时,旋转骰子,显示结果
startShaizi(System.currentTimeMillis(),data.success) startShaizi(System.currentTimeMillis(), data.success)
} }
/** /**
...@@ -188,6 +189,11 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView { ...@@ -188,6 +189,11 @@ class ShaiziActivity : BaseActivity(), View.OnClickListener, ShaiziView {
} }
} }
override fun drawCashSuc() {
dialog?.dismiss()
finish()
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment