Commit 5839c9ac4b48ca91360437ef9a7ccbf58cc5cbe2
1 parent
e9cd98ac
1 优化选择联系人时,默认不可选择的联系人个数
Showing
3 changed files
with
14 additions
and
9 deletions
config.gradle
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SelectIMFriendView.java
| ... | ... | @@ -94,14 +94,18 @@ public class SelectIMFriendView implements MvpView, LetterBarView.OnLetterSelect |
| 94 | 94 | noLetterInfoList.add(noLetterInfo); |
| 95 | 95 | |
| 96 | 96 | } |
| 97 | + int hasSelectCount = 0; | |
| 98 | + if (null != hasSelectList) { | |
| 99 | + hasSelectCount = hasSelectList.size(); | |
| 100 | + } | |
| 97 | 101 | //设置 |
| 98 | - initView(noLetterInfoList); | |
| 102 | + initView(noLetterInfoList, hasSelectCount); | |
| 99 | 103 | |
| 100 | 104 | } |
| 101 | 105 | }); |
| 102 | 106 | } |
| 103 | 107 | |
| 104 | - public void initView(List<IMFriendNoLetterInfo> list) { | |
| 108 | + public void initView(List<IMFriendNoLetterInfo> list, int hasSelectCount) { | |
| 105 | 109 | //设置按钮不可点击 |
| 106 | 110 | nextBtnCanNotClick(); |
| 107 | 111 | //假设这个是原有数据 |
| ... | ... | @@ -219,6 +223,7 @@ public class SelectIMFriendView implements MvpView, LetterBarView.OnLetterSelect |
| 219 | 223 | } |
| 220 | 224 | } |
| 221 | 225 | adapter = new SelectIMFriendAdapter(getContext(), imFriendInfoList); |
| 226 | + adapter.setCantSelectCount(hasSelectCount); | |
| 222 | 227 | linearLayoutManager = new LinearLayoutManager(getContext()); |
| 223 | 228 | fragment.binding.rvFriends.setLayoutManager(linearLayoutManager); |
| 224 | 229 | fragment.binding.rvFriends.setAdapter(adapter); | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/SelectIMFriendAdapter.java
| ... | ... | @@ -28,10 +28,14 @@ public class SelectIMFriendAdapter extends RecyclerView.Adapter { |
| 28 | 28 | private HashMap<String, Integer> contactLetterGuideMap; |
| 29 | 29 | private List<IMFriendHasLetterInfo> rawDataList; |
| 30 | 30 | private OnItemCheckBoxListener onItemCheckBoxListener; |
| 31 | - private int MAX_FRIENDS = 10;//最多10个人 | |
| 31 | + private int MAX_FRIENDS = 10;//最多10个人 | |
| 32 | 32 | |
| 33 | 33 | private String TAG = "SelectIMFriendAdapter"; |
| 34 | 34 | |
| 35 | + public void setCantSelectCount(int hasSelectCount) { | |
| 36 | + this.MAX_FRIENDS -= hasSelectCount; | |
| 37 | + } | |
| 38 | + | |
| 35 | 39 | public void setOnItemCheckBoxListener(OnItemCheckBoxListener onItemCheckBoxListener) { |
| 36 | 40 | this.onItemCheckBoxListener = onItemCheckBoxListener; |
| 37 | 41 | } |
| ... | ... | @@ -64,11 +68,7 @@ public class SelectIMFriendAdapter extends RecyclerView.Adapter { |
| 64 | 68 | if (imFriendInfoList.get(i).getType() == IMFriendHasLetterInfo.LETTER_INDEX) { |
| 65 | 69 | contactLetterGuideMap.put(imFriendInfoList.get(i).getLetter(), i); |
| 66 | 70 | } |
| 67 | - //不可选 | |
| 68 | - if (imFriendInfoList.get(i).isCantSelect()){ | |
| 69 | - //获取默认不可选的人 | |
| 70 | - MAX_FRIENDS--; | |
| 71 | - } | |
| 71 | + | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | } | ... | ... |