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();