From 05e4ff89d79c7681ca7c1aa2851b676a3d349e7b Mon Sep 17 00:00:00 2001 From: Martin <13046765170@163.com> Date: Thu, 13 Jun 2024 18:25:43 +0800 Subject: [PATCH] =?UTF-8?q?add[=E4=BF=AE=E5=BE=A9BUG=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=96=8B=E6=92=AD=E6=95=B4=E8=A0=B1IM=E6=B6=88?= =?UTF-8?q?=E6=81=AF]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../live/activity/LiveRyAnchorActivity.java | 1 + .../com/yunbao/live/adapter/ComboAdapter.java | 1 - .../yunbao/live/adapter/LiveChatAdapter.java | 9 +- .../com/yunbao/live/adapter/PrankAdapter.java | 87 +++++--- .../com/yunbao/live/bean/LiveChatBean.java | 1 + .../dialog/LivePrankAddGiftNumberDialog.java | 2 +- .../live/dialog/LivePrankDialogFragment.java | 1 + .../yunbao/live/views/LiveRoomViewHolder.java | 185 ++++++++++++------ .../res/layout/dialog_live_prank_add_gift.xml | 3 +- .../dialog_live_prank_add_gift_number.xml | 1 - .../main/res/layout/item_prank_progress.xml | 9 +- live/src/main/res/layout/view_prank_group.xml | 11 ++ live/src/main/res/values-en/strings.xml | 4 +- 13 files changed, 216 insertions(+), 99 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index f35818ea6..da2f9d3d7 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -882,6 +882,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl //加载整蛊 if(mLiveRoomViewHolder!=null){ mLiveRoomViewHolder.initPrankProgress(); + mLiveRoomViewHolder.sendMsgPrank(); } } diff --git a/live/src/main/java/com/yunbao/live/adapter/ComboAdapter.java b/live/src/main/java/com/yunbao/live/adapter/ComboAdapter.java index ca265bf41..3f9b18ba6 100644 --- a/live/src/main/java/com/yunbao/live/adapter/ComboAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/ComboAdapter.java @@ -62,7 +62,6 @@ public class ComboAdapter extends RecyclerView.Adapter { +public class PrankAdapter extends RecyclerView.Adapter { private List mList = new ArrayList<>(); private Context mContext; private boolean isAn; + public static final int TYPE_GIFT = 1; + public static final int TYPE_COMBO = 2; + private int viewType1 = TYPE_GIFT; + public PrankAdapter(Context context){ mContext = context; } + public void setViewType(int viewType) { + this.viewType1 = viewType; + } public void setList(List list){ mList.clear(); @@ -48,38 +56,51 @@ public class PrankAdapter extends RecyclerView.Adapter onItemClickListener.onItemClick(v,data.getGift_id())); - holder.prank_item_subscript.setText(String.valueOf(data.getCompleted_num())); - holder.prank_item_prank_name.setText(data.getPrank_content()); - holder.prank_item_gift_name.setText(WordUtil.isNewZh() ? data.getGift_name() : data.getGift_name_en()); - holder.prank_item_now_progress.setText(String.valueOf(data.getSend_num())); - holder.prank_item_total_progress.setText("/"+ data.getGift_num()); - ImgLoader.display(mContext,data.getGift_icon(),holder.prank_item_icon); - holder.prank_item_progress.setMax(data.getGift_num()); - holder.prank_item_progress.setProgress(data.getSend_num()); - holder.an_prank_name.setText(WordUtil.isNewZh() ? data.getGift_name() : data.getGift_name_en()); - holder.an_prank_remove.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - onItemClickListener.onItemDel(data.getGift_id()); + if(viewHolder instanceof MyViewHolder){ + MyViewHolder holder = (MyViewHolder) viewHolder; + holder.itemView.setOnClickListener(v-> onItemClickListener.onItemClick(v,data.getGift_id())); + holder.prank_item_subscript.setText(String.valueOf(data.getCompleted_num())); + holder.prank_item_prank_name.setText(data.getPrank_content()); + holder.prank_item_gift_name.setText(WordUtil.isNewZh() ? data.getGift_name() : data.getGift_name_en()); + holder.prank_item_now_progress.setText(String.valueOf(data.getSend_num())); + holder.prank_item_total_progress.setText("/"+ data.getGift_num()); + ImgLoader.display(mContext,data.getGift_icon(),holder.prank_item_icon); + holder.prank_item_progress.setMax(data.getGift_num()); + holder.prank_item_progress.setProgress(data.getSend_num()); + holder.an_prank_name.setText(data.getPrank_content()); + holder.an_prank_remove.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + onItemClickListener.onItemDel(data.getGift_id()); + } + }); + if(isAn){ + holder.anLayout.setVisibility(View.VISIBLE); + holder.progressLayout.setVisibility(View.GONE); + holder.nameLayout.setVisibility(View.GONE); + }else{ + holder.anLayout.setVisibility(View.GONE); + holder.progressLayout.setVisibility(View.VISIBLE); + holder.nameLayout.setVisibility(View.VISIBLE); } - }); - if(isAn){ - holder.anLayout.setVisibility(View.VISIBLE); - holder.progressLayout.setVisibility(View.GONE); - holder.nameLayout.setVisibility(View.GONE); }else{ - holder.anLayout.setVisibility(View.GONE); - holder.progressLayout.setVisibility(View.VISIBLE); - holder.nameLayout.setVisibility(View.VISIBLE); + MyComboViewHolder holder = (MyComboViewHolder) viewHolder; + holder.itemView.setOnClickListener(v-> onItemClickListener.onItemClick(v,data.getGift_id())); + holder.combo_item_prank_name.setText(data.getPrank_content()); + ImgLoader.display(mContext,data.getGift_icon(),holder.combo_item_icon); + holder.combo_item_combo.setText(String.valueOf(data.getSend_num())); } } @@ -116,6 +137,20 @@ public class PrankAdapter extends RecyclerView.Adapter prankAndComboList = new ArrayList<>(); - private JsonElement completedList = new JsonArray(); - + private List completedList = new ArrayList<>(); + private int isPrank; private boolean prankAnisShow; - + private LinearLayout prank_top_layout; + private ImageView prank_group_top_icon; public LiveRoomViewHolder setGuardType(int guardType) { this.guardType = guardType; return this; } + @Override + protected int getLayoutId() { + return R.layout.view_live_room; + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onUpdata(String str) { if ("svga_new_user_gif".equals(str)) { @@ -736,11 +743,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis sudNameHandler.postDelayed(sudNameRunnable, 10000); } - @Override - protected int getLayoutId() { - return R.layout.view_live_room; - } - private View sudGameMin; public void onShowHideEvent() { @@ -1367,20 +1369,36 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mLiveChatAdapter.removetItem(bean); ((LiveActivity) mContext).sendChatMessage("Hi~", null, null); } else if (bean.getType() == -5) { - String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Turntable&a=tricky"; - url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" - + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0); + String url = CommonAppConfig.HOST + "/h5/activity/Turntable/index.html"; + url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + + CommonAppConfig.getInstance().getToken() + + "&active_id=6"; Log.i("tag", url); Bundle bundle1 = new Bundle(); bundle1.putString("url", url); LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment(); liveHDDialogFragment.setArguments(bundle1); - liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + if(mContext instanceof LiveAudienceActivity){ + liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + }else if(mContext instanceof LiveRyAnchorActivity){ + liveHDDialogFragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + } } else if (bean.getType() == RECOMMEND_CARD_NOTIFY) { gotoLive(bean.getMsgModel().getAnchorId()); } else if (bean.getType() == bean.STAR_CHALLENGE_UPGRADE_NOTIFY) { gotoLive(bean.getMsgModel().getLiveUid()); - } else { + } else if(bean.getType()==bean.TYPE_TO_ANCHOR_PRANK){ + LivePrankDialogFragment fragment = new LivePrankDialogFragment(); + fragment.setOnPrankResultListener(new LivePrankDialogFragment.onPrankResultListener() { + @Override + public void OpenAndCloseListener() { + initPrankProgress(); + } + }); + fragment.setmLiveUid(mLiveUid); + fragment.show(((LiveRyAnchorActivity)mContext).getSupportFragmentManager(), "LivePrankDialogFragment"); + mLiveAnchorViewHolder.closeMenuRed(); + }else{ showUserDialog(bean.getId()); } } @@ -1651,6 +1669,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis // dragonImmediateParticipation.setVisibility(View.GONE); //整蛊转盘优化更新 + prank_top_layout= (LinearLayout) findViewById(R.id.prank_top_layout); + prank_group_top_icon= (ImageView) findViewById(R.id.prank_group_top_icon); prank_group = findViewById(R.id.prank_group);//浮窗 prank_group_title = (TextView) findViewById(R.id.prank_group_title);//浮窗标题 recycler_prank = (RecyclerView) findViewById(R.id.recycler_prank);//列表 @@ -1661,18 +1681,18 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis //点击文字转盘整蛊(跳转转盘整蛊) prank_group_turntable.setOnClickListener(v->{ prankAnisShow = !prankAnisShow; - List tempList = new ArrayList<>(); - for (int i = 0; i >() { - @Override - public void onSuccess(List data) { - - } - - @Override - public void onError(String error) { - - } - }); - L.e("onItemDel:"+giftId); - } - }); - - //连击投票礼物点击 - comboAdapter.addOnItemClickListener((view, giftId) -> { -// LogUtils.e("yqw=====>点击投票礼物:"+giftId); - openGiftDialog(String.valueOf(giftId)); - }); + initPrankAdapter(); } + public void sendMsgPrank(){ + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + LiveChatBean bean = new LiveChatBean(); + bean.setContent("开播整蛊通知"); + bean.setType(LiveChatBean.TYPE_TO_ANCHOR_PRANK); + mLiveChatAdapter.insertItem(bean); + } + }, 1000); + } + //初始化整蛊列表进度 public void initPrankProgress(){ + prankAnisShow = false; //默认展示整蛊列表 // LogUtils.e("yqw=====>主播id:"+mLiveUid); //获取整蛊列表 LiveNetManager.get(mContext).getPrankProgressList(mLiveUid, new com.yunbao.common.http.base.HttpCallback() { @Override public void onSuccess(PrankProgressBean data) { // LogUtils.e("yqw=====>整蛊列表:"+data); + + isPrank = data.getPrank_type(); prankAndComboList.clear(); prankAndComboList.addAll(data.getPrank_list()); + completedList.clear(); + completedList.addAll(data.getCompleted_list()); setPrankList(data.getStatus(),data.getPrank_type(),data.getPrank_turntable_status()); } @@ -1781,6 +1787,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis // LogUtils.e("yqw=====>整蛊礼物数据2:"+prankList.toString()); prankAndComboList.clear(); prankAndComboList.addAll(prankList); + + String completedString = ctString.getString("completed_list"); + List completeds = GsonUtils.fromJson(completedString,new TypeToken>() {}.getType()); + completedList.clear(); + completedList.addAll(completeds); + setPrankList(Integer.parseInt(ctString.getString("status")), Integer.parseInt(ctString.getString("prank_type")), Integer.parseInt(ctString.getString("prank_turntable_status"))); } }catch (Exception e){ @@ -1788,7 +1800,36 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } + private void initPrankAdapter() { + prankAdapter = new PrankAdapter(mContext); + //整蛊礼物点击 + prankAdapter.addOnItemClickListener(new PrankAdapter.OnItemClickListener() { + @Override + public void onItemClick(View view, int giftId) { + if(CommonAppConfig.getInstance().getUid().equals(mLiveUid)){ + return; + } + openGiftDialog(String.valueOf(giftId)); + } + @Override + public void onItemDel(int giftId) { + LiveNetManager.get(mContext).anchorClickFinish(mLiveUid, String.valueOf(giftId), new com.yunbao.common.http.base.HttpCallback>() { + @Override + public void onSuccess(List data) { + + } + + @Override + public void onError(String error) { + + } + }); + L.e("onItemDel:"+giftId); + } + }); + + } //设置整蛊礼物数据 private void setPrankList(int status,int mPrankType,int prankTurntableStatus){ // LogUtils.e("yqw=====>显示转盘icon:是否显示:"+(prankTurntableStatus == 1)+",是否在倒计时"+(lt_trickery.getVisibility() == View.VISIBLE)); @@ -1800,21 +1841,36 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis // LogUtils.e("yqw=====>显示整蛊列表或者投票列表:"+status); if (status == 1){ prank_group.setVisibility(View.VISIBLE); - if (mPrankType == 1){ + initPrankAdapter(); + if (mPrankType == 1){//礼物 sortByCompletionRate(prankAndComboList); + prankAdapter.setViewType(PrankAdapter.TYPE_GIFT); prankAdapter.setList(prankAndComboList); - recycler_prank.setAdapter(prankAdapter); - if(CommonAppConfig.getInstance().getUid().equals(mLiveUid)){ - prank_group_turntable.setVisibility(View.VISIBLE); - }else{ - prank_group_turntable.setVisibility(View.GONE); - } - }else { + }else { //连击 sortBySendNum(prankAndComboList); - comboAdapter.setList(prankAndComboList); - recycler_prank.setAdapter(comboAdapter); - prank_group_title.setText(R.string.combo_vote); + prankAdapter.setViewType(PrankAdapter.TYPE_COMBO); + prankAdapter.setList(prankAndComboList); +// prank_group_title.setText(R.string.combo_vote); } + if(CommonAppConfig.getInstance().getUid().equals(mLiveUid)){ + + prank_top_layout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + prank_group.setVisibility(View.GONE); + prank_small_icon.setVisibility(View.VISIBLE); + } + }); + prank_group_top_icon.setVisibility(View.VISIBLE); + if(mPrankType==1){ + prank_group_turntable.setVisibility(View.VISIBLE); + } + prank_group_bottom_icon.setVisibility(View.GONE); + }else{ + prank_group_turntable.setVisibility(View.GONE); + prank_group_top_icon.setVisibility(View.GONE); + } + recycler_prank.setAdapter(prankAdapter); //主播可能打开整蛊功能,但是不设置整蛊礼物,这里会是空列表 if (!prankAndComboList.isEmpty()){ limitItem(mPrankType,Math.min(prankAndComboList.size(), 4)); @@ -1828,6 +1884,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } + //根据完成度排序 private void sortByCompletionRate(List items) { Collections.sort(items, (item1, item2) -> Double.compare(item2.getCompletionRate(), item1.getCompletionRate())); diff --git a/live/src/main/res/layout/dialog_live_prank_add_gift.xml b/live/src/main/res/layout/dialog_live_prank_add_gift.xml index 1f131a424..b372b4e53 100644 --- a/live/src/main/res/layout/dialog_live_prank_add_gift.xml +++ b/live/src/main/res/layout/dialog_live_prank_add_gift.xml @@ -157,7 +157,8 @@ android:layout_height="43dp" android:layout_gravity="center" android:background="@drawable/bg_prank_coin" - android:ems="10" + android:ems="20" + android:maxLength="20" android:gravity="start|center" android:hint="@string/live_prank_gift_add_gift_contnet_select" android:paddingStart="12dp" diff --git a/live/src/main/res/layout/dialog_live_prank_add_gift_number.xml b/live/src/main/res/layout/dialog_live_prank_add_gift_number.xml index 46cad6c58..8ff0793ab 100644 --- a/live/src/main/res/layout/dialog_live_prank_add_gift_number.xml +++ b/live/src/main/res/layout/dialog_live_prank_add_gift_number.xml @@ -55,7 +55,6 @@ android:layout_marginEnd="16dp" android:layout_marginBottom="16dp" android:orientation="vertical" - app:layout_constraintBottom_toTopOf="@+id/gift_add_btn" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/title"> diff --git a/live/src/main/res/layout/item_prank_progress.xml b/live/src/main/res/layout/item_prank_progress.xml index 815610b82..eb97fc70b 100644 --- a/live/src/main/res/layout/item_prank_progress.xml +++ b/live/src/main/res/layout/item_prank_progress.xml @@ -109,8 +109,11 @@ + + Join the fan group can be opened [Join] Join the fan group to open - Tricky progress - Turntable + Progress + To do Details> Combo Most first