补充个人名片主播端踢人选项
This commit is contained in:
parent
af39c4bac0
commit
2119d75e5b
@ -98,6 +98,8 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
|||||||
private String mToUid;
|
private String mToUid;
|
||||||
private String mStream;
|
private String mStream;
|
||||||
private int mType;
|
private int mType;
|
||||||
|
private int mAction;
|
||||||
|
private String mToName;//对方的名字
|
||||||
private TextView mFollowText;
|
private TextView mFollowText;
|
||||||
private TextView mName;
|
private TextView mName;
|
||||||
private TextView mID;
|
private TextView mID;
|
||||||
@ -123,6 +125,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
|||||||
private ImageView shawl;
|
private ImageView shawl;
|
||||||
private ImageView honorIcon;
|
private ImageView honorIcon;
|
||||||
private ImageView mTitleBg;
|
private ImageView mTitleBg;
|
||||||
|
private ImageView mSetting;
|
||||||
private UserBean mUserBean;
|
private UserBean mUserBean;
|
||||||
private LinearLayout mGuardLayout;
|
private LinearLayout mGuardLayout;
|
||||||
private LinearLayout mUnionLayout;
|
private LinearLayout mUnionLayout;
|
||||||
@ -242,7 +245,9 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
|||||||
mNobleTitleVal = mRootView.findViewById(R.id.noble_title_val);
|
mNobleTitleVal = mRootView.findViewById(R.id.noble_title_val);
|
||||||
mHonorLayout = mRootView.findViewById(R.id.honor_layout);
|
mHonorLayout = mRootView.findViewById(R.id.honor_layout);
|
||||||
mTitleBg = mRootView.findViewById(R.id.title_bg);
|
mTitleBg = mRootView.findViewById(R.id.title_bg);
|
||||||
|
mSetting = mRootView.findViewById(R.id.btn_setting);
|
||||||
mNobleIconLayout.setOnClickListener(this);
|
mNobleIconLayout.setOnClickListener(this);
|
||||||
|
mSetting.setOnClickListener(this);
|
||||||
mHonorLayout.setOnClickListener(v -> forwardHomePage());
|
mHonorLayout.setOnClickListener(v -> forwardHomePage());
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -299,11 +304,17 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
|||||||
Log.i(TAG, "showData: " + data);
|
Log.i(TAG, "showData: " + data);
|
||||||
JSONObject obj = JSON.parseObject(data);
|
JSONObject obj = JSON.parseObject(data);
|
||||||
mUserBean = JSON.toJavaObject(obj, UserBean.class);
|
mUserBean = JSON.toJavaObject(obj, UserBean.class);
|
||||||
|
|
||||||
|
mToName = obj.getString("user_nicename");
|
||||||
|
mAction = obj.getIntValue("action");
|
||||||
if (mUserBean.getIslive().equals("1")) {
|
if (mUserBean.getIslive().equals("1")) {
|
||||||
btn_live.setVisibility(View.VISIBLE);
|
btn_live.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
btn_live.setVisibility(View.GONE);
|
btn_live.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
if(mType==TYPE_ANC_AUD){
|
||||||
|
mSetting.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
if (isAnchor) {
|
if (isAnchor) {
|
||||||
mGuardLayout.setVisibility(View.VISIBLE);
|
mGuardLayout.setVisibility(View.VISIBLE);
|
||||||
if (obj.containsKey("user_president_name") && !StringUtil.isEmpty(obj.getString("user_president_name"))) {
|
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();
|
dismiss();
|
||||||
((LiveActivity) mContext).openFansWindow();
|
((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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,17 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</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>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user