From 33b889cb7937564e807399d62d77a6082572414b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E7=9A=AE?= <14840170+lao-pi123@user.noreply.gitee.com> Date: Fri, 8 Nov 2024 14:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=9F=E7=9B=B4=E6=92=AD=E9=97=B4PK=E5=88=86?= =?UTF-8?q?=E6=95=B0=E5=92=8C=E6=97=B6=E9=97=B4=E9=97=AA=E7=83=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=E5=AE=8C=E6=88=90--?= =?UTF-8?q?=E5=8C=85=E5=90=ABPK=E4=BA=BA=E6=95=B0=E5=87=8F=E5=B0=91?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E5=88=86=E6=95=B0=E8=BF=98=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/views/LiveRoomViewHolder.java | 78 +++++++++++-------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index ffa8e74fa..19067a6a7 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -6111,35 +6111,40 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void upDataPkScore(JSONArray pkScores, int time) { L.eSw("upDataPkScore(JSONArray pkScores, int time) {" + new Gson().toJson(pkScores)); isShowGif = true; - if (detailsView != null) { - mRoot.removeView(detailsView); + + if (detailsView == null){ + L.eSw("upDataPkScore(JSONArray pkScores, int time) {detailsView=null"); + detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); + timeTitle = detailsView.findViewById(R.id.time_title); + textTime = detailsView.findViewById(R.id.text_time); + linearGrade1 = detailsView.findViewById(R.id.lin_pk1); + linearGrade2 = detailsView.findViewById(R.id.lin_pk2); + linearGrade3 = detailsView.findViewById(R.id.lin_pk3); + linearGrade4 = detailsView.findViewById(R.id.lin_pk4); + textPkName1 = detailsView.findViewById(R.id.text_pk_name1); + textPkName2 = detailsView.findViewById(R.id.text_pk_name2); + textPkName3 = detailsView.findViewById(R.id.text_pk_name3); + textPkName4 = detailsView.findViewById(R.id.text_pk_name4); + textGrade1 = detailsView.findViewById(R.id.text_grade1); + textGrade2 = detailsView.findViewById(R.id.text_grade2); + textGrade3 = detailsView.findViewById(R.id.text_grade3); + textGrade4 = detailsView.findViewById(R.id.text_grade4); + imageGrade1 = detailsView.findViewById(R.id.image_grade1); + imageGrade2 = detailsView.findViewById(R.id.image_grade2); + imageGrade3 = detailsView.findViewById(R.id.image_grade3); + imageGrade4 = detailsView.findViewById(R.id.image_grade4); } - L.eSw("upDataPkScore(JSONArray pkScores, int time) {detailsView=null"); - detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); - timeTitle = detailsView.findViewById(R.id.time_title); - textTime = detailsView.findViewById(R.id.text_time); - linearGrade1 = detailsView.findViewById(R.id.lin_pk1); - linearGrade2 = detailsView.findViewById(R.id.lin_pk2); - linearGrade3 = detailsView.findViewById(R.id.lin_pk3); - linearGrade4 = detailsView.findViewById(R.id.lin_pk4); - textPkName1 = detailsView.findViewById(R.id.text_pk_name1); - textPkName2 = detailsView.findViewById(R.id.text_pk_name2); - textPkName3 = detailsView.findViewById(R.id.text_pk_name3); - textPkName4 = detailsView.findViewById(R.id.text_pk_name4); - textGrade1 = detailsView.findViewById(R.id.text_grade1); - textGrade2 = detailsView.findViewById(R.id.text_grade2); - textGrade3 = detailsView.findViewById(R.id.text_grade3); - textGrade4 = detailsView.findViewById(R.id.text_grade4); - imageGrade1 = detailsView.findViewById(R.id.image_grade1); - imageGrade2 = detailsView.findViewById(R.id.image_grade2); - imageGrade3 = detailsView.findViewById(R.id.image_grade3); - imageGrade4 = detailsView.findViewById(R.id.image_grade4); - //暂时关闭 + + if (detailsView.getParent() == null){ + L.eSw("detailsView 添加到了 mRoot"); + mRoot.addView(detailsView); + } + linearGrade1.setVisibility(View.GONE); linearGrade2.setVisibility(View.GONE); linearGrade3.setVisibility(View.GONE); linearGrade4.setVisibility(View.GONE); - mRoot.addView(detailsView); + mRoot.post(new Runnable() { @Override @@ -6161,6 +6166,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis timeTitle.post(countdownRunnable); } Log.e("多人Pk", "upDataPkScore mPkTimeCount:" + mPkTimeCount); + + + Log.e("TestPK", "pkScores.size(): " + pkScores.size()); for (int i = 0; i < pkScores.size(); i++) { JSONObject score = pkScores.getJSONObject(i); String userNiceName = score.getString("user_nicename"); @@ -6201,6 +6209,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis textGrade2.setText(String.valueOf(userScore)); userId2 = userId; } else if (i == 2) { + // 如果只有三个人 if (pkScores.size() == 3) { linearGrade4.setVisibility(View.VISIBLE); textPkName4.setText(userNiceName); @@ -6208,6 +6217,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis textGrade4.setText(String.valueOf(userScore)); userId4 = userId; } else { + Log.e("TestPK 23332222", "pkScores.size(): " + pkScores.size()); linearGrade3.setVisibility(View.VISIBLE); textPkName3.setText(userNiceName); ImgLoader.displayNew(mContext, resScore, imageGrade3); @@ -6269,11 +6279,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis imageGrade2 = detailsView.findViewById(R.id.image_grade2); imageGrade3 = detailsView.findViewById(R.id.image_grade3); imageGrade4 = detailsView.findViewById(R.id.image_grade4); - //暂时关闭 - linearGrade1.setVisibility(View.GONE); - linearGrade2.setVisibility(View.GONE); - linearGrade3.setVisibility(View.GONE); - linearGrade4.setVisibility(View.GONE); + mRoot.removeView(detailsView); mRoot.addView(detailsView); mRoot.post(new Runnable() { @@ -6291,12 +6297,20 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }); } Log.e("多人Pk", "upDataPkScore mPkTimeCount:" + mPkTimeCount); - if (pkScores.size() == 2) { + /* if (pkScores.size() == 2) { linearGrade3.setVisibility(View.GONE); linearGrade4.setVisibility(View.GONE); } else if (pkScores.size() == 3) { - linearGrade4.setVisibility(View.GONE); - } + linearGrade3.setVisibility(View.GONE); + }*/ + + //暂时关闭 + linearGrade1.setVisibility(View.GONE); + linearGrade2.setVisibility(View.GONE); + linearGrade3.setVisibility(View.GONE); + linearGrade4.setVisibility(View.GONE); + + for (int i = 0; i < pkScores.size(); i++) { JSONObject score = pkScores.getJSONObject(i); String userNiceName = score.getString("user_nicename");