补充个人名片主播端踢人选项

This commit is contained in:
zlzw 2022-11-12 15:48:45 +08:00
parent af39c4bac0
commit 2119d75e5b
2 changed files with 215 additions and 0 deletions

View File

@ -98,6 +98,8 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
private String mToUid;
private String mStream;
private int mType;
private int mAction;
private String mToName;//对方的名字
private TextView mFollowText;
private TextView mName;
private TextView mID;
@ -123,6 +125,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
private ImageView shawl;
private ImageView honorIcon;
private ImageView mTitleBg;
private ImageView mSetting;
private UserBean mUserBean;
private LinearLayout mGuardLayout;
private LinearLayout mUnionLayout;
@ -242,7 +245,9 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
mNobleTitleVal = mRootView.findViewById(R.id.noble_title_val);
mHonorLayout = mRootView.findViewById(R.id.honor_layout);
mTitleBg = mRootView.findViewById(R.id.title_bg);
mSetting = mRootView.findViewById(R.id.btn_setting);
mNobleIconLayout.setOnClickListener(this);
mSetting.setOnClickListener(this);
mHonorLayout.setOnClickListener(v -> forwardHomePage());
}
@ -299,11 +304,17 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
Log.i(TAG, "showData: " + data);
JSONObject obj = JSON.parseObject(data);
mUserBean = JSON.toJavaObject(obj, UserBean.class);
mToName = obj.getString("user_nicename");
mAction = obj.getIntValue("action");
if (mUserBean.getIslive().equals("1")) {
btn_live.setVisibility(View.VISIBLE);
} else {
btn_live.setVisibility(View.GONE);
}
if(mType==TYPE_ANC_AUD){
mSetting.setVisibility(View.VISIBLE);
}
if (isAnchor) {
mGuardLayout.setVisibility(View.VISIBLE);
if (obj.containsKey("user_president_name") && !StringUtil.isEmpty(obj.getString("user_president_name"))) {
@ -623,6 +634,199 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
dismiss();
((LiveActivity) mContext).openFansWindow();
}
} else if (i == R.id.btn_setting) {
setting();
}
}
/**
* 设置
* <p>
* 某个大神说角色是权限的集合
* <p>
* 理论上角色的权限应该有服务端以数组或集合的形式返回这样可以在后台动态配置某种角色的权限而不是这样口头约定写死
* 然而是服务端这样做的我也很无奈也许他们不知道如何做成动态配置的吧
* <p>
* 我一直想通过不断重构把代码写的像艺术品然而最近发现这完全是多此一举自讨苦吃是我太天真了
* 下面是我发现的一篇文章说的非常好也点醒了我如果你们发现当前代码写的太烂不堪入目的话请阅读下面的文章
* <p>
* https://www.jianshu.com/p/71521541cd25?utm_campaign=haruki&utm_content=note&utm_medium=reader_share&utm_source=weixin_timeline&from=timeline
*/
private void setting() {
List<Integer> list = new ArrayList<>();
switch (mAction) {
case SETTING_ACTION_ADM://设置 房间管理员点普通观众
list.add(R.string.live_setting_kick);
// list.add(R.string.live_setting_gap);
list.add(R.string.live_setting_gap_2);
break;
case SETTING_ACTION_SUP://设置 超管点主播
list.add(R.string.live_setting_close_live);
list.add(R.string.live_setting_close_live_2);
list.add(R.string.live_setting_forbid_account);
break;
case SETTING_ACTION_ANC_AUD://设置 主播点普通观众
list.add(R.string.live_setting_kick);
// list.add(R.string.live_setting_gap);
list.add(R.string.live_setting_gap_2);
list.add(R.string.live_setting_admin);
list.add(R.string.live_setting_admin_list);
break;
case SETTING_ACTION_ANC_ADM://设置 主播点房间管理员
list.add(R.string.live_setting_kick);
// list.add(R.string.live_setting_gap);
list.add(R.string.live_setting_gap_2);
list.add(R.string.live_setting_admin_cancel);
list.add(R.string.live_setting_admin_list);
break;
}
DialogUitl.showStringArrayDialog(mContext, list.toArray(new Integer[list.size()]), mArrayDialogCallback);
}
private DialogUitl.StringArrayDialogCallback mArrayDialogCallback = new DialogUitl.StringArrayDialogCallback() {
@Override
public void onItemClick(String text, int tag) {
if (tag == R.string.live_setting_kick) {
kick();
} else if (tag == R.string.live_setting_gap) {//永久禁言->改成三天禁言
setShutUp();
} else if (tag == R.string.live_setting_gap_2) {//本场禁言
setShutUp2();
} else if (tag == R.string.live_setting_admin || tag == R.string.live_setting_admin_cancel) {
setAdmin();
} else if (tag == R.string.live_setting_admin_list) {
adminList();
} else if (tag == R.string.live_setting_close_live) {
closeLive();
} else if (tag == R.string.live_setting_forbid_account) {
forbidAccount();
} else if (tag == R.string.live_setting_close_live_2) {//禁用直播
closeLive2();
}
}
};
/**
* 查看管理员列表
*/
private void adminList() {
dismiss();
((LiveActivity) mContext).openAdminListWindow();
}
/**
* 踢人
*/
private void kick() {
LiveHttpUtil.kicking(mLiveUid, mToUid, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
((LiveActivity) mContext).kickUser(mToUid, mToName);
} else {
ToastUtil.show(msg);
}
}
});
}
/**
* 永久禁言->改成三天禁言
*/
private void setShutUp() {
LiveHttpUtil.setShutUp(mLiveUid, "0", 0, mToUid, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
((LiveActivity) mContext).setShutUp(mToUid, mToName, 0);
} else {
ToastUtil.show(msg);
}
}
});
}
/**
* 本场禁言
*/
private void setShutUp2() {
LiveHttpUtil.setShutUp(mLiveUid, mStream, 1, mToUid, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
((LiveActivity) mContext).setShutUp(mToUid, mToName, 1);
} else {
ToastUtil.show(msg);
}
}
});
}
/**
* 设置或取消管理员
*/
private void setAdmin() {
LiveHttpUtil.setAdmin(mLiveUid, mToUid, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
int res = JSON.parseObject(info[0]).getIntValue("isadmin");
if (res == 1) {//被设为管理员
mAction = SETTING_ACTION_ANC_ADM;
} else {//被取消管理员
mAction = SETTING_ACTION_ANC_AUD;
}
((LiveActivity) mContext).sendSetAdminMessage(res, mToUid, mToName);
}
}
});
}
/**
* 超管关闭直播间
*/
private void closeLive() {
dismiss();
LiveHttpUtil.superCloseRoom(mLiveUid, 0, mSuperCloseRoomCallback);
}
/**
* 超管关闭直播间并禁止主播直播
*/
private void closeLive2() {
dismiss();
LiveHttpUtil.superCloseRoom(mLiveUid, 1, mSuperCloseRoomCallback);
}
/**
* 超管关闭直播间并禁用主播账户
*/
private void forbidAccount() {
dismiss();
LiveHttpUtil.superCloseRoom(mLiveUid, 2, mSuperCloseRoomCallback);
}
private HttpCallback mSuperCloseRoomCallback = new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
ToastUtil.show(JSON.parseObject(info[0]).getString("msg"));
((LiveActivity) mContext).superCloseRoom();
} else {
ToastUtil.show(msg);
}
}
};
}

View File

@ -63,6 +63,17 @@
</LinearLayout>
<ImageView
android:id="@+id/btn_setting"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="32dp"
android:layout_marginTop="14dp"
android:padding="8dp"
android:src="@mipmap/icon_live_user_6"
android:visibility="invisible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>