update 自由PK

This commit is contained in:
zlzw 2022-12-10 14:55:03 +08:00
parent a7cf09de1e
commit c056dfe246
7 changed files with 138 additions and 27 deletions

View File

@ -9,7 +9,6 @@ import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.FaceBookUpModel;
import com.yunbao.common.bean.HourRank; import com.yunbao.common.bean.HourRank;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LinkMicUserBeanV2; import com.yunbao.common.bean.LinkMicUserBeanV2;
import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveInfoModel;
@ -358,10 +357,10 @@ public interface PDLiveApi {
@GET("/api/public/?service=Livepk.setRandomPKType") @GET("/api/public/?service=Livepk.setRandomPKType")
Observable<ResponseModel<List<BaseModel>>> changeRandomPkSwitch(@Query("random_pk") int pk); Observable<ResponseModel<List<BaseModel>>> changeRandomPkSwitch(@Query("random_pk") int pk);
/** /**
* 获取随机PK次数 * 获取自由PK次数
*/ */
@GET("/api/public/?service=Livepk.getRandomPKType") @GET("/api/public/?service=Livepk.getActivePkNum")
Observable<ResponseModel<Integer>> getRandomPkNumber(); Observable<ResponseModel<Integer>> getFreePkNumber();
/** /**
* 发起随机PK * 发起随机PK
*/ */
@ -376,7 +375,7 @@ public interface PDLiveApi {
* 自由PK开始后调用接口扣掉次数 * 自由PK开始后调用接口扣掉次数
*/ */
@GET("/api/public/?service=Livepk.setActivePkNum") @GET("/api/public/?service=Livepk.setActivePkNum")
Observable<ResponseModel<BaseModel>> setRandomPkNum(); Observable<ResponseModel<BaseModel>> setFreePkNum();
/** /**
* 随机PK搜索用户 * 随机PK搜索用户
* @param cs 简体关键字/uid * @param cs 简体关键字/uid

View File

@ -4,7 +4,6 @@ import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.ActiveModel;
@ -564,11 +563,11 @@ public class LiveNetManager {
} }
/** /**
* 获取随机PK次数 * 获取自由PK次数
*/ */
public void getRandomPkNumber(HttpCallback<Integer> callback) { public void getFreePkNumber(HttpCallback<Integer> callback) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.getRandomPkNumber() .getFreePkNumber()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(new Consumer<ResponseModel<Integer>>() { .subscribe(new Consumer<ResponseModel<Integer>>() {
@ -616,9 +615,9 @@ public class LiveNetManager {
/** /**
* 自由PK开始后调用接口扣掉次数 * 自由PK开始后调用接口扣掉次数
*/ */
public void setRandomPkNum(HttpCallback<HttpCallbackModel> callback) { public void setFreePkNum(HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.setRandomPkNum() .setFreePkNum()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(new Consumer<ResponseModel<BaseModel>>() { .subscribe(new Consumer<ResponseModel<BaseModel>>() {

View File

@ -17,13 +17,12 @@ import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity; import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.http.LiveHttpUtil;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; import java.util.Arrays;
import cn.rongcloud.rtc.base.RTCErrorCode;
public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> { public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
private static final int HEAD = 0; private static final int HEAD = 0;
@ -102,9 +101,23 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
ToastUtil.show(R.string.free_pk_user_pking); ToastUtil.show(R.string.free_pk_user_pking);
return; return;
} }
LiveHttpUtil.getMicList(LiveRyAnchorActivity.mLiveUid, 0, new com.yunbao.common.http.HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
//非0认为未开通连麦权限
if (code != 0) {
ToastUtil.show("邀请 " + bean.getUserNiceName() + " 发送成功");
mOnItemClickListener.onItemClick(bean, -1);
((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(), ((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString() ((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString()
); );
} else {
ToastUtil.show("請先關閉語言連麥");
}
}
});
}); });
mFollow.setOnClickListener(v -> { mFollow.setOnClickListener(v -> {
RandomPkUserBean bean = (RandomPkUserBean) itemView.getTag(); RandomPkUserBean bean = (RandomPkUserBean) itemView.getTag();

View File

@ -10,6 +10,7 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -25,6 +26,7 @@ import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordsTypeUtil; import com.yunbao.common.utils.WordsTypeUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.adapter.RandomPkRecyclerAdapter; import com.yunbao.live.adapter.RandomPkRecyclerAdapter;
@ -49,6 +51,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
private CommonRefreshView mRecyclerView; private CommonRefreshView mRecyclerView;
private View mSearchLayout; private View mSearchLayout;
private EditText mSearch; private EditText mSearch;
private TextView freePkNum;
private ImageView mClear; private ImageView mClear;
private RandomPkRecyclerAdapter adapter; private RandomPkRecyclerAdapter adapter;
private DataHelper helper; private DataHelper helper;
@ -75,7 +78,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
WindowManager.LayoutParams params = window.getAttributes(); WindowManager.LayoutParams params = window.getAttributes();
window.setWindowAnimations(R.style.bottomToTopAnim); window.setWindowAnimations(R.style.bottomToTopAnim);
params.width = WindowManager.LayoutParams.MATCH_PARENT; params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = DpUtil.dp2px(330); params.height = DpUtil.dp2px(400);
params.gravity = Gravity.BOTTOM; params.gravity = Gravity.BOTTOM;
window.setAttributes(params); window.setAttributes(params);
} }
@ -104,7 +107,9 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
mSearchLayout = findViewById(R.id.random_pk_search_layout); mSearchLayout = findViewById(R.id.random_pk_search_layout);
mSearch = (EditText) findViewById(R.id.search_edit); mSearch = (EditText) findViewById(R.id.search_edit);
mClear = (ImageView) findViewById(R.id.search_clear); mClear = (ImageView) findViewById(R.id.search_clear);
freePkNum = (TextView) findViewById(R.id.free_pk_num);
mClear.setOnClickListener(this); mClear.setOnClickListener(this);
reset.setOnClickListener(this);
mSearch.addTextChangedListener(new TextWatcher() { mSearch.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -132,10 +137,15 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
mRecyclerView.setDataHelper(helper); mRecyclerView.setDataHelper(helper);
mRecyclerView.initData(); mRecyclerView.initData();
mRecyclerView.setRefreshEnable(false);
mRecyclerView.setEmptyLayoutId(R.layout.view_live_search_list_empty); mRecyclerView.setEmptyLayoutId(R.layout.view_live_search_list_empty);
adapter.setOnItemClickListener(new OnItemClickListener<RandomPkUserBean>() { adapter.setOnItemClickListener(new OnItemClickListener<RandomPkUserBean>() {
@Override @Override
public void onItemClick(RandomPkUserBean bean, int position) { public void onItemClick(RandomPkUserBean bean, int position) {
if (position == -1) {
dismiss();
return;
}
mRecyclerView.initData(); mRecyclerView.initData();
} }
}); });
@ -143,6 +153,17 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
private void initData() { private void initData() {
LiveNetManager.get(mContext).getFreePkNumber(new com.yunbao.common.http.base.HttpCallback<Integer>() {
@Override
public void onSuccess(Integer data) {
freePkNum.setText("" + data);
}
@Override
public void onError(String error) {
}
});
} }
private void initTab() { private void initTab() {
@ -198,8 +219,14 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
@Override @Override
public void onClick(View v) { public void onClick(View v) {
int id = v.getId(); int id = v.getId();
if (id == R.id.live_random_pk_switch) { if (id == R.id.menu_reset) {
if (helper.status == DataHelper.LIST_MODEL_LIST) {
mSearch.setText("");
mRecyclerView.initData();
mRecyclerView.showEmpty();
} else {
mRecyclerView.initData();
}
} else if (id == R.id.search_clear) { } else if (id == R.id.search_clear) {
mSearch.setText(""); mSearch.setText("");
} }
@ -266,8 +293,11 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
@Override @Override
public List<RandomPkUserBean> processData(String[] info) { public List<RandomPkUserBean> processData(String[] info) {
Log.i(TAG, "processData: 获取数据成功"); Log.i(TAG, "processData: 获取数据成功");
List<LivePkBean> beans = JSON.parseArray(Arrays.toString(info), LivePkBean.class);
List<RandomPkUserBean> list = new ArrayList<>(); List<RandomPkUserBean> list = new ArrayList<>();
if (info == null || info.length == 0) {
return list;
}
List<LivePkBean> beans = JSON.parseArray(Arrays.toString(info), LivePkBean.class);
list.add(null); list.add(null);
for (LivePkBean bean : beans) { for (LivePkBean bean : beans) {
RandomPkUserBean userBean = new RandomPkUserBean(); RandomPkUserBean userBean = new RandomPkUserBean();
@ -283,7 +313,6 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
@Override @Override
public void onRefreshSuccess(List<RandomPkUserBean> list, int listCount) { public void onRefreshSuccess(List<RandomPkUserBean> list, int listCount) {
} }
@Override @Override
@ -298,7 +327,6 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
@Override @Override
public void onLoadMoreFailure() { public void onLoadMoreFailure() {
mRecyclerView.showEmpty();
} }
} }
} }

View File

@ -32,9 +32,11 @@ import com.tencent.rtmp.TXLiveConstants;
import com.tencent.trtc.TRTCCloudDef; import com.tencent.trtc.TRTCCloudDef;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.RandomPkManager; import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
@ -311,6 +313,18 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
} }
mLiveRyLinkMicPkPresenter.onLinkMicToPk(userBean1); mLiveRyLinkMicPkPresenter.onLinkMicToPk(userBean1);
mLiveRyLinkMicPkPresenter.onLinkMicPkStart(inviteeRoomId, 3); mLiveRyLinkMicPkPresenter.onLinkMicPkStart(inviteeRoomId, 3);
//单人PK减掉次数
LiveNetManager.get(mContext).setFreePkNum(new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
} }
} }
}); });

View File

@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="330dp" android:layout_height="430dp"
android:background="@drawable/bg_live_tota"> android:background="@drawable/bg_live_tota">
<LinearLayout <LinearLayout
android:id="@+id/random_menu_layout" android:id="@+id/random_menu_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:orientation="vertical" android:orientation="vertical"
android:visibility="visible" android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -105,4 +106,61 @@
</com.yunbao.common.custom.CommonRefreshView> </com.yunbao.common.custom.CommonRefreshView>
</LinearLayout> </LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/background_7792d0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/tmp_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="自由PK剩余次數"
android:textColor="#9A9A9A"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/free_pk_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="-2"
android:textColor="#FFFFFF"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/tmp_text1"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tmp_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="每日凌晨6点更新"
android:textColor="#9A9A9A"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tmp_text2"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/icon_free_pk_waring" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B