From b35d5d242e34d66f2a1bec55cb40a668c6bd7fa0 Mon Sep 17 00:00:00 2001 From: hch <16607480311@163.com> Date: Fri, 1 Dec 2023 13:33:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=94=AF=E4=BB=98=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/bean/IMLoginModel.java | 4 +- .../yunbao/common/fragment/LoadingDialog.java | 8 ++- .../main/activity/MyWalletActivity.java | 55 ++++++++++++++++--- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java b/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java index c9c22e008..3af47f163 100644 --- a/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java +++ b/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java @@ -204,7 +204,7 @@ public class IMLoginModel extends BaseModel { @SerializedName("votes") private String votes; @SerializedName("yuanbao") - private long yuanbao; + private double yuanbao; @SerializedName("list") private List> list; @SerializedName("slide") @@ -825,7 +825,7 @@ public class IMLoginModel extends BaseModel { return this; } - public long getYuanbao() { + public double getYuanbao() { return yuanbao; } diff --git a/common/src/main/java/com/yunbao/common/fragment/LoadingDialog.java b/common/src/main/java/com/yunbao/common/fragment/LoadingDialog.java index a0abccd54..d8bf15147 100644 --- a/common/src/main/java/com/yunbao/common/fragment/LoadingDialog.java +++ b/common/src/main/java/com/yunbao/common/fragment/LoadingDialog.java @@ -17,9 +17,11 @@ public class LoadingDialog extends AbsDialogFragment { private TextView hint; private String showText = ""; + public boolean isShow; + public void setShowText(String showText) { this.showText = showText; - + isShow = true; } @Override @@ -44,19 +46,21 @@ public class LoadingDialog extends AbsDialogFragment { hint = (TextView) findViewById(R.id.hint); dots.start(); hint.setText(showText); + isShow = true; } public void setHintText(String text) { if (hint != null) { hint.setText(text); } + isShow = true; } - @Override public void onDestroy() { super.onDestroy(); dots.stop(); + isShow = false; } @Override diff --git a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java index 3660b589f..28fda0513 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java @@ -27,6 +27,7 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.pay.hw.HwBuilder; import com.yunbao.common.utils.GoogleUtils; +import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.R; @@ -62,6 +63,8 @@ public class MyWalletActivity extends AbsActivity { HwBuilder hwBuilder; GoogleUtils googleUtils; + LoadingDialog loadingDialog; + @Override protected int getLayoutId() { return R.layout.activity_my_wallet; @@ -88,7 +91,7 @@ public class MyWalletActivity extends AbsActivity { RouteUtil.forwardRedPacketList(); }); rView.setOnClickListener(v -> { - LoadingDialog loadingDialog = new LoadingDialog(); + loadingDialog = new LoadingDialog(); loadingDialog.show(getSupportFragmentManager(), "LoadingDialog"); loadingDialog.setShowText(getString(R.string.order_query)); @@ -99,8 +102,8 @@ public class MyWalletActivity extends AbsActivity { try { int code = obj.getInt("querySize"); if (code == 0) { - payHandler.post(() -> loadingDialog.setHintText(getString(R.string.order_query_success))); - payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000); + payHandler.post(runnable1); + payHandler.postDelayed(runnable2, 1000); } else { JSONArray tokenList = obj.getJSONArray("tokenList"); JSONArray orderList = obj.getJSONArray("orderList"); @@ -139,11 +142,11 @@ public class MyWalletActivity extends AbsActivity { googleUtils.queryPurchasesAsync(); } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) { hwBuilder.consume(); - payHandler.postDelayed(() -> loadingDialog.setHintText(getString(R.string.order_query_success)), 1000); - payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000); + payHandler.postDelayed(runnable1, 1000); + payHandler.postDelayed(runnable2, 1000); } else { - loadingDialog.setShowText(getString(R.string.order_query_success)); - payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000); + payHandler.post(runnable1); + payHandler.postDelayed(runnable2, 1000); } }); @@ -347,6 +350,44 @@ public class MyWalletActivity extends AbsActivity { } } + private Runnable runnable1 = new Runnable() { + @Override + public void run() { + loadingDialog.setHintText(getString(R.string.order_query_success)); + } + }; + + private Runnable runnable2 = new Runnable() { + @Override + public void run() { + if (loadingDialog != null) { + if (loadingDialog.isShow) { + loadingDialog.dismiss(); + } + } + } + }; + + @Override + protected void onPause() { + super.onPause(); + CommonHttpUtil.cancel("Charge.Google_sec_pay"); + if (payHandler != null) { + payHandler.removeCallbacks(runnable1); + payHandler.removeCallbacks(runnable2); + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + CommonHttpUtil.cancel("Charge.Google_sec_pay"); + if (payHandler != null) { + payHandler.removeCallbacks(runnable1); + payHandler.removeCallbacks(runnable2); + } + } + @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data);