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 000000000..78d447821 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_change.png differ diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index c88180c31..4fb0b435a 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -43,7 +43,6 @@ import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.CrashSaveBean; -import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveGiftBean; @@ -59,7 +58,6 @@ import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; -import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.main.MainNetManager; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; @@ -84,7 +82,6 @@ import com.yunbao.live.dialog.LiveGameDialogFragment; import com.yunbao.live.dialog.LiveGiftDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveMicUserDialogFragment; -import com.yunbao.live.dialog.LiveTotalDialog; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; import com.yunbao.live.dialog.SignDialogFragment; import com.yunbao.live.event.LinkMicTxAccEvent; @@ -694,6 +691,7 @@ public class LiveAudienceActivity extends LiveActivity { IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); switch (event.getType()) { case SIDEBAR: + case BOTTOM_COLLECTION: // int userIndex = -1; // for (int i = 0; i < list.size(); i++) { // if (TextUtils.equals(list.get(i).getUid(), PortraitLiveManager.liveID)) { @@ -730,24 +728,16 @@ public class LiveAudienceActivity extends LiveActivity { // .setWidth(DeviceUtils.getScreenWidth(mContext)/6*5) // .build() // .show(); - CustomDrawerPopupView drawerPopupView = new CustomDrawerPopupView(mContext); + new XPopup.Builder(mContext) .hasShadowBg(false) .isDestroyOnDismiss(true) .isLightStatusBar(false) .popupPosition(PopupPosition.Right)//右边 .hasStatusBarShadow(true) //启用状态栏阴影 - .asCustom(drawerPopupView) + .asCustom(new CustomDrawerPopupView(mContext).setList(list)) .show(); break; - case BOTTOM_COLLECTION: - LiveTotalDialog liveTotalDialog = new LiveTotalDialog(); - liveTotalDialog.setAnchorBean(mLiveBean); - Bundle liveBundle = new Bundle(); - liveBundle.putBoolean("isActivity", event.isActivity()); - liveTotalDialog.setArguments(liveBundle); - liveTotalDialog.show(getSupportFragmentManager(), "LiveTotalDialog"); - break; case GIFT_POPUP: if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) { return; @@ -1064,36 +1054,25 @@ public class LiveAudienceActivity extends LiveActivity { private List 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); + } + }); - } } + } /**