From a1d9b1f75bd58b1dc34467ab898242bd07aa562b Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 9 Dec 2022 16:47:00 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=87=AA=E7=94=B1PK=20=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...dapter.java => FreePkRecyclerAdapter.java} | 4 ++-- .../live/dialog/FreePkDialogFragment.java | 24 +++++++++---------- .../live/dialog/RandomPkDialogFragment.java | 7 +++++- 3 files changed, 19 insertions(+), 16 deletions(-) rename live/src/main/java/com/yunbao/live/adapter/{RandomPkRecyclerAdapter.java => FreePkRecyclerAdapter.java} (98%) diff --git a/live/src/main/java/com/yunbao/live/adapter/RandomPkRecyclerAdapter.java b/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java similarity index 98% rename from live/src/main/java/com/yunbao/live/adapter/RandomPkRecyclerAdapter.java rename to live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java index acf66fc1e..9b0b19aa6 100644 --- a/live/src/main/java/com/yunbao/live/adapter/RandomPkRecyclerAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java @@ -24,11 +24,11 @@ import com.yunbao.live.http.LiveHttpUtil; import java.util.Arrays; -public class RandomPkRecyclerAdapter extends RefreshAdapter { +public class FreePkRecyclerAdapter extends RefreshAdapter { private static final int HEAD = 0; private static final int ITEM = 2; - public RandomPkRecyclerAdapter(Context context) { + public FreePkRecyclerAdapter(Context context) { super(context); } diff --git a/live/src/main/java/com/yunbao/live/dialog/FreePkDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/FreePkDialogFragment.java index fa3866a2a..3b75255e0 100644 --- a/live/src/main/java/com/yunbao/live/dialog/FreePkDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/FreePkDialogFragment.java @@ -26,10 +26,9 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.StringUtil; -import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordsTypeUtil; 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.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 String TAG = "自由PK"; - private int mLiveUid; private TabLayout tabLayout; private View reset; private CommonRefreshView mRecyclerView; @@ -53,7 +51,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl private EditText mSearch; private TextView freePkNum; private ImageView mClear; - private RandomPkRecyclerAdapter adapter; + private FreePkRecyclerAdapter adapter; private DataHelper helper; private int tabStatus; @@ -83,10 +81,6 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl window.setAttributes(params); } - public void setLiveUid(int mLiveUid) { - this.mLiveUid = mLiveUid; - } - @Override public void onDestroy() { super.onDestroy(); @@ -133,7 +127,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl private void initRecycler() { helper = new DataHelper(); helper.setStatus(DataHelper.LIST_MODEL_LIST); - adapter = new RandomPkRecyclerAdapter(mContext); + adapter = new FreePkRecyclerAdapter(mContext); mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); mRecyclerView.setDataHelper(helper); mRecyclerView.initData(); @@ -142,7 +136,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl adapter.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(RandomPkUserBean bean, int position) { - if (position == -1) { + if (position == -1) {//-1是退出对话框,其他重刷数据 dismiss(); return; } @@ -233,8 +227,8 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl } public class DataHelper implements CommonRefreshView.DataHelper { - private final static int LIST_MODEL_LIST = 0; - private final static int LIST_MODEL_FOLLOW = 1; + private final static int LIST_MODEL_LIST = 0;//搜索列表 + private final static int LIST_MODEL_FOLLOW = 1;//关注列表 private int status; private String searchKey; @@ -242,6 +236,10 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl this.status = status; } + /** + * 搜索 + * @param key + */ public void search(String key) { if (StringUtil.isEmpty(key)) { adapter.getList().clear(); @@ -298,7 +296,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl return list; } List beans = JSON.parseArray(Arrays.toString(info), LivePkBean.class); - list.add(null); + list.add(null);//因为有个Head头部,所以数据全部下移一位 for (LivePkBean bean : beans) { RandomPkUserBean userBean = new RandomPkUserBean(); userBean.setId(bean.getUid()); diff --git a/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java index 3925c7375..01a45d438 100644 --- a/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java @@ -233,7 +233,9 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On }); } - + /** + * 开始匹配 + */ private void randomPk() { if (mRandomPkSwitch.getTag() == null || !(boolean) mRandomPkSwitch.getTag()) { ToastUtil.show("未开启随机PK开关"); @@ -262,6 +264,9 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On } + /** + * 恢复按钮状态 + */ private void resetPkBtn() { mPkBtnDesc.setVisibility(View.GONE); mPkBtnTitle.setText(R.string.random_pk_info_btn_start);