diff --git a/common/build.gradle b/common/build.gradle index 88851178a..a0649a127 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -188,4 +188,6 @@ dependencies { api 'com.github.princekin-f:EasyFloat:2.0.4' api files('libs/Msc.jar') + api 'com.github.li-xiaojun:XPopup:2.9.1' + } diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java index 07f931213..6625e23cc 100644 --- a/common/src/main/java/com/yunbao/common/Constants.java +++ b/common/src/main/java/com/yunbao/common/Constants.java @@ -168,6 +168,7 @@ public class Constants { public static final String STAR_CHALLENGE_UPDATE = "starChallengeUpdate";//星级助力 public static final String AI_AUTOMATIC_SPEECH = "aiAutomaticSpeech";//机器人助手 public static final String STAR_CHALLENGE_UPGRADE_NOTIFY = "starChallengeUpgradeNotify";//星级挑战成功 + public static final String SUPER_VISION = "supervision";//超级发言警告 //游戏socket public static final String SOCKET_GAME_ZJH = "startGame";//炸金花 diff --git a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java new file mode 100644 index 000000000..32fe68918 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java @@ -0,0 +1,29 @@ +package com.yunbao.common.adapter; + +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +/** + * 新侧边栏适配器 + */ +public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { + + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return null; + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + + } + + @Override + public int getItemCount() { + return 0; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java b/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java new file mode 100644 index 000000000..41156f452 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java @@ -0,0 +1,94 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class CustomSidebarChildModel extends BaseModel { + @SerializedName("id") + private String id; + @SerializedName("parent_id") + private String parentId; + @SerializedName("title") + private String title; + @SerializedName("subtitle") + private String subtitle; + @SerializedName("icon") + private String icon; + @SerializedName("src") + private String src; + @SerializedName("show_type") + private String showType; + @SerializedName("sort") + private String sort; + + public String getId() { + return id; + } + + public CustomSidebarChildModel setId(String id) { + this.id = id; + return this; + } + + public String getParentId() { + return parentId; + } + + public CustomSidebarChildModel setParentId(String parentId) { + this.parentId = parentId; + return this; + } + + public String getTitle() { + return title; + } + + public CustomSidebarChildModel setTitle(String title) { + this.title = title; + return this; + } + + public String getSubtitle() { + return subtitle; + } + + public CustomSidebarChildModel setSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + public String getIcon() { + return icon; + } + + public CustomSidebarChildModel setIcon(String icon) { + this.icon = icon; + return this; + } + + public String getSrc() { + return src; + } + + public CustomSidebarChildModel setSrc(String src) { + this.src = src; + return this; + } + + public String getShowType() { + return showType; + } + + public CustomSidebarChildModel setShowType(String showType) { + this.showType = showType; + return this; + } + + public String getSort() { + return sort; + } + + public CustomSidebarChildModel setSort(String sort) { + this.sort = sort; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/CustomSidebarInfoModel.java b/common/src/main/java/com/yunbao/common/bean/CustomSidebarInfoModel.java new file mode 100644 index 000000000..9d3c85547 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/CustomSidebarInfoModel.java @@ -0,0 +1,99 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * 新版自定义侧边栏 + */ +public class CustomSidebarInfoModel extends BaseModel { + @SerializedName("id") + private String id; + @SerializedName("title") + private String title; + @SerializedName("subtitle") + private String subtitle; + @SerializedName("sort") + private String sort; + @SerializedName("show_type") + private String showType; + @SerializedName("src") + private String src; + @SerializedName("type") + private String type; + @SerializedName("child") + private List child; + + public String getId() { + return id; + } + + public CustomSidebarInfoModel setId(String id) { + this.id = id; + return this; + } + + public String getTitle() { + return title; + } + + public CustomSidebarInfoModel setTitle(String title) { + this.title = title; + return this; + } + + public String getSubtitle() { + return subtitle; + } + + public CustomSidebarInfoModel setSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + public String getSort() { + return sort; + } + + public CustomSidebarInfoModel setSort(String sort) { + this.sort = sort; + return this; + } + + public String getShowType() { + return showType; + } + + public CustomSidebarInfoModel setShowType(String showType) { + this.showType = showType; + return this; + } + + public String getSrc() { + return src; + } + + public CustomSidebarInfoModel setSrc(String src) { + this.src = src; + return this; + } + + public String getType() { + return type; + } + + public CustomSidebarInfoModel setType(String type) { + this.type = type; + return this; + } + + public List getChild() { + return child; + } + + public CustomSidebarInfoModel setChild(List child) { + this.child = child; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index c3bddf6e6..5e71880e0 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -4,6 +4,7 @@ import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.ContributeModel; +import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.HourRank; import com.yunbao.common.bean.IMLoginModel; @@ -236,7 +237,8 @@ public interface PDLiveApi { Observable> getNobleRankHideUserList(); /** - *获取当前星级 + * 获取当前星级 + * * @param liveUid * @return */ @@ -248,4 +250,10 @@ public interface PDLiveApi { */ @GET("/api/public/?service=Live.getLiveRoomActivtyBanner") Observable>> getLiveRoomActivityBanner(); + + /** + * 新侧边栏请求 + */ + @GET("/api/public/?service=Live.getCustomSidebarInfo") + Observable>> getCustomSidebarInfo(); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index a84922559..bc4913516 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -6,6 +6,7 @@ import android.text.TextUtils; import com.yunbao.common.R; import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveRoomActivityBanner; import com.yunbao.common.bean.NobleRankHideUserListModel; @@ -14,7 +15,6 @@ import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.VipModel; import com.yunbao.common.http.API; -import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.base.HttpCallback; import java.util.List; @@ -63,6 +63,7 @@ public class LiveNetManager { if (callback != null) callback.onError(throwable.getMessage()); }).isDisposed(); + } /** @@ -237,7 +238,6 @@ public class LiveNetManager { /** * 获取 【新人特惠】【趣味游戏】【幸运天使】 - * */ public void getLiveRoomActivityBanner(HttpCallback> callback) { API.get().pdLiveApi(mContext) @@ -253,4 +253,22 @@ public class LiveNetManager { throwable.printStackTrace(); }).isDisposed(); } + + /** + * 获取新侧边数据 + * + * @param callback + */ + public void getCustomSidebarInfo(HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getCustomSidebarInfo() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(listResponseModel -> callback.onSuccess(listResponseModel.getData().getInfo()), throwable -> { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + throwable.printStackTrace(); + }).isDisposed(); + } } diff --git a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java new file mode 100644 index 000000000..1ddfedce5 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java @@ -0,0 +1,57 @@ +package com.yunbao.common.views; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.lxj.xpopup.core.DrawerPopupView; +import com.yunbao.common.R; +import com.yunbao.common.bean.CustomSidebarInfoModel; +import com.yunbao.common.http.live.LiveNetManager; + +import java.util.List; + +public class CustomDrawerPopupView extends DrawerPopupView { + private Context mContext; + + private RecyclerView drawerList; + + public CustomDrawerPopupView(@NonNull Context context) { + super(context); + mContext = context; + } + + @Override + protected int getImplLayoutId() { + return R.layout.custom_drawer_popup; + } + + @Override + protected void onCreate() { + super.onCreate(); + + initView(); + initData(); + + } + + private void initView() { + drawerList = findViewById(R.id.drawerList); + } + + private void initData() { + LiveNetManager.get(mContext) + .getCustomSidebarInfo(new com.yunbao.common.http.base.HttpCallback>() { + @Override + public void onSuccess(List data) { + + } + + @Override + public void onError(String error) { + + } + }); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/yunbao/common/views/DrawerRecommendViewHolder.java b/common/src/main/java/com/yunbao/common/views/DrawerRecommendViewHolder.java new file mode 100644 index 000000000..876bac123 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/DrawerRecommendViewHolder.java @@ -0,0 +1,15 @@ +package com.yunbao.common.views; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +/** + * 侧边栏推荐布局 任务 + */ +public class DrawerRecommendViewHolder extends RecyclerView.ViewHolder { + public DrawerRecommendViewHolder(@NonNull View itemView) { + super(itemView); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/DrawerTaskViewHolder.java b/common/src/main/java/com/yunbao/common/views/DrawerTaskViewHolder.java new file mode 100644 index 000000000..0ac077cdb --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/DrawerTaskViewHolder.java @@ -0,0 +1,15 @@ +package com.yunbao.common.views; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +/** + * 侧边栏任务布局 + */ +public class DrawerTaskViewHolder extends RecyclerView.ViewHolder { + public DrawerTaskViewHolder(@NonNull View itemView) { + super(itemView); + } +} diff --git a/common/src/main/res/drawable/backgroud_custom_drawer_popup.xml b/common/src/main/res/drawable/backgroud_custom_drawer_popup.xml new file mode 100644 index 000000000..18e7accd9 --- /dev/null +++ b/common/src/main/res/drawable/backgroud_custom_drawer_popup.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/custom_drawer_popup.xml b/common/src/main/res/layout/custom_drawer_popup.xml new file mode 100644 index 000000000..aec92c644 --- /dev/null +++ b/common/src/main/res/layout/custom_drawer_popup.xml @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/live_more_icon_connect_new.png b/common/src/main/res/mipmap-xxhdpi/live_more_icon_connect_new.png new file mode 100644 index 000000000..779b2dc96 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/live_more_icon_connect_new.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/live_more_icon_fenestrule_new.png b/common/src/main/res/mipmap-xxhdpi/live_more_icon_fenestrule_new.png new file mode 100644 index 000000000..1c277bbeb Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/live_more_icon_fenestrule_new.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/live_more_icon_hd.png b/common/src/main/res/mipmap-xxhdpi/live_more_icon_hd.png new file mode 100644 index 000000000..8de7b9706 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/live_more_icon_hd.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/live_more_icon_more.png b/common/src/main/res/mipmap-xxhdpi/live_more_icon_more.png new file mode 100644 index 000000000..2b0398a85 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/live_more_icon_more.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/live_more_icon_sliding_new.png b/common/src/main/res/mipmap-xxhdpi/live_more_icon_sliding_new.png new file mode 100644 index 000000000..f2abfe924 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/live_more_icon_sliding_new.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/live_more_icon_special_new.png b/common/src/main/res/mipmap-xxhdpi/live_more_icon_special_new.png new file mode 100644 index 000000000..57d08e40e Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/live_more_icon_special_new.png differ diff --git a/config.gradle b/config.gradle index c7985d37c..70ee56319 100644 --- a/config.gradle +++ b/config.gradle @@ -10,9 +10,9 @@ ext { manifestPlaceholders = [ //正式 - serverHost : "https://napi.yaoulive.com", +// serverHost : "https://napi.yaoulive.com", //測試 -// serverHost : "https://ceshi.yaoulive.com", + serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", 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 1420ef4c8..c88180c31 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -33,6 +33,8 @@ import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; import com.facebook.appevents.AppEventsLogger; import com.google.firebase.analytics.FirebaseAnalytics; +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.enums.PopupPosition; import com.lzf.easyfloat.EasyFloat; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; @@ -41,6 +43,7 @@ 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; @@ -56,6 +59,7 @@ 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; @@ -68,6 +72,7 @@ import com.yunbao.common.utils.L; import com.yunbao.common.utils.ProcessResultUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.CustomDrawerPopupView; import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.common.views.weight.VerticalViewPager; import com.yunbao.live.R; @@ -81,7 +86,6 @@ 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.SidebarLiveAudience; import com.yunbao.live.dialog.SignDialogFragment; import com.yunbao.live.event.LinkMicTxAccEvent; import com.yunbao.live.event.LiveAudienceEvent; @@ -142,6 +146,7 @@ public class LiveAudienceActivity extends LiveActivity { //直播间进入房间队列 private Handler liveHandler = new Handler(); private ImageView voicePress; + private View titleLine; @Override public T findViewById(@IdRes int id) { @@ -181,6 +186,7 @@ public class LiveAudienceActivity extends LiveActivity { private void initView() { // 竖直滑动 ViewPager verticalViewPager = findViewById(R.id.view_pager); + titleLine = findViewById(R.id.title_line); voicePress = findViewById(R.id.voice_press); verticalViewPager.setEnableScroll(IMLoginManager.get(mContext).isSlide()); //判断是否有直播悬浮窗,有直接关闭 @@ -688,23 +694,51 @@ public class LiveAudienceActivity extends LiveActivity { IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); switch (event.getType()) { case SIDEBAR: - int userIndex = -1; - for (int i = 0; i < list.size(); i++) { - if (TextUtils.equals(list.get(i).getUid(), PortraitLiveManager.liveID)) { - userIndex = i; - } - } - if (userIndex != -1) { - list.remove(userIndex); - } - //从右边打开侧边栏 - SidebarLiveAudience sidebarLiveAudience = new SidebarLiveAudience(); - bundle.putString("Avatar", mLiveBean.getAvatar()); - bundle.putString("banner", GsonUtils.toJson(slideInfoModels)); - bundle.putString("list", GsonUtils.toJson(list)); - bundle.putInt("LiveBg", liveBg); - sidebarLiveAudience.setArguments(bundle); - sidebarLiveAudience.show(getSupportFragmentManager(), "SidebarLiveAudience"); +// int userIndex = -1; +// for (int i = 0; i < list.size(); i++) { +// if (TextUtils.equals(list.get(i).getUid(), PortraitLiveManager.liveID)) { +// userIndex = i; +// } +// } +// if (userIndex != -1) { +// list.remove(userIndex); +// } +// //从右边打开侧边栏 +// SidebarLiveAudience sidebarLiveAudience = new SidebarLiveAudience(); +// bundle.putString("Avatar", mLiveBean.getAvatar()); +// bundle.putString("banner", GsonUtils.toJson(slideInfoModels)); +// bundle.putString("list", GsonUtils.toJson(list)); +// bundle.putInt("LiveBg", liveBg); +// sidebarLiveAudience.setArguments(bundle); +// sidebarLiveAudience.show(getSupportFragmentManager(), "SidebarLiveAudience"); +// MPopupWindow.create(mContext) +// .setLayoutId(R.layout.view_sidebar_live_audience) +// .setBackgroundDrawable(new ColorDrawable(Color.GREEN)) +// .setOnDismissListener(new MPopupWindow.MPopupListener() { +// @Override +// public void invoke(View contentView) { +// +// } +// +// @Override +// public void onDismiss() { +// +// } +// }).setGravity(TypeGravity.BOTTOM_RIGHT) +// .setTarget(titleLine) +// .setHeight(DeviceUtils.getScreenHeight(mContext)*2) +// .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) + .show(); break; case BOTTOM_COLLECTION: LiveTotalDialog liveTotalDialog = new LiveTotalDialog(); @@ -1030,25 +1064,36 @@ public class LiveAudienceActivity extends LiveActivity { private List list = new ArrayList<>(); private void getDrawer() { - - //推荐位 - MainNetManager.get(mContext) - .anchorRecommend("12", new com.yunbao.common.http.base.HttpCallback() { + LiveNetManager.get(mContext) + .getCustomSidebarInfo(new com.yunbao.common.http.base.HttpCallback>() { @Override - public void onSuccess(AnchorRecommendModel anchorRecommendModel) { - list.clear(); - slideInfoModels.clear(); - List models = anchorRecommendModel.getList(); + public void onSuccess(List data) { - 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/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java index a2ad2f0c1..9096d03e8 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -299,6 +299,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter { mBg.setBackground(null); mTextView.setText(bean.getContent()); } + } else if (bean.getType() == LiveChatBean.SYSTEM2) { + mTextView.setTextColor(0xffffffff); + mBg.setBackground(null); + mTextView.setText(bean.getContent()); } else if (bean.getType() == -1) {//自动消息,关注 boolean isContains = false; for (LiveChatBean model : mList) { diff --git a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java index 6165349f5..5a492399f 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java @@ -11,8 +11,9 @@ import com.yunbao.common.bean.MsgModel; public class LiveChatBean { - public static final int NORMAL = 0; + public final int NORMAL = 0; public static final int SYSTEM = 1; + public static final int SYSTEM2 = 111; public static final int GIFT = 2; public static final int ENTER_ROOM = 3; public static final int LIGHT = 4; @@ -22,6 +23,8 @@ public class LiveChatBean { public static final int STAR_CHALLENGE_UPGRADE_NOTIFY = 105; public static final int LUCKY_ANGEL = 106;//幸运天使 + + private String id; private String userNiceName; private int level; diff --git a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java index 03f0c2f49..89e28ad83 100644 --- a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java +++ b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java @@ -1,40 +1,19 @@ package com.yunbao.live.dialog; import android.content.DialogInterface; -import android.graphics.Color; import android.os.Bundle; -import android.text.TextUtils; -import android.view.Display; import android.view.Gravity; import android.view.View; import android.view.Window; import android.view.WindowManager; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.recyclerview.widget.GridLayoutManager; import com.alibaba.fastjson.JSON; -import com.blankj.utilcode.util.GsonUtils; -import com.google.gson.reflect.TypeToken; -import com.ms.banner.Banner; -import com.yunbao.common.activity.WebViewActivity; -import com.yunbao.common.bean.AnchorRecommendItemModel; -import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.LiveBean; -import com.yunbao.common.bean.SlideInfoModel; -import com.yunbao.common.custom.CommonRefreshView; -import com.yunbao.common.custom.ItemDecoration; import com.yunbao.common.dialog.AbsDialogFragment; -import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; -import com.yunbao.common.http.main.MainNetManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.RouteUtil; -import com.yunbao.common.views.SlideInBannerViewHolder; -import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; import com.yunbao.live.adapter.SidebarAdapter; import com.yunbao.live.event.LiveAudienceEvent; @@ -42,32 +21,18 @@ import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.views.LivePlayRyViewHolder; -import com.yunbao.live.views.PortraitLiveManager; import org.greenrobot.eventbus.EventBus; -import java.util.ArrayList; -import java.util.List; - /** * 直播间侧边栏 */ public class SidebarLiveAudience extends AbsDialogFragment { - //侧边栏背景 - private ImageView sidebarBack; - private View mask; - //侧边栏刷新列表 - public CommonRefreshView sidebarList; + //侧边栏适配器 private SidebarAdapter sidebarAdapter; - private List slideInfoModels = new ArrayList<>(); - private List list = new ArrayList<>(); - private int index = 0; - private LinearLayout haveData, noDataLive; - private Banner mBanner; - private TextView inBatch; @Override protected int getLayoutId() { @@ -84,176 +49,7 @@ public class SidebarLiveAudience extends AbsDialogFragment { super.onActivityCreated(savedInstanceState); Bundle bundle = getArguments(); - sidebarBack = (ImageView) findViewById(R.id.sidebar_back); - haveData = (LinearLayout) findViewById(R.id.have_data); - noDataLive = (LinearLayout) findViewById(R.id.view_no_data_live); - //侧边栏轮播 - mBanner = (Banner) findViewById(R.id.banner); - inBatch = (TextView) findViewById(R.id.in_batch); - mask = findViewById(R.id.mask); - if (bundle != null) { - String avatar = bundle.getString("Avatar"); - int liveBg = bundle.getInt("LiveBg"); - slideInfoModels = GsonUtils.fromJson(bundle.getString("banner"), new TypeToken>() { - }.getType()); - list = GsonUtils.fromJson(bundle.getString("list"), new TypeToken>() { - }.getType()); - //侧边栏背景 - if (liveBg == 1) { - ImgLoader.displayBlurLive(mContext, avatar, sidebarBack); - mask.setVisibility(View.VISIBLE); - } else { - ImgLoader.display(mContext, R.mipmap.live_bg, sidebarBack); - mask.setVisibility(View.GONE); - } - - } - sidebarList = (CommonRefreshView) findViewById(R.id.sidebarList); - sidebarList.setHeaderTextColor(Color.parseColor("#ffffff")); - GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false); - gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { - @Override - public int getSpanSize(int position) { - if (position == 0) { - return 2; - } - return 1; - } - }); - sidebarList.setLayoutManager(gridLayoutManager); - sidebarList.setEmptyLayoutId(R.layout.view_no_data_live); - sidebarList.setLoadMoreEnable(false); - ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 6, 0); - decoration.setOnlySetItemOffsetsButNoDraw(true); - sidebarList.setItemDecoration(decoration); - Display mDisplay = getActivity().getWindowManager().getDefaultDisplay(); - sidebarAdapter = new SidebarAdapter(mContext, mDisplay.getHeight()); - sidebarAdapter.setHasStableIds(true); - sidebarList.setRecyclerViewAdapter(sidebarAdapter); - ViewClicksAntiShake.clicksAntiShake(inBatch, new ViewClicksAntiShake.ViewClicksCallBack() { - @Override - public void onViewClicks() { - sidebarList.initData(); - } - }); - if (sidebarAdapter != null) { - if (list.size() == 1) { - haveData.setVisibility(View.GONE); - noDataLive.setVisibility(View.VISIBLE); - - if (mBanner.isStart()) { - mBanner.update(slideInfoModels); - } else { - mBanner.setAutoPlay(true) - .setPages(slideInfoModels, new SlideInBannerViewHolder()) - .setDelayTime(3000) - .setOnBannerClickListener((datas, p) -> { - if (p >= 0 && p < slideInfoModels.size()) { - SlideInfoModel bean = slideInfoModels.get(p); - if (bean != null) { - - String link = bean.getSlideUrl(); - if (link.contains("http")) { - WebViewActivity.forward(getContext(), link, true); - } else { - gotoLive(link); - } - } - } - }).start(); - } - } else { - haveData.setVisibility(View.VISIBLE); - noDataLive.setVisibility(View.GONE); - sidebarAdapter.addData(list); - sidebarAdapter.setData(slideInfoModels); - } - - } - sidebarList.setDataHelperNew(new CommonRefreshView.DataHelperNew() { - @Override - public void loadData(int p) { - - } - - @Override - public void refresh() { - if (index > 0) { - //推荐位 - MainNetManager.get(getActivity()) - .anchorRecommend("12", new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(AnchorRecommendModel anchorRecommendModel) { - List list = anchorRecommendModel.getList(); - int userIndex = -1; - for (int i = 0; i < list.size(); i++) { - if (TextUtils.equals(list.get(i).getUid(), PortraitLiveManager.liveID)) { - userIndex = i; - } - } - if (userIndex != -1) { - list.remove(userIndex); - } - - list.add(0, new AnchorRecommendItemModel()); - if (list.size() == 1) { - haveData.setVisibility(View.GONE); - noDataLive.setVisibility(View.VISIBLE); - - if (mBanner.isStart()) { - mBanner.update(slideInfoModels); - } else { - mBanner.setAutoPlay(true) - .setPages(slideInfoModels, new SlideInBannerViewHolder()) - .setDelayTime(3000) - .setOnBannerClickListener((datas, p) -> { - if (p >= 0 && p < slideInfoModels.size()) { - SlideInfoModel bean = slideInfoModels.get(p); - if (bean != null) { - - String link = bean.getSlideUrl(); - if (link.contains("http")) { - WebViewActivity.forward(getContext(), link, true); - } else { - gotoLive(link); - } - } - } - }).start(); - } - } else { - haveData.setVisibility(View.VISIBLE); - noDataLive.setVisibility(View.GONE); - sidebarAdapter.addData(list); - sidebarAdapter.setData(anchorRecommendModel.getSlide()); - } - - sidebarList.onFinish(); - } - - @Override - public void onError(String error) { - } - }); - } else { - index = index + 1; - } - - } - }); - sidebarList.initData(); - sidebarAdapter.setOnItemClickListener((bean, position) -> { - - gotoLive(bean.getUid()); - dismiss(); - }); - sidebarAdapter.setListener(new SidebarAdapter.SidebarListener() { - @Override - public void refresh() { - sidebarList.initData(); - } - }); } @Override diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 0818c9784..a058d2023 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -204,12 +204,12 @@ public class SocketRyClient { } break; case Constants.SOCKET_KICK://踢人 - systemChatMessage(map.getString("ct")); + systemChatMessage2(map.getString("ct")); mListener.onKick(map.getString("touid")); break; case Constants.SOCKET_SHUT_UP://禁言 String ct = map.getString("ct"); - systemChatMessage(ct); + systemChatMessage2(ct); mListener.onShutUp(map.getString("touid"), ct); break; case Constants.SOCKET_SEND_MSG://文字消息,点亮,用户进房间,这种混乱的设计是因为服务器端逻辑就是这样设计的,客户端无法自行修改 @@ -333,9 +333,12 @@ public class SocketRyClient { mListener.addFakeFans(list); break; case Constants.SOCKET_SET_ADMIN://设置或取消管理员 - systemChatMessage(map.getString("ct")); + systemChatMessage2(map.getString("ct")); mListener.onSetAdmin(map.getString("touid"), map.getIntValue("action")); break; + case Constants.SUPER_VISION://设置或取消管理员 + systemChatMessage2(map.getString("ct")); + break; case Constants.SOCKET_BUY_GUARD://购买守护 buyGuardInSameRoom(map); break; @@ -858,6 +861,16 @@ public class SocketRyClient { mListener.onChat(bean, 1); } + /** + * 接收到系统消息,显示在聊天栏中 + */ + private static void systemChatMessage2(String content) { + LiveChatBean bean = new LiveChatBean(); + bean.setContent(content); + bean.setType(LiveChatBean.SYSTEM2); + mListener.onChat(bean, 1); + } + /** * 处理观众与主播连麦逻辑 */ diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 0a055d8ff..17535b20e 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -183,6 +183,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //标记是调用正常退出还是手动切后台 private boolean isQuitF = false; + //是否成功调用进入房间接口 + private boolean isEnterRoom = false; + public PortraitLiveManager setQuitF(boolean quitF) { isQuitF = quitF; return this; @@ -224,6 +227,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) { + isEnterRoom = false; openParametersModel = new OpenParametersModel(); mContext.runOnUiThread(new Runnable() { @Override @@ -1062,7 +1066,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe LiveHttpUtil.enterRoom(mLiveBean.getUid(), mLiveBean.getStream(), new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { - + isEnterRoom = true; if (code == 0 && info.length > 0) { JSONObject obj = JSON.parseObject(info[0]); mDanmuPrice = obj.getString("barrage_fee"); @@ -1418,7 +1422,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe * 退出直播间 */ public void exitLiveRoom() { - if (mLiveBean == null) { + if (mLiveBean == null && !isEnterRoom) { return; } RongChatRoomClient.getInstance().quitChatRoom("g" + mLiveBean.getUid(), new IRongCoreCallback.OperationCallback() { diff --git a/live/src/main/res/layout/activity_live_detail.xml b/live/src/main/res/layout/activity_live_detail.xml index 997e1794d..e69a2c00a 100644 --- a/live/src/main/res/layout/activity_live_detail.xml +++ b/live/src/main/res/layout/activity_live_detail.xml @@ -3,6 +3,11 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + android:layout_marginStart="54dp" + android:src="@mipmap/icon_voice_press" + android:visibility="gone" /> \ No newline at end of file diff --git a/live/src/main/res/layout/view_sidebar_live_audience.xml b/live/src/main/res/layout/view_sidebar_live_audience.xml index a5638be36..3dfd27392 100644 --- a/live/src/main/res/layout/view_sidebar_live_audience.xml +++ b/live/src/main/res/layout/view_sidebar_live_audience.xml @@ -1,110 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file