update 自由PK 注释

This commit is contained in:
zlzw 2022-12-09 16:47:00 +08:00
parent afed0c8833
commit a1d9b1f75b
3 changed files with 19 additions and 16 deletions

View File

@ -24,11 +24,11 @@ import com.yunbao.live.http.LiveHttpUtil;
import java.util.Arrays; import java.util.Arrays;
public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> { public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
private static final int HEAD = 0; private static final int HEAD = 0;
private static final int ITEM = 2; private static final int ITEM = 2;
public RandomPkRecyclerAdapter(Context context) { public FreePkRecyclerAdapter(Context context) {
super(context); super(context);
} }

View File

@ -26,10 +26,9 @@ 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.FreePkRecyclerAdapter;
import com.yunbao.live.bean.LivePkBean; import com.yunbao.live.bean.LivePkBean;
import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.http.LiveHttpUtil;
@ -45,7 +44,6 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
private static final int TAB_STATUS_FOLLOW = 2; private static final int TAB_STATUS_FOLLOW = 2;
private static final String TAG = "自由PK"; private static final String TAG = "自由PK";
private int mLiveUid;
private TabLayout tabLayout; private TabLayout tabLayout;
private View reset; private View reset;
private CommonRefreshView mRecyclerView; private CommonRefreshView mRecyclerView;
@ -53,7 +51,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
private EditText mSearch; private EditText mSearch;
private TextView freePkNum; private TextView freePkNum;
private ImageView mClear; private ImageView mClear;
private RandomPkRecyclerAdapter adapter; private FreePkRecyclerAdapter adapter;
private DataHelper helper; private DataHelper helper;
private int tabStatus; private int tabStatus;
@ -83,10 +81,6 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
window.setAttributes(params); window.setAttributes(params);
} }
public void setLiveUid(int mLiveUid) {
this.mLiveUid = mLiveUid;
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
@ -133,7 +127,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
private void initRecycler() { private void initRecycler() {
helper = new DataHelper(); helper = new DataHelper();
helper.setStatus(DataHelper.LIST_MODEL_LIST); helper.setStatus(DataHelper.LIST_MODEL_LIST);
adapter = new RandomPkRecyclerAdapter(mContext); adapter = new FreePkRecyclerAdapter(mContext);
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();
@ -142,7 +136,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
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) { if (position == -1) {//-1是退出对话框其他重刷数据
dismiss(); dismiss();
return; return;
} }
@ -233,8 +227,8 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
} }
public class DataHelper implements CommonRefreshView.DataHelper<RandomPkUserBean> { public class DataHelper implements CommonRefreshView.DataHelper<RandomPkUserBean> {
private final static int LIST_MODEL_LIST = 0; private final static int LIST_MODEL_LIST = 0;//搜索列表
private final static int LIST_MODEL_FOLLOW = 1; private final static int LIST_MODEL_FOLLOW = 1;//关注列表
private int status; private int status;
private String searchKey; private String searchKey;
@ -242,6 +236,10 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
this.status = status; this.status = status;
} }
/**
* 搜索
* @param key
*/
public void search(String key) { public void search(String key) {
if (StringUtil.isEmpty(key)) { if (StringUtil.isEmpty(key)) {
adapter.getList().clear(); adapter.getList().clear();
@ -298,7 +296,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
return list; return list;
} }
List<LivePkBean> beans = JSON.parseArray(Arrays.toString(info), LivePkBean.class); List<LivePkBean> beans = JSON.parseArray(Arrays.toString(info), LivePkBean.class);
list.add(null); list.add(null);//因为有个Head头部所以数据全部下移一位
for (LivePkBean bean : beans) { for (LivePkBean bean : beans) {
RandomPkUserBean userBean = new RandomPkUserBean(); RandomPkUserBean userBean = new RandomPkUserBean();
userBean.setId(bean.getUid()); userBean.setId(bean.getUid());

View File

@ -233,7 +233,9 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
}); });
} }
/**
* 开始匹配
*/
private void randomPk() { private void randomPk() {
if (mRandomPkSwitch.getTag() == null || !(boolean) mRandomPkSwitch.getTag()) { if (mRandomPkSwitch.getTag() == null || !(boolean) mRandomPkSwitch.getTag()) {
ToastUtil.show("未开启随机PK开关"); ToastUtil.show("未开启随机PK开关");
@ -262,6 +264,9 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
} }
/**
* 恢复按钮状态
*/
private void resetPkBtn() { private void resetPkBtn() {
mPkBtnDesc.setVisibility(View.GONE); mPkBtnDesc.setVisibility(View.GONE);
mPkBtnTitle.setText(R.string.random_pk_info_btn_start); mPkBtnTitle.setText(R.string.random_pk_info_btn_start);