From 0b6c188e0a7deb3a0cbeafc6b6e1649146523018 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 9 Nov 2022 18:27:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=A0=8F:=E4=BE=A7=E8=BE=B9?= =?UTF-8?q?=E6=A0=8F=E7=95=8C=E9=9D=A2=E5=AE=8C=E6=88=90=EF=BC=8C=E6=96=87?= =?UTF-8?q?=E5=AD=97=E6=B6=88=E6=81=AF=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/CustomDrawerPopupAdapter.java | 18 ++- .../common/adapter/RecommendAdapter.java | 48 ++++++++ .../com/yunbao/common/bean/IMLoginModel.java | 2 +- .../common/views/CustomDrawerPopupView.java | 9 ++ .../views/RecommendChildViewHolder.java | 42 +++++++ .../common/views/RecommendViewHolder.java | 28 +++++ .../views/SidebarLiveItemViewHolder.java | 9 +- .../res/layout/item_sidebar_lives_new.xml | 46 ++++++++ common/src/main/res/layout/view_recommend.xml | 49 ++++++++- .../main/res/mipmap-xxhdpi/icon_change.png | Bin 0 -> 2018 bytes .../live/activity/LiveAudienceActivity.java | 51 +++------ .../yunbao/live/adapter/SidebarAdapter.java | 2 +- .../com/yunbao/live/utils/LiveTextRender.java | 104 +++++++----------- 13 files changed, 294 insertions(+), 114 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/adapter/RecommendAdapter.java create mode 100644 common/src/main/java/com/yunbao/common/views/RecommendChildViewHolder.java rename {live/src/main/java/com/yunbao/live => common/src/main/java/com/yunbao/common}/views/SidebarLiveItemViewHolder.java (91%) create mode 100644 common/src/main/res/layout/item_sidebar_lives_new.xml create mode 100644 common/src/main/res/mipmap-xxhdpi/icon_change.png diff --git a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java index d1c6c4847..b0cc3c2fd 100644 --- a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java @@ -9,6 +9,7 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.R; +import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.views.DrawerRecommendViewHolder; import com.yunbao.common.views.DrawerTaskViewHolder; @@ -30,6 +31,7 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { private final int FUN_GAMES = 3; private final int RIGHTS_INTERESTS = 4; private final int RECOMMEND = 5; + private List list = new ArrayList<>(); private List infoModels = new ArrayList<>(); @@ -37,6 +39,11 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { this.mContext = mContext; } + public CustomDrawerPopupAdapter setList(List list) { + this.list = list; + return this; + } + @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { @@ -64,15 +71,20 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { if (holder instanceof DrawerRecommendViewHolder) { DrawerRecommendViewHolder recommendViewHolder = (DrawerRecommendViewHolder) holder; recommendViewHolder.setData(infoModels.get(position)); - }else if (holder instanceof DrawerTaskViewHolder) { + } else if (holder instanceof DrawerTaskViewHolder) { DrawerTaskViewHolder taskViewHolder = (DrawerTaskViewHolder) holder; taskViewHolder.setData(infoModels.get(position)); - }else if (holder instanceof FunGamesViewHolder) { + } else if (holder instanceof FunGamesViewHolder) { FunGamesViewHolder funGamesViewHolder = (FunGamesViewHolder) holder; funGamesViewHolder.setData(infoModels.get(position)); - }else if (holder instanceof RigtsInterestsViewHolder) { + } else if (holder instanceof RigtsInterestsViewHolder) { RigtsInterestsViewHolder rigtsInterestsViewHolder = (RigtsInterestsViewHolder) holder; rigtsInterestsViewHolder.setData(infoModels.get(position)); + } else if (holder instanceof RecommendViewHolder) { + + RecommendViewHolder recommendViewHolder = (RecommendViewHolder) holder; + recommendViewHolder.setData(infoModels.get(position)); + recommendViewHolder.updateData(list); } } diff --git a/common/src/main/java/com/yunbao/common/adapter/RecommendAdapter.java b/common/src/main/java/com/yunbao/common/adapter/RecommendAdapter.java new file mode 100644 index 000000000..935608060 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/RecommendAdapter.java @@ -0,0 +1,48 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.AnchorRecommendItemModel; +import com.yunbao.common.views.RecommendChildViewHolder; + +import java.util.ArrayList; +import java.util.List; + +public class RecommendAdapter extends RecyclerView.Adapter { + private List list = new ArrayList<>(); + private Context mContext; + + public RecommendAdapter(Context mContext) { + this.mContext = mContext; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new RecommendChildViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_sidebar_lives_new, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + + RecommendChildViewHolder itemViewHolder = (RecommendChildViewHolder) holder; + itemViewHolder.setData(list.get(position)); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public void updateData(List mList) { + list.clear(); + list.addAll(mList); + notifyDataSetChanged(); + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java b/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java index 05dac447d..e7cbf396a 100644 --- a/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java +++ b/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java @@ -687,7 +687,7 @@ public class IMLoginModel extends BaseModel { * @return */ public boolean anchorUserType() { - return !TextUtils.equals("C", usersType); + return TextUtils.equals("C", usersType); } public IMLoginModel setUsersType(String usersType) { diff --git a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java index 0aabefe86..237c664c5 100644 --- a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java +++ b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java @@ -9,10 +9,12 @@ import androidx.recyclerview.widget.RecyclerView; import com.lxj.xpopup.core.DrawerPopupView; import com.yunbao.common.R; import com.yunbao.common.adapter.CustomDrawerPopupAdapter; +import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.utils.ToastUtil; +import java.util.ArrayList; import java.util.List; public class CustomDrawerPopupView extends DrawerPopupView { @@ -20,6 +22,12 @@ public class CustomDrawerPopupView extends DrawerPopupView { private RecyclerView drawerList; private CustomDrawerPopupAdapter adapter; + private List list = new ArrayList<>(); + + public CustomDrawerPopupView setList(List list) { + this.list = list; + return this; + } public CustomDrawerPopupView(@NonNull Context context) { super(context); @@ -43,6 +51,7 @@ public class CustomDrawerPopupView extends DrawerPopupView { private void initView() { drawerList = findViewById(R.id.drawerList); adapter = new CustomDrawerPopupAdapter(mContext); + adapter.setList(list); drawerList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); drawerList.setAdapter(adapter); } diff --git a/common/src/main/java/com/yunbao/common/views/RecommendChildViewHolder.java b/common/src/main/java/com/yunbao/common/views/RecommendChildViewHolder.java new file mode 100644 index 000000000..6f7957c7e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/RecommendChildViewHolder.java @@ -0,0 +1,42 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.squareup.picasso.Picasso; +import com.yunbao.common.R; +import com.yunbao.common.bean.AnchorRecommendItemModel; +import com.yunbao.common.glide.ImgLoader; + +public class RecommendChildViewHolder extends RecyclerView.ViewHolder { + private ImageView cover; + private ImageView liveType; + private TextView name; + + public RecommendChildViewHolder(@NonNull View itemView) { + super(itemView); + cover = itemView.findViewById(R.id.cover); + liveType = itemView.findViewById(R.id.live_type); + name = itemView.findViewById(R.id.name); + } + + public void setData(AnchorRecommendItemModel bean) { + Context mContext = itemView.getContext(); + if (bean.getContentPicSizeTwo() != null && !bean.getContentPicSizeTwo().equals("")) { + Picasso.with(mContext) + .load(bean.getContentPicSizeTwo()) + .into(liveType); + } else if (bean.getContentPicSizeThree() != null && !bean.getContentPicSizeThree().equals("")) { + Picasso.with(mContext) + .load(bean.getContentPicSizeThree()) + .into(liveType); + } + ImgLoader.display(itemView.getContext(), bean.getThumb(), cover); + name.setText(bean.getUserNicename()); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/RecommendViewHolder.java b/common/src/main/java/com/yunbao/common/views/RecommendViewHolder.java index d91499f51..a68bb0a30 100644 --- a/common/src/main/java/com/yunbao/common/views/RecommendViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/RecommendViewHolder.java @@ -1,13 +1,41 @@ package com.yunbao.common.views; import android.view.View; +import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.yunbao.common.R; +import com.yunbao.common.adapter.RecommendAdapter; +import com.yunbao.common.bean.AnchorRecommendItemModel; +import com.yunbao.common.bean.CustomSidebarInfoModel; + +import java.util.List; + public class RecommendViewHolder extends RecyclerView.ViewHolder { + private TextView sendGoodGift, subtitle; + private RecyclerView childList; + private RecommendAdapter recommendAdapter; + public RecommendViewHolder(@NonNull View itemView) { super(itemView); + sendGoodGift = itemView.findViewById(R.id.send_good_gift); + subtitle = itemView.findViewById(R.id.subtitle); + childList = itemView.findViewById(R.id.child_list); + recommendAdapter = new RecommendAdapter(itemView.getContext()); + childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 3)); + childList.setAdapter(recommendAdapter); + } + + public void setData(CustomSidebarInfoModel model) { + sendGoodGift.setText(model.getTitle()); + subtitle.setText(model.getSubtitle()); + } + + public void updateData(List list) { + recommendAdapter.updateData(list); } } diff --git a/live/src/main/java/com/yunbao/live/views/SidebarLiveItemViewHolder.java b/common/src/main/java/com/yunbao/common/views/SidebarLiveItemViewHolder.java similarity index 91% rename from live/src/main/java/com/yunbao/live/views/SidebarLiveItemViewHolder.java rename to common/src/main/java/com/yunbao/common/views/SidebarLiveItemViewHolder.java index 64af88fe8..6b6e80657 100644 --- a/live/src/main/java/com/yunbao/live/views/SidebarLiveItemViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SidebarLiveItemViewHolder.java @@ -1,4 +1,4 @@ -package com.yunbao.live.views; +package com.yunbao.common.views; import android.content.Context; import android.view.View; @@ -8,14 +8,11 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import com.bumptech.glide.Glide; -import com.bumptech.glide.load.resource.bitmap.CircleCrop; -import com.bumptech.glide.request.RequestOptions; import com.jakewharton.rxbinding3.view.RxView; import com.squareup.picasso.Picasso; +import com.yunbao.common.R; import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.glide.ImgLoader; -import com.yunbao.live.R; import java.util.concurrent.TimeUnit; @@ -58,7 +55,7 @@ public class SidebarLiveItemViewHolder extends RecyclerView.ViewHolder { .load(bean.getContentPicSizeThree()) .into(liveType); } - ImgLoader.display(itemView.getContext(),bean.getThumb(),mCover); + ImgLoader.display(itemView.getContext(), bean.getThumb(), mCover); mName.setText(bean.getUserNicename()); diff --git a/common/src/main/res/layout/item_sidebar_lives_new.xml b/common/src/main/res/layout/item_sidebar_lives_new.xml new file mode 100644 index 000000000..b9a0e1eaa --- /dev/null +++ b/common/src/main/res/layout/item_sidebar_lives_new.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_recommend.xml b/common/src/main/res/layout/view_recommend.xml index 77d9ef65f..499d3207e 100644 --- a/common/src/main/res/layout/view_recommend.xml +++ b/common/src/main/res/layout/view_recommend.xml @@ -1,6 +1,49 @@ - + android:layout_height="wrap_content" + android:layout_marginStart="10dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="10dp" + android:background="@drawable/bg_drawer_popup" + android:orientation="vertical"> - \ No newline at end of file + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/icon_change.png b/common/src/main/res/mipmap-xxhdpi/icon_change.png new file mode 100644 index 0000000000000000000000000000000000000000..78d447821dbf42bc54672a4b51cccb8c883dbe5b GIT binary patch literal 2018 zcmV<82Oao{P)Px+oJmAMR9HvtS8Z&RSrtC#-21-m%(R6mEg;?Qx*wD63mfEXfexk67CJNU z%zN)W<}`)CLd%r($C`M5wVC_g``mM%^E}T*_=pYsh~a_%T|miXQY~G&G%{nxj9FUi zClGN306Yl*4+4NUUTMS37nu1CL_9=9uMZ6k^;cI{=ToVaE$24Ms!&%~mlusjABjXF zpJC=Flu`*qdcnL_}a_=;-M15{X28p-_NGBr=*zCa(!! z?nTb=-*NBWz16<&Kd!a@3L-v_h!xCyl$n2i{`~phwYRt5M)W%X36bZ`n>VviD1?Z3 zedETBL7AIRIBoy_{dHRF1zPLxj9*_a48uRDaAGDUp%D81qU#pMQD7 zh7HoSV*`b_H8nM&8_xhh3lS}0=BV(5ncrpRLjdrz+S=O7%a$!O_fx4%CgWFCRaFiT z4@W%DYt~wCP)f}$l}e&bU-y0gw5&TcG-UAL!GnuD&s$4Gs}OOnb52M%MruSXI_EB0 zYrm(I>Rr2b?b)dU%49OiIX9n(o{~-#WhbJil~T`$k{e^b&CGcsVr%V1?CI(G1`$0A z0FPU1qtb?msF+!*A>Cw|xtE!D6^q5gt*x!ns%4MP&d!>KhK7{@@HO!~=iCq?ij*vH z&Rs&p*NCVR0A$ZBc6WEbsFZpN02+)DZ)7>mGypgS00l&B6i@*0lVY*>>*nU>i)Et$ zfL*(GRmbD;uL8hUBAV}<8BC99^BzARm z>H7M50kTmkwT6fuu-1+^=Y9nM-RI7o`{$M|TY}q^`oMt$jlS=1@jS1^7~`z9QlX!& zS+gcP1-qCKpR~VpoacEflu}EKF>e`Tep4tEPTz2Z+W_s`w=b@>Ug3G(cMel1P34$PKibkV9Qc6i68?@FQ z4uasv@p$|~If<`~>zj1S2h9~bJ3FiA%$c)QYn=puk6UZcJLkSxEEfAto;-PRsyvbw z@95|dL8Np#EnJ*5Dcs@q;yJCYtq+G`_#zRdh^WRGa{>VN8e?7^7#KLadGqE{8JxmQ zCL`g0wp_nbDrSt4C_9o$rAiZ(>8^RGx3{J=iI-IF@G|~914Qq zSgBOX_4oJNZQHhqvX8Alo}c6&322p~#zeFN5uemrt1t{-R!aSS_3G8{PYIAr7KN>@ zu3m(QtF+dwh$zY`+4#)(Gv_Vm+)_MjaKFG|U zVCIL3NWAa@0K6j_M?`P0TD5BMz5od!w{PF>&z?PdzSjC_W?n`_38mC@X0CM3iCIdn z7EZ~Zl_Zv~l##r{%u*Gp;!yzji)8X-GAaHwA+gJTC{|TfRe7E_SB#j5zQD|nF|#~* zVp@v}00=e-c8ECOoI6cKM~yLmGsYYr92~sf-rg=`o?4epCK6(lu~@94p`jr{MD list = new ArrayList<>(); private void getDrawer() { - LiveNetManager.get(mContext) - .getCustomSidebarInfo(new com.yunbao.common.http.base.HttpCallback>() { - @Override - public void onSuccess(List data) { + //推荐位 + MainNetManager.get(mContext) + .anchorRecommend("12", new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(AnchorRecommendModel anchorRecommendModel) { + list.clear(); + slideInfoModels.clear(); + List models = anchorRecommendModel.getList(); + + models.add(0, new AnchorRecommendItemModel()); + list.addAll(models); + slideInfoModels = anchorRecommendModel.getSlide(); } @Override public void onError(String error) { - } }); -// //推荐位 -// MainNetManager.get(mContext) -// .anchorRecommend("12", new com.yunbao.common.http.base.HttpCallback() { -// @Override -// public void onSuccess(AnchorRecommendModel anchorRecommendModel) { -// list.clear(); -// slideInfoModels.clear(); -// List models = anchorRecommendModel.getList(); -// -// models.add(0, new AnchorRecommendItemModel()); -// list.addAll(models); -// slideInfoModels = anchorRecommendModel.getSlide(); -// } -// -// @Override -// public void onError(String error) { -// } -// }); } public void onFollowEvent(FollowEvent e) { diff --git a/live/src/main/java/com/yunbao/live/adapter/SidebarAdapter.java b/live/src/main/java/com/yunbao/live/adapter/SidebarAdapter.java index a0839a9cb..8cd6617c4 100644 --- a/live/src/main/java/com/yunbao/live/adapter/SidebarAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/SidebarAdapter.java @@ -10,7 +10,7 @@ import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.SlideInfoModel; import com.yunbao.live.R; -import com.yunbao.live.views.SidebarLiveItemViewHolder; +import com.yunbao.common.views.SidebarLiveItemViewHolder; import com.yunbao.live.views.SidebarViewHoler; import java.util.ArrayList; diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java index 29f1b6d39..6d3dca23f 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java @@ -456,77 +456,53 @@ public class LiveTextRender { private void renderTMP(Context context, final TextView textView, final LiveChatBean bean) { - final LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); - if (levelBean == null) { - if (textView != null) { - SpannableStringBuilder builder = createPrefix(null, bean); - int color = 0xffffdd00; - switch (bean.getType()) { - case LiveChatBean.GIFT: - builder = renderGift(color, builder, bean); - break; - default: - builder = renderChat(color, builder, bean); - break; + if (textView != null) { + getLevelImage(context, bean.getLevel(), new ImgLoader.DrawableCallback() { + @Override + public void onLoadSuccess(Drawable drawable) { + SpannableStringBuilder builder = createPrefix(drawable, bean); + int color = Color.parseColor("#68F1F4"); + if (bean.isAnchor()) { + color = 0xffffdd00; + } else { + color = Color.parseColor("#68F1F4"); + } + switch (bean.getType()) { + case LiveChatBean.GIFT: + builder = renderGift(color, builder, bean); + break; + default: + builder = renderChat(color, builder, bean); + break; + } + textView.setText(builder); } - textView.setText(builder); - } - } else { - if (textView != null) { - getLevelImage(context, bean.getLevel(), new ImgLoader.DrawableCallback() { - @Override - public void onLoadSuccess(Drawable drawable) { - SpannableStringBuilder builder = createPrefix(drawable, bean); - int color = 0; - if (bean.isAnchor()) { - color = 0xffffdd00; - } else { - try { - color = Color.parseColor(levelBean.getColor()); - } catch (Exception e) { - color = Color.parseColor("#ffffff"); - } - } - switch (bean.getType()) { - case LiveChatBean.GIFT: - builder = renderGift(color, builder, bean); - break; - default: - builder = renderChat(color, builder, bean); - break; - } - textView.setText(builder); - } - @Override - public void onLoadFailed() { - SpannableStringBuilder builder = createPrefix(null, bean); - int color = 0; - if (bean.isAnchor()) { - color = 0xffffdd00; - } else { - try { - color = Color.parseColor(levelBean.getColor()); - } catch (Exception e) { - color = Color.parseColor("#ffffff"); - } - } - switch (bean.getType()) { - case LiveChatBean.GIFT: - builder = renderGift(color, builder, bean); - break; - default: - builder = renderChat(color, builder, bean); - break; - } - textView.setText(builder); + @Override + public void onLoadFailed() { + SpannableStringBuilder builder = createPrefix(null, bean); + int color = 0; + if (bean.isAnchor()) { + color = 0xffffdd00; + } else { + color = Color.parseColor("#68F1F4"); } - }); + switch (bean.getType()) { + case LiveChatBean.GIFT: + builder = renderGift(color, builder, bean); + break; + default: + builder = renderChat(color, builder, bean); + break; + } + textView.setText(builder); + } + }); - } } + } /**