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