Merge remote-tracking branch 'origin/master' into dev_live_new_user_icon

This commit is contained in:
zlzw 2022-08-23 11:31:08 +08:00
commit 6d9fd4e0a8
20 changed files with 596 additions and 238 deletions

View File

@ -32,7 +32,10 @@ import static com.yunbao.common.CommonAppContext.isReady;
*/
public class RongcloudIMManager {
//融云开发者平台注册app唯一识别符
public static final String RONG_IM_KEY = "uwd1c0sxu1p71";
// public static final String RONG_IM_KEY = "uwd1c0sxu1p71";
//测试环境
public static final String RONG_IM_KEY = "pvxdm17jpd3hr";
private static final String CLASSNAME = "RongcloudIMManager";
/**

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
>
<translate
android:duration="200"
android:fromXDelta="100%p"
android:toXDelta="0"
/>
</set>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="200"
android:fromXDelta="0"
android:toXDelta="100%p"
/>
</set>

View File

@ -66,7 +66,10 @@
<item name="android:windowEnterAnimation">@anim/left_anim_enter</item>
<item name="android:windowExitAnimation">@anim/left_anim_exit</item>
</style>
<style name="RightLeftToAnim" parent="android:Animation">
<item name="android:windowEnterAnimation">@anim/right_anim_enter</item>
<item name="android:windowExitAnimation">@anim/right_anim_exit</item>
</style>
<style name="groupLast" parent="AppTheme">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>

View File

@ -29,8 +29,7 @@ import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.EffectsSettingsDialog;
import com.yunbao.common.dialog.LiveChargeDialogFragment;
import com.yunbao.common.dialog.LiveTotalDialog;
import com.yunbao.common.event.LiveAudienceEvent;
import com.yunbao.live.dialog.LiveTotalDialog;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
@ -54,7 +53,9 @@ import com.yunbao.live.dialog.LiveGuardDialogFragment;
import com.yunbao.live.dialog.LiveHDDialogFragment;
import com.yunbao.live.dialog.LiveMicUserDialogFragment;
import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience;
import com.yunbao.live.dialog.SidebarLiveAudience;
import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.event.LiveRoomChangeEvent;
import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil;
@ -688,7 +689,12 @@ public class LiveAudienceActivity extends LiveActivity {
switch (event.getType()) {
case SIDEBAR:
//从右边打开侧边栏
manager.openDrawer();
SidebarLiveAudience sidebarLiveAudience = new SidebarLiveAudience();
bundle.putString("Avatar", mLiveBean.getAvatar());
sidebarLiveAudience.setArguments(bundle);
sidebarLiveAudience.show(getSupportFragmentManager(), "SidebarLiveAudience");
// manager.openDrawer();
break;
case BOTTOM_COLLECTION:
LiveTotalDialog liveTotalDialog = new LiveTotalDialog();
@ -788,6 +794,22 @@ public class LiveAudienceActivity extends LiveActivity {
fragment4Audience.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveWishListDialogFragmentAudience");
}
break;
case OPEN_PARAMETERS:
mDanmuPrice = TextUtils.equals(event.getParametersModel().getmDanmuPrice(), mDanmuPrice) ?
mDanmuPrice : event.getParametersModel().getmDanmuPrice();
mSocketUserType = TextUtils.equals(String.valueOf(mSocketUserType), String.valueOf(event.getParametersModel().getmSocketUserType())) ?
mSocketUserType : event.getParametersModel().getmSocketUserType();
mChatLevel = TextUtils.equals(String.valueOf(mChatLevel), String.valueOf(event.getParametersModel().getmChatLevel())) ?
mChatLevel : event.getParametersModel().getmChatLevel();
mDanMuLevel = TextUtils.equals(String.valueOf(mDanMuLevel), String.valueOf(event.getParametersModel().getmDanMuLevel())) ?
mDanMuLevel : event.getParametersModel().getmDanMuLevel();
mLiveType = TextUtils.equals(String.valueOf(mLiveType), String.valueOf(event.getParametersModel().getmLiveType())) ?
mLiveType : event.getParametersModel().getmLiveType();
mLiveTypeVal = TextUtils.equals(String.valueOf(mLiveTypeVal), String.valueOf(event.getParametersModel().getmLiveTypeVal())) ?
mLiveTypeVal : event.getParametersModel().getmLiveTypeVal();
mLiveGuardInfo = event.getParametersModel().getmLiveGuardInfo() == null ?
mLiveGuardInfo : event.getParametersModel().getmLiveGuardInfo();
break;
}

View File

@ -1,4 +1,4 @@
package com.yunbao.common.adapter;
package com.yunbao.live.adapter;
import android.view.LayoutInflater;
import android.view.View;
@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.views.FunGamesViewHolder;
import com.yunbao.live.views.FunGamesViewHolder;
import java.util.ArrayList;
import java.util.List;

View File

@ -8,8 +8,10 @@ import androidx.recyclerview.widget.RecyclerView;
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.live.views.SidebarViewHoler;
import java.util.ArrayList;
import java.util.List;
@ -21,6 +23,9 @@ public class SidebarAdapter extends RefreshAdapter<AnchorRecommendItemModel> {
private int mHeight;
private Context mContext;
private List<AnchorRecommendItemModel> itemModelList = new ArrayList<>();
private List<SlideInfoModel> data = new ArrayList<>();
private static final int HEAD = 1;
private static final int NORMAL = 0;
public SidebarAdapter(Context context, int height) {
super(context);
@ -31,24 +36,40 @@ public class SidebarAdapter extends RefreshAdapter<AnchorRecommendItemModel> {
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == HEAD) {
return new SidebarViewHoler(mInflater.inflate(R.layout.view_sidebar_live_audience_top, parent, false));
} else {
return new SidebarLiveItemViewHolder(mInflater.inflate(R.layout.item_sidebar_lives, parent, false));
}
return new SidebarLiveItemViewHolder(mInflater.inflate(R.layout.item_sidebar_lives, parent, false));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof SidebarLiveItemViewHolder) {
((SidebarLiveItemViewHolder) holder).loadViewDate(mList.get(position ), position , mHeight, new SidebarLiveItemViewHolder.OnItemClickListener() {
((SidebarLiveItemViewHolder) holder).loadViewDate(mList.get(position), position, mHeight, new SidebarLiveItemViewHolder.OnItemClickListener() {
@Override
public void onItemClick(AnchorRecommendItemModel bean, int position) {
if (mOnItemClickListener!=null){
mOnItemClickListener.onItemClick(bean,position);
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(bean, position);
}
}
});
} else if (holder instanceof SidebarViewHoler) {
SidebarViewHoler sidebarViewHoler = (SidebarViewHoler) holder;
sidebarViewHoler.onBanner(data);
}
}
@Override
public int getItemViewType(int position) {
if (position == 0) {
return HEAD;
}
return NORMAL;
}
/**
* 添加数据
*
@ -57,4 +78,10 @@ public class SidebarAdapter extends RefreshAdapter<AnchorRecommendItemModel> {
public void addData(List<AnchorRecommendItemModel> list) {
refreshData(list);
}
public SidebarAdapter setData(List<SlideInfoModel> data) {
this.data = data;
notifyDataSetChanged();
return this;
}
}

View File

@ -0,0 +1,81 @@
package com.yunbao.live.bean;
import com.yunbao.common.bean.BaseModel;
/**
* 直播间基类的参数回传
*/
public class OpenParametersModel extends BaseModel {
private String mDanmuPrice;//弹幕价格
private int mSocketUserType;//socket用户类型 30 普通用户 40 管理员 50 主播 60超管
private int mChatLevel;//发言等级限制
private int mDanMuLevel;//弹幕等级限制
//直播间的类型 普通 密码 门票 计时等
private int mLiveType = 0;
//收费价格,计时收费每次扣费的值
private int mLiveTypeVal = 0;
private LiveGuardInfo mLiveGuardInfo = null;
public int getmLiveType() {
return mLiveType;
}
public OpenParametersModel setmLiveType(int mLiveType) {
this.mLiveType = mLiveType;
return this;
}
public int getmLiveTypeVal() {
return mLiveTypeVal;
}
public OpenParametersModel setmLiveTypeVal(int mLiveTypeVal) {
this.mLiveTypeVal = mLiveTypeVal;
return this;
}
public LiveGuardInfo getmLiveGuardInfo() {
return mLiveGuardInfo;
}
public OpenParametersModel setmLiveGuardInfo(LiveGuardInfo mLiveGuardInfo) {
this.mLiveGuardInfo = mLiveGuardInfo;
return this;
}
public String getmDanmuPrice() {
return mDanmuPrice;
}
public OpenParametersModel setmDanmuPrice(String mDanmuPrice) {
this.mDanmuPrice = mDanmuPrice;
return this;
}
public int getmSocketUserType() {
return mSocketUserType;
}
public OpenParametersModel setmSocketUserType(int mSocketUserType) {
this.mSocketUserType = mSocketUserType;
return this;
}
public int getmChatLevel() {
return mChatLevel;
}
public OpenParametersModel setmChatLevel(int mChatLevel) {
this.mChatLevel = mChatLevel;
return this;
}
public int getmDanMuLevel() {
return mDanMuLevel;
}
public OpenParametersModel setmDanMuLevel(int mDanMuLevel) {
this.mDanMuLevel = mDanMuLevel;
return this;
}
}

View File

@ -1,4 +1,4 @@
package com.yunbao.common.dialog;
package com.yunbao.live.dialog;
import android.os.Bundle;
import android.view.Gravity;
@ -9,14 +9,15 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
import com.yunbao.common.adapter.FunGamesAdapter;
import com.yunbao.live.adapter.FunGamesAdapter;
import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.event.LiveAudienceEvent;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.event.LiveAudienceEvent;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

View File

@ -0,0 +1,171 @@
package com.yunbao.live.dialog;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import androidx.recyclerview.widget.GridLayoutManager;
import com.alibaba.fastjson.JSON;
import com.yunbao.common.bean.AnchorRecommendItemModel;
import com.yunbao.common.bean.AnchorRecommendModel;
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.DeviceUtils;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.adapter.SidebarAdapter;
import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
import java.util.List;
/**
* 直播间侧边栏
*/
public class SidebarLiveAudience extends AbsDialogFragment {
//侧边栏背景
private ImageView sidebarBack;
//侧边栏刷新列表
public CommonRefreshView sidebarList;
//侧边栏适配器
private SidebarAdapter sidebarAdapter;
@Override
protected int getLayoutId() {
return R.layout.view_sidebar_live_audience;
}
@Override
protected int getDialogStyle() {
return com.yunbao.common.R.style.dialog2;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Bundle bundle = getArguments();
sidebarBack = (ImageView) findViewById(R.id.sidebar_back);
if (bundle != null) {
String avatar = bundle.getString("Avatar");
//侧边栏背景
ImgLoader.displayBlurLive(mContext, avatar, sidebarBack);
}
sidebarList = (CommonRefreshView) findViewById(R.id.sidebarList);
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);
sidebarList.setDataHelperNew(new CommonRefreshView.DataHelperNew() {
@Override
public void loadData(int p) {
}
@Override
public void refresh() {
//推荐位
MainNetManager.get(getActivity())
.anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
@Override
public void onSuccess(AnchorRecommendModel anchorRecommendModel) {
if (getActivity().isFinishing()) return;
//侧边栏
MainNetManager.get(getActivity())
.getHot(1, new com.yunbao.common.http.base.HttpCallback<List<SlideInfoModel>>() {
@Override
public void onSuccess(List<SlideInfoModel> data) {
List<AnchorRecommendItemModel> list = anchorRecommendModel.getList();
list.add(0, new AnchorRecommendItemModel());
sidebarAdapter.addData(list);
sidebarList.onFinish();
sidebarAdapter.setData(data);
}
@Override
public void onError(String error) {
}
});
}
@Override
public void onError(String error) {
}
});
}
});
sidebarList.initData();
sidebarAdapter.setOnItemClickListener((bean, position) -> gotoLive(bean.getUid()));
}
@Override
protected boolean canCancel() {
return true;
}
@Override
protected void setWindowAttributes(Window window) {
window.setWindowAnimations(com.yunbao.common.R.style.RightLeftToAnim);
WindowManager.LayoutParams params = window.getAttributes();
params.width = DeviceUtils.getScreenWidth(getActivity()) / 3 * 2;
params.height = WindowManager.LayoutParams.MATCH_PARENT;
params.gravity = Gravity.RIGHT;
window.setAttributes(params);
}
/**
* 前往直播间
*/
private void gotoLive(final String liveId) {
LiveHttpUtil.getLiveInfo(liveId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(getActivity(), (liveBean1, liveType, liveTypeVal, liveSdk) -> {
if (liveBean1 == null) {
return;
}
LiveAudienceActivity.forward(getActivity(), liveBean1, liveType, liveTypeVal, "", 0, liveSdk);
(getActivity()).finish();
});
mCheckLivePresenter.checkLive(liveBean);
} else {
RouteUtil.forwardUserHome(getActivity(), liveId, 0);
getActivity().finish();
}
}
});
}
}

View File

@ -1,11 +1,32 @@
package com.yunbao.common.event;
package com.yunbao.live.event;
import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.live.bean.OpenParametersModel;
public class LiveAudienceEvent extends BaseModel {
private LiveAudienceType type;
private ActiveModel model = new ActiveModel();
private String avatar = "";
private OpenParametersModel parametersModel = new OpenParametersModel();
public OpenParametersModel getParametersModel() {
return parametersModel;
}
public LiveAudienceEvent setParametersModel(OpenParametersModel parametersModel) {
this.parametersModel = parametersModel;
return this;
}
public String getAvatar() {
return avatar;
}
public LiveAudienceEvent setAvatar(String avatar) {
this.avatar = avatar;
return this;
}
public ActiveModel getModel() {
return model;
@ -36,7 +57,8 @@ public class LiveAudienceEvent extends BaseModel {
NOBLE(8, "贵族"),
LIAN_MAI(9, "连麦"),
EFFECTS_SETTINGS(10, "特效設置"),
WISH_LIST(11,"心愿单");
WISH_LIST(11, "心愿单"),
OPEN_PARAMETERS(12, "开放参数");
private int type;

View File

@ -1,4 +1,4 @@
package com.yunbao.common.views;
package com.yunbao.live.views;
import android.view.View;
import android.widget.ImageView;
@ -9,10 +9,10 @@ import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.event.LiveAudienceEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.event.LiveAudienceEvent;
public class FunGamesViewHolder extends RecyclerView.ViewHolder {
private ImageView funGamePic;

View File

@ -33,7 +33,7 @@ import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.event.LiveAudienceEvent;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.common.event.MessageIMEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;

View File

@ -45,7 +45,7 @@ import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.LiveAudienceEvent;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;

View File

@ -4,22 +4,17 @@ import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Outline;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.viewpager.widget.PagerAdapter;
import com.adjust.sdk.Adjust;
@ -27,26 +22,19 @@ import com.adjust.sdk.AdjustEvent;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.ms.banner.Banner;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.SlideInfoModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.custom.ItemDecoration;
import com.yunbao.common.custom.MyViewPager;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.main.MainNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.RandomUtil;
@ -54,11 +42,9 @@ import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.utils.formatBigNum;
import com.yunbao.common.views.SlideInBannerViewHolder;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.adapter.SidebarAdapter;
import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.bean.LiveBuyGuardMsgBean;
import com.yunbao.live.bean.LiveChatBean;
@ -70,16 +56,17 @@ import com.yunbao.live.bean.LiveLuckGiftWinBean;
import com.yunbao.live.bean.LivePKUserListBean;
import com.yunbao.live.bean.LiveReceiveGiftBean;
import com.yunbao.live.bean.LiveUserGiftBean;
import com.yunbao.live.bean.OpenParametersModel;
import com.yunbao.live.bean.WishlistModel;
import com.yunbao.live.dialog.BlowkissDialog;
import com.yunbao.live.dialog.NewUserDialog;
import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPkPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.socket.SocketChatUtil;
import com.yunbao.live.socket.SocketClient;
@ -120,16 +107,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
private Intent mIntent;
//直播间背景
private ImageView liveBack;
//侧边栏轮播
private Banner mBanner;
//侧边栏刷新列表
public CommonRefreshView sidebarList;
//侧边栏适配器
private SidebarAdapter sidebarAdapter;
//侧边栏背景
private ImageView sidebarBack;
//侧滑布局
private DrawerLayout drawerLayout;
// private DrawerLayout drawerLayout;
//直播间拆分布局
private LiveRoomPlayViewHolder mLivePlayViewHolder;
//头部布局
@ -205,31 +186,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//直播页面背景
liveBack = mRootContainer.findViewById(R.id.live_back);
//侧边栏
drawerLayout = mRootContainer.findViewById(R.id.drawer_layout);
FrameLayout leftDrawer = mRootContainer.findViewById(R.id.left_drawer);
DrawerLayout.LayoutParams layoutParams = (DrawerLayout.LayoutParams) leftDrawer.getLayoutParams();
layoutParams.width = DeviceUtils.getScreenWidth(mContext) / 3 * 2;
leftDrawer.setLayoutParams(layoutParams);
sidebarList = mRootContainer.findViewById(R.id.sidebarList);
sidebarBack = mRootContainer.findViewById(R.id.sidebar_back);
//禁止滑动打开侧边栏
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
sidebarList.setEmptyLayoutId(R.layout.view_no_data_live);
GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false);
sidebarList.setLayoutManager(gridLayoutManager);
sidebarList.setLoadMoreEnable(false);
ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 6, 0);
decoration.setOnlySetItemOffsetsButNoDraw(true);
sidebarList.setItemDecoration(decoration);
Display mDisplay = mContext.getWindowManager().getDefaultDisplay();
sidebarAdapter = new SidebarAdapter(mContext, mDisplay.getHeight());
//侧边栏轮播
mBanner = mRootContainer.findViewById(R.id.banner);
sidebarAdapter.setOnItemClickListener((bean, position) -> gotoLive(bean.getUid()));
sidebarAdapter.setHasStableIds(true);
sidebarList.setRecyclerViewAdapter(sidebarAdapter);
}
@ -240,6 +197,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveType = liveType;
mLiveTypeVal = liveTypeVal;
liveID = data.getUid();
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS)
.setParametersModel(new OpenParametersModel()
.setmLiveType(mLiveType)
.setmLiveTypeVal(mLiveTypeVal)));
if (mIntent.getIntExtra("isry", 0) == 1) {
mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0));
} else {
@ -264,57 +226,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//直播间背景
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack);
//侧边栏背景
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), sidebarBack);
sidebarList.setDataHelperNew(new CommonRefreshView.DataHelperNew() {
@Override
public void loadData(int p) {
}
@Override
public void refresh() {
//推荐位
MainNetManager.get(mContext)
.anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
@Override
public void onSuccess(AnchorRecommendModel data) {
if (mContext.isFinishing()) return;
sidebarAdapter.addData(data.getList());
sidebarList.onFinish();
}
@Override
public void onError(String error) {
}
});
}
});
sidebarList.initData();
mBanner.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
}
});
mBanner.setClipToOutline(true);
//侧边栏
MainNetManager.get(mContext)
.getHot(1, new com.yunbao.common.http.base.HttpCallback<List<SlideInfoModel>>() {
@Override
public void onSuccess(List<SlideInfoModel> data) {
mContext.runOnUiThread(() -> onBanner(data));
}
@Override
public void onError(String error) {
}
});
mLivePlayViewHolder.setCover(data.getThumb());
mLivePlayViewHolder.play(data.getPull());
mLiveRoomViewHolder.setAvatar(data.getAvatar());
@ -922,7 +834,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mSocketUserType = obj.getIntValue("usertype");
mChatLevel = obj.getIntValue("speak_limit");
mDanMuLevel = obj.getIntValue("barrage_limit");
//回传参数
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS)
.setParametersModel(new OpenParametersModel().setmDanmuPrice(mDanmuPrice)
.setmSocketUserType(mSocketUserType)
.setmChatLevel(mChatLevel)
.setmDanMuLevel(mDanMuLevel)));
EventBus.getDefault().post("close_login");
EventBus.getDefault().post("oneUesrOver");
@ -1110,6 +1028,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveGuardInfo.setMyGuardType(guardObj.getIntValue("type"));
mLiveGuardInfo.setMyGuardEndTime(guardObj.getString("endtime"));
}
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS)
.setParametersModel(new OpenParametersModel().setmLiveGuardInfo(mLiveGuardInfo)));
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.setGuardNum(guardNum);
mLiveRoomViewHolder.setFansNum(fansNum);
@ -1179,62 +1100,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
countDownTimer.start();
}
/**
* 侧滑轮播
*/
public void onBanner(List<SlideInfoModel> data) {
if (data == null || data.size() == 0 || mBanner == null) {
return;
}
if (mBanner.isStart()) {
mBanner.update(data);
} else {
mBanner.setAutoPlay(true)
.setPages(data, new SlideInBannerViewHolder())
.setDelayTime(3000)
.setOnBannerClickListener((datas, p) -> {
if (p >= 0 && p < data.size()) {
SlideInfoModel bean = data.get(p);
if (bean != null) {
String link = bean.getSlideUrl();
if (link.contains("http")) {
WebViewActivity.forward(mContext, link, true);
} else {
gotoLive(link);
}
}
}
}).start();
}
}
/**
* 前往直播间
*/
private void gotoLive(final String liveId) {
LiveHttpUtil.getLiveInfo(liveId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean1, liveType, liveTypeVal, liveSdk) -> {
if (liveBean1 == null) {
return;
}
LiveAudienceActivity.forward(mContext, liveBean1, liveType, liveTypeVal, "", 0, liveSdk);
mContext.finish();
});
mCheckLivePresenter.checkLive(liveBean);
} else {
RouteUtil.forwardUserHome(mContext, liveId, 0);
mContext.finish();
}
}
});
}
/**
* 暂停播放
@ -1372,9 +1237,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
public void openDrawer() {
drawerLayout.openDrawer(GravityCompat.END);
}
// public void openDrawer() {
// drawerLayout.openDrawer(GravityCompat.END);
// }
public void onLinkMicTxAccEvent(LinkMicTxAccEvent e) {
if (mLivePlayViewHolder != null && mLivePlayViewHolder instanceof LivePlayTxViewHolder) {

View File

@ -0,0 +1,91 @@
package com.yunbao.live.views;
import android.app.Activity;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.ms.banner.Banner;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.SlideInfoModel;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.views.SlideInBannerViewHolder;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
import java.util.List;
public class SidebarViewHoler extends RecyclerView.ViewHolder {
//侧边栏轮播
private Banner mBanner;
public SidebarViewHoler(@NonNull View itemView) {
super(itemView);
//侧边栏轮播
mBanner = itemView.findViewById(R.id.banner);
}
/**
* 侧滑轮播
*/
public void onBanner(List<SlideInfoModel> data) {
if (data == null || data.size() == 0 || mBanner == null) {
return;
}
if (mBanner.isStart()) {
mBanner.update(data);
} else {
mBanner.setAutoPlay(true)
.setPages(data, new SlideInBannerViewHolder())
.setDelayTime(3000)
.setOnBannerClickListener((datas, p) -> {
if (p >= 0 && p < data.size()) {
SlideInfoModel bean = data.get(p);
if (bean != null) {
String link = bean.getSlideUrl();
if (link.contains("http")) {
WebViewActivity.forward(itemView.getContext(), link, true);
} else {
gotoLive(link);
}
}
}
}).start();
}
}
/**
* 前往直播间
*/
private void gotoLive(final String liveId) {
LiveHttpUtil.getLiveInfo(liveId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(itemView.getContext(), (liveBean1, liveType, liveTypeVal, liveSdk) -> {
if (liveBean1 == null) {
return;
}
LiveAudienceActivity.forward(itemView.getContext(), liveBean1, liveType, liveTypeVal, "", 0, liveSdk);
((Activity) itemView.getContext()).finish();
});
mCheckLivePresenter.checkLive(liveBean);
} else {
RouteUtil.forwardUserHome(itemView.getContext(), liveId, 0);
((Activity) itemView.getContext()).finish();
}
}
});
}
}

View File

@ -52,65 +52,6 @@
android:visibility="gone" />
</FrameLayout>
<FrameLayout
android:id="@+id/left_drawer"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@mipmap/live_bg"
android:choiceMode="singleChoice"
android:dividerHeight="0dp"
android:orientation="vertical"
android:scrollbars="none">
<ImageView
android:id="@+id/sidebar_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#90000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingTop="56dp"
android:paddingEnd="8dp">
<com.ms.banner.Banner
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="77dp"
android:layout_marginBottom="5dp"
app:delay_time="3000"
app:indicator_drawable_selected="@drawable/bg_home_indicator_selected"
app:indicator_drawable_unselected="@drawable/bg_home_indicator_unselected"
app:indicator_height="8dp"
app:indicator_margin="6dp"
app:indicator_width="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/recommended_for_you"
android:textColor="#FFF6F7FB"
android:textSize="14sp" />
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/sidebarList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp" />
</LinearLayout>
</FrameLayout>
</com.yunbao.common.views.weight.MyDrawerLayout>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/sidebar_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#90000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingEnd="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingTop="56dp"
android:paddingEnd="8dp">
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/sidebarList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp">
</com.yunbao.common.custom.CommonRefreshView>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.ms.banner.Banner
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="77dp"
android:layout_marginBottom="5dp"
app:delay_time="3000"
app:indicator_drawable_selected="@drawable/bg_home_indicator_selected"
app:indicator_drawable_unselected="@drawable/bg_home_indicator_unselected"
app:indicator_height="8dp"
app:indicator_margin="6dp"
app:indicator_width="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/recommended_for_you"
android:textColor="#FFF6F7FB"
android:textSize="14sp" />
</LinearLayout>
</FrameLayout>

View File

@ -6,6 +6,8 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.app.NotificationChannel;
import android.app.PendingIntent;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
@ -125,11 +127,18 @@ import cn.rongcloud.rtc.api.RCRTCConfig;
import cn.rongcloud.rtc.api.RCRTCEngine;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.rong.imkit.config.RongConfigCenter;
import io.rong.imkit.notification.NotificationConfig;
import io.rong.imlib.RongIMClient;
import kotlin.Unit;
import static com.yunbao.common.CommonAppContext.isReady;
import io.rong.imlib.model.Message;
import io.rong.push.PushManager;
import io.rong.push.PushType;
import kotlin.*;
@Route(path = RouteUtil.PATH_MAIN)
public class MainActivity extends AbsActivity implements MainAppBarLayoutListener {
@ -292,6 +301,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
// Log and toast
Log.d(TAG, token);
PushManager.getInstance()
.onReceiveToken(MainActivity.this, PushType.GOOGLE_FCM, token);
Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show();
}
});
@ -392,6 +403,28 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
mViewPager.setCurrentItem(0);
mTabButtonGroup.setCurPosition(0);
isInstructor();
RongConfigCenter.notificationConfig().setInterceptor(new NotificationConfig.Interceptor() {
@Override
public boolean isNotificationIntercepted(Message message) {
return true;
}
@Override
public PendingIntent onPendingIntent(PendingIntent pendingIntent, Intent intent) {
return null;
}
@Override
public boolean isHighPriorityMessage(Message message) {
return false;
}
@Override
public NotificationChannel onRegisterChannel(NotificationChannel notificationChannel) {
return null;
}
});
RxView.clicks(findViewById(R.id.banner_click))
.throttleFirst(2, TimeUnit.SECONDS)
.subscribe(new Observer<Unit>() {