From 0ea92c00a2604d148c0bd1fe296578834c4bdd98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=89=8D=E5=8D=AB?= <2298122580@qq.com> Date: Thu, 18 Jul 2024 17:31:44 +0800 Subject: [PATCH] =?UTF-8?q?6.8.0:=E5=B0=8F=E6=B8=B8=E6=88=8F=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E7=95=8C=E9=9D=A2,=E8=A7=82=E4=BC=97=E8=A7=86?= =?UTF-8?q?=E8=A7=92=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dialog/SudGameDoubleDialog.java | 83 +++++++++++-------- 1 file changed, 49 insertions(+), 34 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameDoubleDialog.java b/common/src/main/java/com/yunbao/common/dialog/SudGameDoubleDialog.java index 96aefe35c..e79374df3 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameDoubleDialog.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameDoubleDialog.java @@ -43,6 +43,7 @@ public class SudGameDoubleDialog extends AbsDialogCenterPopupWindow{ private AppCompatTextView sub_win_name,sub_win_score,sub_loss_name,sub_loss_score,sub_time; private CountDownTimer countDownTimer; private List settleBeans = new ArrayList<>(); + private boolean containMe; @Override public void buildDialog(XPopup.Builder builder) { @@ -89,48 +90,62 @@ public class SudGameDoubleDialog extends AbsDialogCenterPopupWindow{ sortByWinNum(settleBeans); SudSettleBean sudSettleBean1 = settleBeans.get(0); // 第一名 SudSettleBean sudSettleBean2 = settleBeans.get(1); // 第二名 + checkMe(sudSettleBean1.getUid(),sudSettleBean2.getUid());//判断这场对局是不是包含自己 - ImgLoader.display(mContext,sudSettleBean1.getAvatar_url(),sub_win_head); - ImgLoader.display(mContext,sudSettleBean2.getAvatar_url(),sub_loss_head); - sub_win_name.setText(sudSettleBean1.getNick_name()); - sub_loss_name.setText(sudSettleBean2.getNick_name()); - if (sudSettleBean1.getWin_num()>0){ - sub_win_score.setText("+"+sudSettleBean1.getWin_num()); - }else { - sub_win_score.setText(String.valueOf(sudSettleBean1.getWin_num())); - } - sub_loss_score.setText(String.valueOf(sudSettleBean2.getWin_num())); + // 检查是否是当前用户 + boolean isFirstMe = CommonAppConfig.getInstance().getUid().equals(sudSettleBean1.getUid()); + boolean isDraw = sudSettleBean1.getWin_num() == sudSettleBean2.getWin_num(); + boolean isZh = WordUtil.isNewZh(); - if (sudSettleBean1.getWin_num() == sudSettleBean2.getWin_num()){ - //平局 - if (WordUtil.isNewZh()){ - sub_title.setImageResource(R.mipmap.sub_draw_zh); - }else { - sub_title.setImageResource(R.mipmap.sub_draw_en); + if (containMe) { + // 当前用户在游戏中 + SudSettleBean winBean = isFirstMe ? sudSettleBean1 : sudSettleBean2; + SudSettleBean lossBean = isFirstMe ? sudSettleBean2 : sudSettleBean1; + + ImgLoader.display(mContext, winBean.getAvatar_url(), sub_win_head); + ImgLoader.display(mContext, lossBean.getAvatar_url(), sub_loss_head); + sub_win_name.setText(winBean.getNick_name()); + sub_loss_name.setText(lossBean.getNick_name()); + + sub_win_score.setText(winBean.getWin_num() > 0 ? "+" + winBean.getWin_num() : String.valueOf(winBean.getWin_num())); + sub_loss_score.setText(String.valueOf(lossBean.getWin_num())); + + if (isDraw) { + // 平局 + sub_title.setImageResource(isZh ? R.mipmap.sub_draw_zh : R.mipmap.sub_draw_en); + sub_win_hat.setVisibility(View.GONE); + } else { + // 胜利或失败 + sub_title.setImageResource(isZh ? (isFirstMe ? R.mipmap.sub_win_zh : R.mipmap.sub_loss_zh) : (isFirstMe ? R.mipmap.sub_win_en : R.mipmap.sub_loss_en)); + sub_win_hat.setVisibility(View.VISIBLE); } - sub_win_hat.setVisibility(View.GONE); - }else { - //有胜负 - sub_win_hat.setVisibility(View.VISIBLE); - if (CommonAppConfig.getInstance().getUid().equals(sudSettleBean1.getUid())){ - //本人胜利 - if (WordUtil.isNewZh()){ - sub_title.setImageResource(R.mipmap.sub_win_zh); - }else { - sub_title.setImageResource(R.mipmap.sub_win_en); - } - }else { - //本人失败 - if (WordUtil.isNewZh()){ - sub_title.setImageResource(R.mipmap.sub_loss_zh); - }else { - sub_title.setImageResource(R.mipmap.sub_loss_en); - } + } else { + // 当前用户不在游戏中 + ImgLoader.display(mContext, sudSettleBean1.getAvatar_url(), sub_win_head); + ImgLoader.display(mContext, sudSettleBean2.getAvatar_url(), sub_loss_head); + sub_win_name.setText(sudSettleBean1.getNick_name()); + sub_loss_name.setText(sudSettleBean2.getNick_name()); + + sub_win_score.setText(sudSettleBean1.getWin_num() > 0 ? "+" + sudSettleBean1.getWin_num() : String.valueOf(sudSettleBean1.getWin_num())); + sub_loss_score.setText(String.valueOf(sudSettleBean2.getWin_num())); + + if (isDraw) { + // 平局 + sub_title.setImageResource(isZh ? R.mipmap.sub_draw_zh : R.mipmap.sub_draw_en); + sub_win_hat.setVisibility(View.GONE); + } else { + // 非当前用户的胜利 + sub_title.setImageResource(isZh ? R.mipmap.sub_win_zh : R.mipmap.sub_win_en); + sub_win_hat.setVisibility(View.VISIBLE); } } } } + private void checkMe(String id1,String id2){ + containMe = CommonAppConfig.getInstance().getUid().equals(id1) || CommonAppConfig.getInstance().getUid().equals(id2); + } + @Override protected void onShow() { super.onShow();