diff --git a/common/src/main/java/com/yunbao/common/bean/UserBean.java b/common/src/main/java/com/yunbao/common/bean/UserBean.java index ca4c91489..aa44fc257 100644 --- a/common/src/main/java/com/yunbao/common/bean/UserBean.java +++ b/common/src/main/java/com/yunbao/common/bean/UserBean.java @@ -71,6 +71,38 @@ public class UserBean implements Parcelable { //粉丝团等级 private int fansLevel; //粉丝团进场皮肤 + protected int typeMic; + private boolean isMicList = false; + + private boolean isRequest = false; + + public boolean isRequest() { + return isRequest; + } + + public UserBean setRequest(boolean request) { + isRequest = request; + return this; + } + + public boolean isMicList() { + return isMicList; + } + + public UserBean setMicList(boolean micList) { + isMicList = micList; + return this; + } + + public int getTypeMic() { + return typeMic; + } + + public UserBean setTypeMic(int typeMic) { + this.typeMic = typeMic; + return this; + } + private String fansEnterRoomUrl; public int getUserInfoComplete() { diff --git a/common/src/main/java/com/yunbao/common/manager/MicUserManager.java b/common/src/main/java/com/yunbao/common/manager/MicUserManager.java new file mode 100644 index 000000000..1df287e32 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/manager/MicUserManager.java @@ -0,0 +1,89 @@ +package com.yunbao.common.manager; + +import android.content.Context; +import android.text.TextUtils; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.reflect.TypeToken; +import com.yunbao.common.CommonAppContext; +import com.yunbao.common.bean.UserBean; +import com.yunbao.common.manager.base.BaseCacheManager; + +import java.util.ArrayList; +import java.util.List; + +/** + * 连麦用户申请列表维护 + */ +public class MicUserManager extends BaseCacheManager { + private String micKey = "TYPE_MIC_REQUEST"; + private List micUsers = new ArrayList<>(); + private static MicUserManager manager; + + public MicUserManager(Context context) { + super(context); + } + + public static MicUserManager get() { + if (null == manager) { + manager = new MicUserManager(CommonAppContext.sInstance.getBaseContext()); + } + return manager; + } + + public void upDataMicUser(JSONObject map) { + UserBean userModel = new UserBean(); + + UserBean.DressBean dressAvatar = null; + if (!TextUtils.isEmpty(map.getString("dress_avatar"))) { + dressAvatar = new UserBean.DressBean(); + dressAvatar.setAvatar_frame(map.getString("dress_avatar")); + } + + userModel.setAvatar(map.getString("avatar")); + userModel.setId(map.getString("uid")); + userModel.setUserNiceName(map.getString("uname")); + userModel.setDress(dressAvatar); + userModel.setSex(map.getIntValue("sex")); + userModel.setLevel(map.getIntValue("level")); + userModel.setTypeMic(2); + micUsers.add(userModel); + put(micKey, micUsers); + } + + public List getMicUserList() { + if (micUsers.size() < 1) { + micUsers = getList(micKey, new TypeToken>() { + }.getType()); + } + + return micUsers; + } + + public void removeMiscUser(JSONObject map) { + micUsers = getMicUserList(); + if (micUsers == null) return; + for (int i = 0; i < micUsers.size(); i++) { + if (TextUtils.equals(micUsers.get(i).getId(), map.getString("uid"))) { + micUsers.remove(i); + } + } + put(micKey, micUsers); + } + + public void removeMiscUser(String uid) { + micUsers = getMicUserList(); + if (micUsers == null) return; + for (int i = 0; i < micUsers.size(); i++) { + if (TextUtils.equals(micUsers.get(i).getId(), uid)) { + micUsers.remove(i); + } + } + put(micKey, micUsers); + } + + public void removeAllMicUserList() { + deleteByKey(micKey); + micUsers.clear(); + } +} diff --git a/common/src/main/java/com/yunbao/common/manager/MicedUserManager.java b/common/src/main/java/com/yunbao/common/manager/MicedUserManager.java new file mode 100644 index 000000000..fa885e2da --- /dev/null +++ b/common/src/main/java/com/yunbao/common/manager/MicedUserManager.java @@ -0,0 +1,89 @@ +package com.yunbao.common.manager; + +import android.content.Context; +import android.text.TextUtils; + +import com.google.gson.reflect.TypeToken; +import com.yunbao.common.CommonAppContext; +import com.yunbao.common.bean.LinkMicUserBean; +import com.yunbao.common.bean.UserBean; +import com.yunbao.common.manager.base.BaseCacheManager; + +import java.util.ArrayList; +import java.util.List; + +/** + * 处于连麦中的人员维护列表 + */ +public class MicedUserManager extends BaseCacheManager { + private String micKey = "TYPE_MIC_LIST"; + private List micUsers = new ArrayList<>(); + + public MicedUserManager(Context context) { + super(context); + } + + private static MicedUserManager manager; + + + public static MicedUserManager get() { + if (null == manager) { + manager = new MicedUserManager(CommonAppContext.sInstance.getBaseContext()); + } + return manager; + } + + + public void upDataMicUserList(List list) { + if (list == null || list.size() < 1) return; + for (LinkMicUserBean linkMicUserBean : list) { + if (!TextUtils.equals(linkMicUserBean.getId(), + String.valueOf(IMLoginManager.get( + CommonAppContext.sInstance.getBaseContext()). + getUserInfo().getId()))) { + + UserBean userModel = new UserBean(); + UserBean.DressBean dressAvatar = null; + if (!TextUtils.isEmpty(linkMicUserBean.getDress_avatar())) { + dressAvatar = new UserBean.DressBean(); + dressAvatar.setAvatar_frame(linkMicUserBean.getDress_avatar()); + } + + userModel.setAvatar(linkMicUserBean.getAvatar()); + userModel.setId(linkMicUserBean.getId()); + userModel.setUserNiceName(linkMicUserBean.getUname()); + userModel.setSex(linkMicUserBean.getSex()); + userModel.setDress(dressAvatar); + userModel.setLevel(linkMicUserBean.getLevel()); + userModel.setTypeMic(1); + micUsers.add(userModel); + } + } + put(micKey, micUsers); + } + + public void removeMiscUser(String uid) { + micUsers = getMicUserList(); + if (micUsers == null) return; + for (int i = 0; i < micUsers.size(); i++) { + if (TextUtils.equals(micUsers.get(i).getId(), uid)) { + micUsers.remove(i); + } + } + put(micKey, micUsers); + } + + public List getMicUserList() { + if (micUsers.size() < 1) { + micUsers = getList(micKey, new TypeToken>() { + }.getType()); + } + + return micUsers; + } + + public void removeAllMicUserList() { + deleteByKey(micKey); + micUsers.clear(); + } +} diff --git a/common/src/main/res/drawable/bg_anchor_mic_info_btn_invite.xml b/common/src/main/res/drawable/bg_anchor_mic_info_btn_invite.xml index ee73ee2f4..f3698b385 100644 --- a/common/src/main/res/drawable/bg_anchor_mic_info_btn_invite.xml +++ b/common/src/main/res/drawable/bg_anchor_mic_info_btn_invite.xml @@ -1,9 +1,15 @@ - + - + + + + + + + \ No newline at end of file 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 5f95834a0..092d9c4e6 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1745,7 +1745,7 @@ public class LiveAudienceActivity extends LiveActivity { if (liveSudGamePopupXPopup != null) { liveSudGamePopupXPopup.BusGetOff(); liveSudGamePopupXPopup.dialog.dismiss(); - + verticalViewPager.setEnableScroll(true); liveSudGamePopupXPopup = null; } break; diff --git a/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java b/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java index 7202da106..8d0d5c0c7 100644 --- a/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java @@ -1,6 +1,7 @@ package com.yunbao.live.adapter; import android.content.Context; +import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -20,20 +21,20 @@ import com.yunbao.common.Constants; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.LevelBean; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.API; import com.yunbao.common.http.ResponseModel; +import com.yunbao.common.manager.MicUserManager; +import com.yunbao.common.manager.MicedUserManager; import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; -import com.yunbao.live.activity.LiveRyAnchorActivity; -import com.yunbao.common.bean.MicUserBean; -import com.yunbao.live.interfaces.LiveFunctionClickListener; import com.yunbao.live.socket.SocketSendBean; import java.net.MalformedURLException; @@ -49,7 +50,7 @@ import io.rong.imlib.model.Conversation; import io.rong.imlib.model.Message; import io.rong.message.TextMessage; -public class AnchorUserMicInfoAdapter extends RefreshAdapter { +public class AnchorUserMicInfoAdapter extends RefreshAdapter { public static final int TYPE_MIC_LIST = 1;//连麦列表 public static final int TYPE_MIC_REQUEST = 2;//请求连麦 public static final int TYPE_MIC_INVITE = 3;//邀请连麦 @@ -116,40 +117,42 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { mBtn = itemView.findViewById(R.id.mic_btn); mClose = itemView.findViewById(R.id.mic_exit); mBtn.setOnClickListener(v -> { - if (v.getTag() != null) { - MicUserBean tag = (MicUserBean) v.getTag(); - LiveRyAnchorActivity.checkMicUserLength(mLiveUid, new LiveFunctionClickListener() { - @Override - public void onClick(int length) { - //只允许最多3人连麦(加主播4人) - if (length <= 4) { - if (tag.getType() == TYPE_MIC_REQUEST) { - applyMic(tag, 4, createSocketSendBean()); - ToastUtil.show(mContext.getString(R.string.live_mic_request)); - } else if (tag.getType() == TYPE_MIC_INVITE) { - SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId()); - applyMic(tag, 1, bean); - ToastUtil.show(mContext.getString(R.string.live_mic_invite)); + if (MicedUserManager.get().getMicUserList().size() < 3) { + if (v.getTag() != null) { + UserBean tag = (UserBean) v.getTag(); + if (tag.getTypeMic() == TYPE_MIC_REQUEST) { + SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId()); + applyMic(tag, 1, bean); + ToastUtil.show(mContext.getString(R.string.live_mic_invite)); + } else if (tag.getTypeMic() == TYPE_MIC_INVITE) { + applyMic(tag, 4, createSocketSendBean()); + ToastUtil.show(mContext.getString(R.string.live_mic_request)); + for (int i = 0; i < mList.size(); i++) { + if (TextUtils.equals(mList.get(i).getId(), tag.getId())) { + mList.get(i).setRequest(true); + notifyItemChanged(i); } - } else { - ToastUtil.show(mContext.getString(R.string.live_mic_max)); } - } - }); + } + } + + }else { + ToastUtil.show(mContext.getString(R.string.live_mic_max)); } }); mClose.setOnClickListener(v -> { if (v.getTag() != null) { - API.get().createPDLiveApi(true) - .killDrLm(((MicUserBean) v.getTag()).getId(), mLiveUid) + API.get().createPDLiveApi(false) + .killDrLm(((UserBean) v.getTag()).getId(), mLiveUid) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Consumer>() { @Override public void accept(ResponseModel stringResponseModel) throws Exception { - applyMic((MicUserBean) v.getTag(), 8, createSocketSendBean()); + applyMic((UserBean) v.getTag(), 8, createSocketSendBean()); ToastUtil.show(mContext.getString(R.string.live_mic_user_down)); + refreshView.initData(); } }, Throwable::printStackTrace).isDisposed(); @@ -167,9 +170,10 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { /** * 发送IM消息 + * * @param action 4为同意请求,1为邀请,其余见 {@link com.yunbao.live.socket.SocketRyClient} Constants.LIAN_MAI解析 */ - void applyMic(MicUserBean bean, int action, SocketSendBean msg) { + void applyMic(UserBean bean, int action, SocketSendBean msg) { msg.param("action", action); msg.create(); Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; @@ -184,9 +188,17 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { @Override public void onSuccess(io.rong.imlib.model.Message message) { Log.e("ry", "发送成功"); - refreshView.initData(); + IMCenter.getInstance().deleteRemoteMessages(Conversation.ConversationType.PRIVATE, message.getTargetId(), new Message[]{message}, null); IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, message.getTargetId(), null); + if (bean.getTypeMic() == TYPE_MIC_REQUEST) { + MicUserManager.get().removeMiscUser(bean.getId()); + } + if (bean.getTypeMic() == TYPE_MIC_LIST && action == 8) { + MicedUserManager.get().removeMiscUser(bean.getId()); + } + + refreshView.initData(); } @Override @@ -197,9 +209,9 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { }); } - void setData(final MicUserBean bean, int position) { + void setData(final UserBean bean, int position) { - itemView.setOnClickListener(new View.OnClickListener() { + mAvatar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((LiveActivity) mContext).showUserDialog(bean.getId()); @@ -208,7 +220,7 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { }); mClose.setTag(bean); mBtn.setTag(bean); - switch (bean.getType()) { + switch (bean.getTypeMic()) { case TYPE_MIC_LIST: mClose.setVisibility(View.VISIBLE); mBtn.setVisibility(View.GONE); @@ -219,29 +231,46 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { mBtn.setVisibility(View.VISIBLE); break; } - if (bean.getType() == TYPE_MIC_REQUEST) { + if (bean.getTypeMic() == TYPE_MIC_REQUEST) { mBtn.setText("同意"); - if(!WordUtil.isNewZh()){ + if (!WordUtil.isNewZh()) { mBtn.setText("agree"); } mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_ok); - } else if (bean.getType() == TYPE_MIC_INVITE) { - mBtn.setText("邀请"); - if (!WordUtil.isNewZh()) { - mBtn.setText("invite"); - } + } else if (bean.getTypeMic() == TYPE_MIC_INVITE) { + + mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_invite); + if (bean.isMicList()) { + mBtn.setEnabled(false); + mBtn.setClickable(false); + mBtn.setSelected(false); + mBtn.setText(WordUtil.isNewZh() ? "連麥中" : "Trung"); + } else { + mBtn.setEnabled(true); + mBtn.setClickable(true); + mBtn.setSelected(true); +// if (bean.isRequest()){ +// mBtn.setText(WordUtil.isNewZh() ? "已邀请" : "Invited"); +// }else { + mBtn.setText(WordUtil.isNewZh() ? "邀请" : "invite"); +// } + + } + } ImgLoader.display(mContext, bean.getAvatar(), mAvatar); - if (bean.getDress_avatar() != null) { - if (bean.getDress_avatar().contains("svga")) { + gift_svga.setImageDrawable(null); + if (bean.getDress() != null) { + if (bean.getDress().getAvatar_frame().contains("svga")) { + try { - new SVGAParser(mContext).parse(new URL(bean.getDress_avatar()), new SVGAParser.ParseCompletion() { + new SVGAParser(mContext).parse(new URL(bean.getDress().getAvatar_frame()), new SVGAParser.ParseCompletion() { @Override public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); gift_svga.setImageDrawable(drawable); - SVGAViewUtils.playEndClear(gift_svga); + SVGAViewUtils.playEndClear(gift_svga, false); } @Override @@ -252,10 +281,9 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { e.printStackTrace(); } } else { - ImgLoader.display(mContext, bean.getDress_avatar(), gift_svga); + ImgLoader.display2(mContext, bean.getDress().getAvatar_frame(), gift_svga); } } - mName.setText(bean.getUserNiceName()); mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); @@ -263,8 +291,7 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { if (levelBean != null) { ImgLoader.display(mContext, levelBean.getThumb(), mLevel); } + } } - - } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java index e4cf9f13f..a136fce20 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java @@ -4,6 +4,7 @@ import android.app.ActionBar; import android.app.Dialog; import android.graphics.Color; import android.os.Bundle; +import android.text.TextUtils; import android.util.Log; import android.view.Gravity; import android.view.View; @@ -20,23 +21,23 @@ import com.yunbao.common.Constants; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.LinkMicUserBean; +import com.yunbao.common.bean.LiveUserGiftBean; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.http.API; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.http.ResponseModel; +import com.yunbao.common.manager.MicUserManager; +import com.yunbao.common.manager.MicedUserManager; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.adapter.AnchorUserMicInfoAdapter; -import com.yunbao.live.bean.LiveGuardInfo; -import com.yunbao.common.bean.LiveUserGiftBean; -import com.yunbao.common.bean.MicUserBean; -import com.yunbao.common.http.LiveHttpUtil; -import com.yunbao.live.utils.LiveImDeletUtil; -import com.yunbao.common.utils.MicStatusManager; import java.util.ArrayList; import java.util.Arrays; @@ -58,19 +59,15 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi private AnchorUserMicInfoAdapter userMicInfoAdapter; private String mLiveUid; private String stream; - private LiveGuardInfo mLiveGuardInfo; public static LiveActivity activity = null; - public eightbitlab.com.blurview.BlurView blurView; public TextView listMicbtn, requestMicBtn, inviteMicBtn, mDisconnectMic; private TextView mNoMoreDesc; private String Tips = "1"; - private String type = "guanzhong"; View mOpenMicLayout, no_more; View mOpenMicBtn; private TreeMap mMicQueueList = new TreeMap<>(); private List mAudienceList = new ArrayList<>(); - private LiveImDeletUtil liveImDeletUtil; private OnMicListener micListener; @Override @@ -97,9 +94,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi window.setAttributes(params); } - public void setLiveGuardInfo(LiveGuardInfo info) { - mLiveGuardInfo = info; - } public void setMicQueueList(TreeMap mMicQueueList) { this.mMicQueueList = mMicQueueList; @@ -142,8 +136,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi if (bundle == null) { return; } - liveImDeletUtil = new LiveImDeletUtil(); - mLiveUid = bundle.getString(Constants.LIVE_UID); stream = bundle.getString(Constants.STREAM); listMicbtn = mRootView.findViewById(R.id.audience_btn); @@ -168,9 +160,11 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi return; } Tips = "1"; +// + userMicInfoAdapter.clearData(); Up(); - type = "guanzhong"; mRefreshView.initData(); + }); requestMicBtn.setOnClickListener(view -> { if (!MicStatusManager.getInstance().isAnchorOpenRoom()) { @@ -178,7 +172,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi } Tips = "2"; Up(); - type = "guard"; mRefreshView.initData(); }); @@ -188,9 +181,9 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi return; } Tips = "3"; - Up(); - type = "fans"; + mRefreshView.initData(); + Up(); }); mOpenMicBtn.setOnClickListener(v -> { API.get().pdLiveApi(mContext) @@ -204,7 +197,7 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi mRefreshView.setVisibility(View.VISIBLE); mDisconnectMic.setVisibility(View.VISIBLE); MicStatusManager.getInstance().setAnchorOpenRoom(true); - mRefreshView.initData(); +// mRefreshView.initData(); } }, Throwable::printStackTrace) .isDisposed(); @@ -218,11 +211,14 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi mDisconnectMic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh()?"是否確認關閉語音連麥":"Whether to disable the voice", new DialogUitl.SimpleCallback() { + DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh() ? "是否確認關閉語音連麥" : "Whether to disable the voice", new DialogUitl.SimpleCallback() { @Override public void onConfirmClick(Dialog dialog, String content) { MicStatusManager.getInstance().closeMic(mContext); + MicUserManager.get().removeAllMicUserList(); LiveMicAnchorDialogFragment.this.dismiss(); + MicedUserManager.get().removeAllMicUserList(); + MicUserManager.get().removeAllMicUserList(); } }); } @@ -231,10 +227,11 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi userMicInfoAdapter.setLiveUid(mLiveUid); userMicInfoAdapter.setRefreshView(mRefreshView); Up(); + mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); - mRefreshView.setDataHelper(new CommonRefreshView.DataHelper() { + mRefreshView.setDataHelper(new CommonRefreshView.DataHelper() { @Override - public RefreshAdapter getAdapter() { + public RefreshAdapter getAdapter() { userMicInfoAdapter.notifyDataSetChanged(); return userMicInfoAdapter; } @@ -242,70 +239,109 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi @Override public void loadData(int p, HttpCallback callback) { Log.e("tag111", p + "ssss"); - LiveHttpUtil.getMicList(mLiveUid, p, callback); + LiveHttpUtil.getUserList(mLiveUid, stream, "guanzhong", p, callback); pg = p; - if (p == 1) { - no_more.setVisibility(View.VISIBLE); - mRefreshView.setVisibility(View.GONE); - } + } @Override - public List processData(String[] info) { + public List processData(String[] info) { Log.e("tag222", Tips + "ssss" + MicStatusManager.getInstance().toString()); JSONObject obj = JSON.parseObject(info[0]); - List data = new ArrayList<>(); + List data = new ArrayList<>(); + if (TextUtils.equals(Tips, "2")) { - if (Tips.equals("2")) { - for (String uid : mMicQueueList.keySet()) { - LinkMicUserBean userBean = mMicQueueList.get(uid); - MicUserBean bean = new MicUserBean(); - bean.setAvatar(userBean.getAvatar()); - bean.setId(uid); - bean.setUserNiceName(userBean.getUname()); - bean.setSex(userBean.getSex()); - bean.setDress_avatar(userBean.getDress_avatar()); - bean.setLevel(userBean.getLevel()); - bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_REQUEST); - data.add(bean); - } - } else if ("3".equals(Tips)) { - for (LiveUserGiftBean userBean : mAudienceList) { - MicUserBean bean = new MicUserBean(); - bean.setAvatar(userBean.getAvatar()); - bean.setId(userBean.getId()); - bean.setUserNiceName(userBean.getUserNiceName()); - bean.setSex(userBean.getSex()); - bean.setDress_avatar(userBean.getDress().getAvatar_frame()); - bean.setLevel(userBean.getLevel()); - bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_INVITE); - data.add(bean); - } - mRefreshView.setNotLoadMore(); - } else { - data = JSON.parseArray(obj.getString("userlist"), MicUserBean.class); - for (MicUserBean bean : data) { - bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_LIST); - } - if (data.size() != 0) { - data.remove(0); - } - } - if (data.size() > 0 && pg == 1) { - nums = 0; - view_no.setVisibility(View.GONE); - if (nums == 0) { - view_no.setVisibility(View.VISIBLE); + userMicInfoAdapter.clearData(); + data = MicUserManager.get().getMicUserList(); + + if (data.size() == 0) { + no_more.setVisibility(View.VISIBLE); + mRefreshView.setVisibility(View.GONE); + + }else { + mRefreshView.setVisibility(View.VISIBLE); + no_more.setVisibility(View.GONE); + } + mRefreshView.mRecyclerView.getRecycledViewPool().setMaxRecycledViews(0, data.size()); + } else if (TextUtils.equals(Tips, "3")) { + data = JSON.parseArray(obj.getString("userlist"), UserBean.class); + for (UserBean bean : data) { + bean.setTypeMic(AnchorUserMicInfoAdapter.TYPE_MIC_INVITE); + for (UserBean model : MicedUserManager.get().getMicUserList()) { + if (!bean.isMicList() && TextUtils.equals(bean.getId(), model.getId())) { + bean.setMicList(true); + } + } + + } + if (pg == 1 && data.size() == 0) { + no_more.setVisibility(View.VISIBLE); + mRefreshView.setVisibility(View.GONE); + } + if (data.size() > 0 && pg == 1) { + nums = 0; + view_no.setVisibility(View.GONE); + if (nums == 0) { + view_no.setVisibility(View.VISIBLE); + } + mRefreshView.mRecyclerView.getRecycledViewPool().setMaxRecycledViews(0, data.size()); + mRefreshView.setVisibility(View.VISIBLE); + no_more.setVisibility(View.GONE); + } + } else if (TextUtils.equals(Tips, "1")) { + userMicInfoAdapter.clearData(); + data = MicedUserManager.get().getMicUserList(); + + if (data.size() == 0) { + no_more.setVisibility(View.VISIBLE); + mRefreshView.setVisibility(View.GONE); + + }else { + mRefreshView.setVisibility(View.VISIBLE); + no_more.setVisibility(View.GONE); } mRefreshView.mRecyclerView.getRecycledViewPool().setMaxRecycledViews(0, data.size()); - mRefreshView.setVisibility(View.VISIBLE); - no_more.setVisibility(View.GONE); } + + +// if (Tips.equals("2")) { +// for (String uid : mMicQueueList.keySet()) { +// LinkMicUserBean userBean = mMicQueueList.get(uid); +// MicUserBean bean = new MicUserBean(); +// bean.setAvatar(userBean.getAvatar()); +// bean.setId(uid); +// bean.setUserNiceName(userBean.getUname()); +// bean.setSex(userBean.getSex()); +// bean.setDress_avatar(userBean.getDress_avatar()); +// bean.setLevel(userBean.getLevel()); +// bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_REQUEST); +// data.add(bean); +// } +// } else if ("3".equals(Tips)) { +// for (LiveUserGiftBean userBean : mAudienceList) { +// MicUserBean bean = new MicUserBean(); +// bean.setAvatar(userBean.getAvatar()); +// bean.setId(userBean.getId()); +// bean.setUserNiceName(userBean.getUserNiceName()); +// bean.setSex(userBean.getSex()); +// bean.setDress_avatar(userBean.getDress().getAvatar_frame()); +// bean.setLevel(userBean.getLevel()); +// bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_INVITE); +// data.add(bean); +// } +// mRefreshView.setNotLoadMore(); +// } else { + +// if (data.size() != 0) { +// data.remove(0); +// } +// } + return data; } @Override - public void onRefreshSuccess(List list, int listCount) { + public void onRefreshSuccess(List list, int listCount) { } @@ -315,7 +351,7 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi } @Override - public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { Log.e("tag333", "是" + nums); } @@ -323,7 +359,9 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi public void onLoadMoreFailure() { } }); + initData(); + } @Override @@ -333,7 +371,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi @Override public void onDestroy() { - mLiveGuardInfo = null; LiveHttpUtil.cancel("getUserLists"); super.onDestroy(); } @@ -344,7 +381,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi requestMicBtn.setTextColor(Color.parseColor("#ff646464")); inviteMicBtn.setTextColor(Color.parseColor("#ff646464")); mNoMoreDesc.setText(R.string.no_more_mic); - type = "guanzhong"; } else if (Tips.equals("2")) { listMicbtn.setTextColor(Color.parseColor("#ff646464")); requestMicBtn.setTextColor(Color.parseColor("#fff6f7fb")); @@ -353,7 +389,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi if (!WordUtil.isNewZh()) { mNoMoreDesc.setText("No one has applied at the moment"); } - type = "guard"; } else if (Tips.equals("3")) { listMicbtn.setTextColor(Color.parseColor("#ff646464")); requestMicBtn.setTextColor(Color.parseColor("#ff646464")); @@ -362,7 +397,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi if (!WordUtil.isNewZh()) { mNoMoreDesc.setText("No audience at the moment"); } - type = "fans"; } } 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 c4b618153..714c7d1d2 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -42,6 +42,8 @@ import com.yunbao.common.event.SendBlindGiftEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.IMRTCManager; +import com.yunbao.common.manager.MicUserManager; +import com.yunbao.common.manager.MicedUserManager; import com.yunbao.common.manager.NewLevelManager; import com.yunbao.common.manager.RandomPkManager; import com.yunbao.common.utils.Bus; @@ -199,6 +201,7 @@ public class SocketRyClient { .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_MIC_LIST) .setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class)) ); + MicedUserManager.get().upDataMicUserList(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class)); } else if (actions == 6) { if (WordUtil.isNewZh()) { ToastUtil.show("主播已關閉當前語音連麥功能"); @@ -221,10 +224,12 @@ public class SocketRyClient { .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC) .setObject(map.toJavaObject(LinkMicUserBean.class)) ); + MicUserManager.get().upDataMicUser(map); } else if (actions == 7) {//取消连麦 Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL) ); + MicUserManager.get().removeMiscUser(map); } break; case Constants.UP_USER_LIST: @@ -754,7 +759,7 @@ public class SocketRyClient { case "SudGameCreateRoom": Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.SUD_GAME_CREATE_ROOM) - .setAvatar(WordUtil.isNewZh()?map.getString("sud_game_name"):map.getString("sud_game_name_en")) + .setAvatar(WordUtil.isNewZh() ? map.getString("sud_game_name") : map.getString("sud_game_name_en")) .setCreateSudRoomModel(GsonUtils.fromJson(map.toString(), SudGameDateModel.class))); break;