Commit d49f39e2b91c6b782fdef99ac0b4064faa297600
1 parent
3c0738f5
1 完成设置角色逻辑
Showing
39 changed files
with
1232 additions
and
51 deletions
app/src/main/java/com/cnlive/strike/xiaojiaspeaker/MainActivity.java
| ... | ... | @@ -27,13 +27,13 @@ public class MainActivity extends AppCompatActivity { |
| 27 | 27 | // startActivity(new Intent(MainActivity.this, BluetoothConnActivity.class)); |
| 28 | 28 | // startActivity(new Intent(MainActivity.this, BlueToothStep1Activity.class)); |
| 29 | 29 | // startActivity(new Intent(MainActivity.this, ConnBluetoothSuccessActivity.class)); |
| 30 | - startActivity(new Intent(MainActivity.this, AllDeviceActivity.class)); | |
| 30 | +// startActivity(new Intent(MainActivity.this, AllDeviceActivity.class)); | |
| 31 | 31 | // startActivity(new Intent(MainActivity.this, DeviceInstructionActivity.class)); |
| 32 | 32 | // startActivity(new Intent(MainActivity.this, DeviceManagerActivity.class)); |
| 33 | 33 | // startActivity(new Intent(MainActivity.this, FirmwareUpdateActivity.class)); |
| 34 | 34 | // startActivity(new Intent(MainActivity.this, SelectWifiActivity.class)); |
| 35 | 35 | // startActivity(new Intent(MainActivity.this, ToolBarTestActivity.class)); |
| 36 | -// startActivity(new Intent(MainActivity.this, SelectIMFriendActivity.class)); | |
| 36 | + startActivity(new Intent(MainActivity.this, SelectIMFriendActivity.class)); | |
| 37 | 37 | finish(); |
| 38 | 38 | } |
| 39 | 39 | ... | ... |
module_xiaojiaSoundBox/src/main/AndroidManifest.xml
| ... | ... | @@ -17,7 +17,8 @@ |
| 17 | 17 | <uses-permission android:name="android.permission.INTERNET" /> |
| 18 | 18 | |
| 19 | 19 | <application> |
| 20 | - <activity android:name=".ui.activity.SelectIMFriendActivity"></activity> | |
| 20 | + <activity android:name=".ui.activity.SetFriendsRoleActivity"></activity> | |
| 21 | + <activity android:name=".ui.activity.SelectIMFriendActivity" /> | |
| 21 | 22 | <activity android:name=".ui.activity.FirmwareUpdateActivity" /> |
| 22 | 23 | <activity android:name=".ui.activity.DeviceManagerActivity" /> |
| 23 | 24 | <activity android:name=".ui.activity.DeviceInstructionActivity" /> | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/SetFriendsRolePresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.util.Log; | |
| 5 | +import android.view.View; | |
| 6 | + | |
| 7 | +import com.cnlive.libs.base.logic.Logic; | |
| 8 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 9 | +import com.cnlive.libs.base.logic.callback.FailureCallback; | |
| 10 | +import com.cnlive.libs.base.logic.callback.SuccessCallback; | |
| 11 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.SetFriendsRoleView; | |
| 12 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | |
| 13 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyListBean; | |
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | |
| 15 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.SubscriptionBaseInfo; | |
| 16 | +import com.cnlive.strike.xiaojiaspeaker.netWork.result.SubscriptionRequest; | |
| 17 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 18 | + | |
| 19 | +import java.util.HashMap; | |
| 20 | +import java.util.Map; | |
| 21 | + | |
| 22 | +import io.reactivex.disposables.Disposable; | |
| 23 | + | |
| 24 | +public class SetFriendsRolePresenter extends MvpBasePresenter<SetFriendsRoleView> { | |
| 25 | + | |
| 26 | + private String TAG = "SetFriendsRolePresenter"; | |
| 27 | + | |
| 28 | + public void getSetRoleList(Context context, String sids, String familyId) { | |
| 29 | + if (null == getView()) { | |
| 30 | + return; | |
| 31 | + } | |
| 32 | + Map<String, String> map = new HashMap<>(); | |
| 33 | + map.put("sids", sids); | |
| 34 | + map.put("familyId", familyId); | |
| 35 | + Logic.create(map) | |
| 36 | + .action(new Logic.Action<Map<String, String>, SubscriptionBaseInfo<RoleNetBean>>() { | |
| 37 | + @Override | |
| 38 | + public Disposable action(Map<String, String> paramsMap, DataCallback<SubscriptionBaseInfo<RoleNetBean>> dataCallback) { | |
| 39 | + return SubscriptionRequest.service(ApiServiceXiaoJia.class, api -> api.getSetRoleList(paramsMap)).subscribe(context, dataCallback); | |
| 40 | + } | |
| 41 | + }).<SubscriptionBaseInfo<RoleNetBean>>event() | |
| 42 | + .setSuccessCallback(new SuccessCallback<SubscriptionBaseInfo<RoleNetBean>>() { | |
| 43 | + @Override | |
| 44 | + public void onSuccess(SubscriptionBaseInfo<RoleNetBean> baseInfo) { | |
| 45 | + Log.e(TAG, "onSuccess: "); | |
| 46 | + | |
| 47 | + if (null == getView()) { | |
| 48 | + return; | |
| 49 | + } | |
| 50 | + for (int i=0;i<baseInfo.getData().getRoleList().size();i++){ | |
| 51 | + if (baseInfo.getData().getRoleList().get(i).getRoleName().equals("哥哥")){ | |
| 52 | + baseInfo.getData().getRoleList().get(i).setAllowUse(false); | |
| 53 | + } | |
| 54 | + } | |
| 55 | + getView().initView(baseInfo.getData()); | |
| 56 | + | |
| 57 | + } | |
| 58 | + }) | |
| 59 | + .setFailureCallback(new FailureCallback() { | |
| 60 | + @Override | |
| 61 | + public void onFailure(int i, String s) { | |
| 62 | + //显示重试 | |
| 63 | + Log.e(TAG, "onFailure: "+s); | |
| 64 | + } | |
| 65 | + }) | |
| 66 | + | |
| 67 | + .start(); | |
| 68 | + } | |
| 69 | +} | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SelectIMFriendView.java
| 1 | 1 | package com.cnlive.strike.xiaojiaspeaker.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity; |
| 4 | +import android.content.Context; | |
| 5 | +import android.support.v4.content.ContextCompat; | |
| 4 | 6 | import android.support.v7.widget.LinearLayoutManager; |
| 7 | +import android.text.Editable; | |
| 8 | +import android.text.TextUtils; | |
| 9 | +import android.text.TextWatcher; | |
| 10 | +import android.util.Log; | |
| 11 | +import android.view.View; | |
| 12 | +import android.view.WindowManager; | |
| 13 | +import android.view.inputmethod.InputMethodManager; | |
| 5 | 14 | |
| 15 | +import com.cnlive.strike.ui.widget.LetterBarView; | |
| 16 | +import com.cnlive.strike.xiaojiaspeaker.R; | |
| 6 | 17 | import com.cnlive.strike.xiaojiaspeaker.model.IMFriendHasLetterInfo; |
| 7 | 18 | import com.cnlive.strike.xiaojiaspeaker.model.IMFriendNoLetterInfo; |
| 19 | +import com.cnlive.strike.xiaojiaspeaker.model.LetterComparator; | |
| 20 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.SetFriendsRoleActivity; | |
| 8 | 21 | import com.cnlive.strike.xiaojiaspeaker.ui.adapter.SelectIMFriendAdapter; |
| 9 | 22 | import com.cnlive.strike.xiaojiaspeaker.ui.fragment.SelectIMFriendFragment; |
| 23 | +import com.cnlive.strike.xiaojiaspeaker.util.utilcode.util.GsonUtils; | |
| 10 | 24 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 11 | 25 | |
| 12 | 26 | import java.util.ArrayList; |
| 27 | +import java.util.Collections; | |
| 13 | 28 | import java.util.List; |
| 14 | 29 | |
| 15 | -public class SelectIMFriendView implements MvpView { | |
| 30 | +public class SelectIMFriendView implements MvpView, LetterBarView.OnLetterSelectListener { | |
| 16 | 31 | private SelectIMFriendFragment fragment; |
| 17 | 32 | private SelectIMFriendAdapter adapter; |
| 18 | 33 | private List<IMFriendNoLetterInfo> noLetterInfoList; |
| 19 | - | |
| 20 | 34 | private List<IMFriendHasLetterInfo> imFriendInfoList; |
| 35 | + private LinearLayoutManager linearLayoutManager; | |
| 36 | + private String TAG = "SelectIMFriendView"; | |
| 37 | + private boolean isFirst = true; | |
| 21 | 38 | |
| 22 | 39 | public SelectIMFriendView(SelectIMFriendFragment fragment) { |
| 23 | 40 | this.fragment = fragment; |
| ... | ... | @@ -28,49 +45,83 @@ public class SelectIMFriendView implements MvpView { |
| 28 | 45 | } |
| 29 | 46 | |
| 30 | 47 | public void initView() { |
| 48 | + //设置按钮不可点击 | |
| 49 | + nextBtnCanNotClick(); | |
| 31 | 50 | //假设这个是原有数据 |
| 32 | 51 | noLetterInfoList = new ArrayList<>(); |
| 33 | 52 | IMFriendNoLetterInfo noLetterInfo = new IMFriendNoLetterInfo(); |
| 34 | 53 | noLetterInfo.setUserName("韩亚云"); |
| 35 | - noLetterInfo.setSelect(true); | |
| 36 | - noLetterInfo.setId("123"); | |
| 54 | + noLetterInfo.setCantSelect(true); | |
| 55 | + noLetterInfo.setId("352660"); | |
| 37 | 56 | noLetterInfoList.add(noLetterInfo); |
| 38 | 57 | |
| 39 | 58 | noLetterInfo = new IMFriendNoLetterInfo(); |
| 40 | 59 | noLetterInfo.setUserName("杨帅"); |
| 41 | - noLetterInfo.setSelect(false); | |
| 42 | - noLetterInfo.setId("12345"); | |
| 60 | + noLetterInfo.setId("352668"); | |
| 43 | 61 | noLetterInfoList.add(noLetterInfo); |
| 44 | 62 | |
| 45 | 63 | noLetterInfo = new IMFriendNoLetterInfo(); |
| 46 | 64 | noLetterInfo.setUserName("杨杨"); |
| 47 | - noLetterInfo.setSelect(false); | |
| 48 | - noLetterInfo.setId("12345"); | |
| 65 | + noLetterInfo.setId("352700"); | |
| 49 | 66 | noLetterInfoList.add(noLetterInfo); |
| 50 | 67 | |
| 51 | 68 | noLetterInfo = new IMFriendNoLetterInfo(); |
| 52 | 69 | noLetterInfo.setUserName("杨天"); |
| 53 | - noLetterInfo.setSelect(false); | |
| 54 | - noLetterInfo.setId("12345"); | |
| 70 | + noLetterInfo.setId("352782"); | |
| 55 | 71 | noLetterInfoList.add(noLetterInfo); |
| 56 | 72 | |
| 57 | 73 | noLetterInfo = new IMFriendNoLetterInfo(); |
| 58 | 74 | noLetterInfo.setUserName("郭瑞鹏"); |
| 59 | - noLetterInfo.setSelect(false); | |
| 60 | - noLetterInfo.setId("123456"); | |
| 75 | + noLetterInfo.setId("352898"); | |
| 61 | 76 | noLetterInfoList.add(noLetterInfo); |
| 62 | 77 | |
| 63 | 78 | noLetterInfo = new IMFriendNoLetterInfo(); |
| 64 | 79 | noLetterInfo.setUserName("殷巧娟"); |
| 65 | - noLetterInfo.setSelect(false); | |
| 66 | - noLetterInfo.setId("1234567"); | |
| 80 | + noLetterInfo.setId("353001"); | |
| 67 | 81 | noLetterInfoList.add(noLetterInfo); |
| 68 | 82 | |
| 69 | 83 | noLetterInfo = new IMFriendNoLetterInfo(); |
| 70 | 84 | noLetterInfo.setUserName("张晓文"); |
| 71 | - noLetterInfo.setSelect(false); | |
| 72 | - noLetterInfo.setId("12345"); | |
| 85 | + noLetterInfo.setId("353036"); | |
| 86 | + noLetterInfoList.add(noLetterInfo); | |
| 87 | + | |
| 88 | + | |
| 89 | + noLetterInfo = new IMFriendNoLetterInfo(); | |
| 90 | + noLetterInfo.setUserName("小明"); | |
| 91 | + noLetterInfo.setId("353360"); | |
| 92 | + noLetterInfoList.add(noLetterInfo); | |
| 93 | + | |
| 94 | + noLetterInfo = new IMFriendNoLetterInfo(); | |
| 95 | + noLetterInfo.setUserName("小红"); | |
| 96 | + noLetterInfo.setId("353417"); | |
| 97 | + noLetterInfoList.add(noLetterInfo); | |
| 98 | + | |
| 99 | + noLetterInfo = new IMFriendNoLetterInfo(); | |
| 100 | + noLetterInfo.setUserName("小绿"); | |
| 101 | + noLetterInfo.setId("353557"); | |
| 102 | + noLetterInfoList.add(noLetterInfo); | |
| 103 | + | |
| 104 | + noLetterInfo = new IMFriendNoLetterInfo(); | |
| 105 | + noLetterInfo.setUserName("小黄"); | |
| 106 | + noLetterInfo.setId("353651"); | |
| 107 | + noLetterInfoList.add(noLetterInfo); | |
| 108 | + | |
| 109 | + noLetterInfo = new IMFriendNoLetterInfo(); | |
| 110 | + noLetterInfo.setUserName("张三"); | |
| 111 | + noLetterInfo.setId("353728"); | |
| 112 | + noLetterInfoList.add(noLetterInfo); | |
| 113 | + | |
| 114 | + noLetterInfo = new IMFriendNoLetterInfo(); | |
| 115 | + noLetterInfo.setUserName("李四"); | |
| 116 | + noLetterInfo.setId("353777"); | |
| 117 | + noLetterInfoList.add(noLetterInfo); | |
| 118 | + | |
| 119 | + noLetterInfo = new IMFriendNoLetterInfo(); | |
| 120 | + noLetterInfo.setUserName("王五"); | |
| 121 | + noLetterInfo.setId("353789"); | |
| 73 | 122 | noLetterInfoList.add(noLetterInfo); |
| 123 | + //对数据进行排序 | |
| 124 | + Collections.sort(noLetterInfoList, new LetterComparator()); | |
| 74 | 125 | |
| 75 | 126 | //开始循环遍历索引 |
| 76 | 127 | String lastIndexStr = ""; |
| ... | ... | @@ -93,7 +144,7 @@ public class SelectIMFriendView implements MvpView { |
| 93 | 144 | hasLetterInfo = new IMFriendHasLetterInfo(); |
| 94 | 145 | hasLetterInfo.setId(noLetterInfoList.get(i).getId()); |
| 95 | 146 | hasLetterInfo.setType(IMFriendHasLetterInfo.USER_INFO); |
| 96 | - hasLetterInfo.setSelect(noLetterInfoList.get(i).isSelect()); | |
| 147 | + hasLetterInfo.setCantSelect(noLetterInfoList.get(i).isCantSelect()); | |
| 97 | 148 | hasLetterInfo.setUserIcon(noLetterInfoList.get(i).getUserIcon()); |
| 98 | 149 | hasLetterInfo.setUserName(noLetterInfoList.get(i).getUserName()); |
| 99 | 150 | imFriendInfoList.add(hasLetterInfo); |
| ... | ... | @@ -107,8 +158,133 @@ public class SelectIMFriendView implements MvpView { |
| 107 | 158 | } |
| 108 | 159 | } |
| 109 | 160 | adapter = new SelectIMFriendAdapter(getContext(), imFriendInfoList); |
| 110 | - fragment.binding.rvFriends.setLayoutManager(new LinearLayoutManager(getContext())); | |
| 161 | + linearLayoutManager = new LinearLayoutManager(getContext()); | |
| 162 | + fragment.binding.rvFriends.setLayoutManager(linearLayoutManager); | |
| 111 | 163 | fragment.binding.rvFriends.setAdapter(adapter); |
| 164 | + //设置选中状态监听 | |
| 165 | + adapter.setOnItemCheckBoxListener(new SelectIMFriendAdapter.OnItemCheckBoxListener() { | |
| 166 | + @Override | |
| 167 | + public void itemCheckCount(int count) { | |
| 168 | + if (count != 0) { | |
| 169 | + fragment.binding.btnNext.setText("下一步(" + count + ")"); | |
| 170 | + nextBtnCanClick(); | |
| 171 | + } else { | |
| 172 | + fragment.binding.btnNext.setText("下一步"); | |
| 173 | + nextBtnCanNotClick(); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + }); | |
| 177 | + //设置索引滑动监听 | |
| 178 | + fragment.binding.letterBarView.setOnLetterSelectListener(this); | |
| 179 | + //搜索框点击事件 | |
| 180 | + fragment.binding.etQuery.setOnClickListener(new View.OnClickListener() { | |
| 181 | + @Override | |
| 182 | + public void onClick(View view) { | |
| 183 | + fragment.binding.etQuery.setFocusable(true);//设置获取焦点可以编辑 | |
| 184 | + fragment.binding.etQuery.setFocusableInTouchMode(true); | |
| 185 | + fragment.binding.etQuery.requestFocus();//重新请求焦点 | |
| 186 | + if (isFirst) { | |
| 187 | + //强制调用键盘 | |
| 188 | + InputMethodManager inputMethodManager = | |
| 189 | + (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
| 190 | + if (getContext().getWindow().getAttributes().softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) { | |
| 191 | + inputMethodManager.toggleSoftInput(0, InputMethodManager.SHOW_FORCED); | |
| 192 | + } | |
| 193 | + isFirst = false; | |
| 194 | + } | |
| 195 | + } | |
| 196 | + }); | |
| 197 | + fragment.binding.etQuery.addTextChangedListener(new TextWatcher() { | |
| 198 | + @Override | |
| 199 | + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { | |
| 200 | + | |
| 201 | + } | |
| 202 | + | |
| 203 | + @Override | |
| 204 | + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { | |
| 205 | + if (null != adapter) { | |
| 206 | + if (charSequence.toString().trim().length() > 0) { | |
| 207 | + fragment.binding.ivDelete.setVisibility(View.VISIBLE); | |
| 208 | + List<IMFriendHasLetterInfo> list = new ArrayList<>(); | |
| 209 | + for (int t = 0; t < imFriendInfoList.size(); t++) { | |
| 210 | + if (imFriendInfoList.get(t).getType() != IMFriendHasLetterInfo.LETTER_INDEX) { | |
| 211 | + if (imFriendInfoList.get(t).getUserName().indexOf(charSequence.toString()) != -1) { | |
| 212 | + Log.e(TAG, "onTextChanged: " + imFriendInfoList.get(t).getUserName()); | |
| 213 | + list.add(imFriendInfoList.get(t)); | |
| 214 | + } | |
| 215 | + } | |
| 216 | + } | |
| 217 | + adapter.searchItems(list); | |
| 218 | + } else { | |
| 219 | + fragment.binding.ivDelete.setVisibility(View.GONE); | |
| 220 | + adapter.resetItems(); | |
| 221 | + } | |
| 222 | + } | |
| 223 | + } | |
| 224 | + | |
| 225 | + @Override | |
| 226 | + public void afterTextChanged(Editable editable) { | |
| 227 | + | |
| 228 | + } | |
| 229 | + }); | |
| 230 | + | |
| 231 | + //删除 | |
| 232 | + fragment.binding.ivDelete.setOnClickListener(new View.OnClickListener() { | |
| 233 | + @Override | |
| 234 | + public void onClick(View view) { | |
| 235 | + fragment.binding.etQuery.setText(""); | |
| 236 | + if (null != adapter) { | |
| 237 | + adapter.resetItems(); | |
| 238 | + } | |
| 239 | + } | |
| 240 | + }); | |
| 241 | + //下一步按钮 | |
| 242 | + fragment.binding.btnNext.setOnClickListener(new View.OnClickListener() { | |
| 243 | + @Override | |
| 244 | + public void onClick(View view) { | |
| 245 | + //获取选择的uid | |
| 246 | + if (null!=adapter){ | |
| 247 | + String selectUids=adapter.getSelectUid(); | |
| 248 | + SetFriendsRoleActivity.startActivity(getContext(),selectUids); | |
| 112 | 249 | |
| 250 | + } | |
| 251 | + } | |
| 252 | + }); | |
| 253 | + } | |
| 254 | + | |
| 255 | + /** | |
| 256 | + * 下一步按钮可以点击 | |
| 257 | + */ | |
| 258 | + public void nextBtnCanClick() { | |
| 259 | + fragment.binding.btnNext.setEnabled(true); | |
| 260 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_btn_green)); | |
| 261 | + | |
| 262 | + } | |
| 263 | + | |
| 264 | + /** | |
| 265 | + * 下一步按钮可以点击 | |
| 266 | + */ | |
| 267 | + public void nextBtnCanNotClick() { | |
| 268 | + fragment.binding.btnNext.setEnabled(false); | |
| 269 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_btn_gray)); | |
| 270 | + } | |
| 271 | + | |
| 272 | + /** | |
| 273 | + * 点击索引 | |
| 274 | + * | |
| 275 | + * @param s | |
| 276 | + */ | |
| 277 | + @Override | |
| 278 | + public void onLetterSelect(String s) { | |
| 279 | + //滑动列表 | |
| 280 | + if (null != adapter && null != imFriendInfoList && !TextUtils.isEmpty(s) && null != linearLayoutManager) { | |
| 281 | + //获取指定列表 | |
| 282 | + if (null != adapter.getContactLetterGuideMap()) { | |
| 283 | + if (null != adapter.getContactLetterGuideMap().get(s)) { | |
| 284 | + linearLayoutManager.scrollToPositionWithOffset(adapter.getContactLetterGuideMap().get(s), 0); | |
| 285 | + } | |
| 286 | + | |
| 287 | + } | |
| 288 | + } | |
| 113 | 289 | } |
| 114 | 290 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SetFriendsRoleView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.support.v7.widget.GridLayoutManager; | |
| 5 | +import android.support.v7.widget.LinearLayoutManager; | |
| 6 | + | |
| 7 | +import com.cnlive.strike.xiaojiaspeaker.R; | |
| 8 | +import com.cnlive.strike.xiaojiaspeaker.model.RoleInfo; | |
| 9 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | |
| 10 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.SetRoleAdapter; | |
| 11 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.SetFriendsRoleFragment; | |
| 12 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 13 | + | |
| 14 | +import java.util.ArrayList; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +public class SetFriendsRoleView implements MvpView { | |
| 18 | + private SetFriendsRoleFragment fragment; | |
| 19 | + private List<RoleInfo> roleInfoList; | |
| 20 | + private SetRoleAdapter adapter; | |
| 21 | + | |
| 22 | + public SetFriendsRoleView(SetFriendsRoleFragment fragment) { | |
| 23 | + this.fragment = fragment; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public Activity getContext() { | |
| 27 | + return fragment == null ? null : fragment.getActivity(); | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void initView(RoleNetBean roleNetBean) { | |
| 31 | + roleInfoList = new ArrayList<>(); | |
| 32 | + //整理数据 | |
| 33 | + //获取选中的联系人 | |
| 34 | + if (null != roleNetBean.getRoleUserList()) { | |
| 35 | + RoleInfo roleInfo = null; | |
| 36 | + for (int i = 0; i < roleNetBean.getRoleUserList().size(); i++) { | |
| 37 | + roleInfo = new RoleInfo(); | |
| 38 | + roleInfo.setUid(roleNetBean.getRoleUserList().get(i).getSid()); | |
| 39 | + roleInfo.setUserName(roleNetBean.getRoleUserList().get(i).getNick()); | |
| 40 | + roleInfo.setUserIcon(roleNetBean.getRoleUserList().get(i).getFace()); | |
| 41 | + List<RoleNetBean.RoleListBean> roleList = new ArrayList<>(); | |
| 42 | + for (int j = 0; j < roleNetBean.getRoleList().size(); j++) { | |
| 43 | + RoleNetBean.RoleListBean bean = new RoleNetBean.RoleListBean(); | |
| 44 | + bean.setAllowUse(roleNetBean.getRoleList().get(j).isAllowUse()); | |
| 45 | + bean.setId(roleNetBean.getRoleList().get(j).getId()); | |
| 46 | + bean.setRoleName(roleNetBean.getRoleList().get(j).getRoleName()); | |
| 47 | + bean.setSelectList(new ArrayList<>()); | |
| 48 | + roleList.add(bean); | |
| 49 | + } | |
| 50 | + roleInfo.setRoleList(roleList); | |
| 51 | + roleInfoList.add(roleInfo); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + //设置适配器 | |
| 55 | + adapter = new SetRoleAdapter(getContext(), roleInfoList); | |
| 56 | + fragment.binding.rvFriendsRole.setLayoutManager(new LinearLayoutManager(getContext())); | |
| 57 | + fragment.binding.rvFriendsRole.setAdapter(adapter); | |
| 58 | + } | |
| 59 | +} | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/model/IMFriendHasLetterInfo.java
| ... | ... | @@ -18,9 +18,17 @@ public class IMFriendHasLetterInfo { |
| 18 | 18 | private String Id; |
| 19 | 19 | private String userIcon; |
| 20 | 20 | private String userName; |
| 21 | - private boolean isSelect; | |
| 21 | + private boolean CantSelect;//可以选择 | |
| 22 | 22 | private String letter; |
| 23 | 23 | |
| 24 | + public boolean isCantSelect() { | |
| 25 | + return CantSelect; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setCantSelect(boolean cantSelect) { | |
| 29 | + CantSelect = cantSelect; | |
| 30 | + } | |
| 31 | + | |
| 24 | 32 | public void setLetter(String letter) { |
| 25 | 33 | this.letter = letter; |
| 26 | 34 | } |
| ... | ... | @@ -49,6 +57,9 @@ public class IMFriendHasLetterInfo { |
| 49 | 57 | this.letter = SearchUtil.isAllEnglish(pinYin.substring(0, 1)) ? pinYin : "#"; |
| 50 | 58 | } |
| 51 | 59 | } |
| 60 | + if (this.letter.length() >= 2) { | |
| 61 | + this.letter = this.letter.substring(0, 1); | |
| 62 | + } | |
| 52 | 63 | } |
| 53 | 64 | |
| 54 | 65 | public String getId() { |
| ... | ... | @@ -76,11 +87,4 @@ public class IMFriendHasLetterInfo { |
| 76 | 87 | setLetterContent(userName); |
| 77 | 88 | } |
| 78 | 89 | |
| 79 | - public boolean isSelect() { | |
| 80 | - return isSelect; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public void setSelect(boolean select) { | |
| 84 | - isSelect = select; | |
| 85 | - } | |
| 86 | 90 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/model/IMFriendNoLetterInfo.java
| ... | ... | @@ -15,7 +15,7 @@ public class IMFriendNoLetterInfo { |
| 15 | 15 | private String Id; |
| 16 | 16 | private String userIcon; |
| 17 | 17 | private String userName; |
| 18 | - private boolean isSelect; | |
| 18 | + private boolean isCantSelect; | |
| 19 | 19 | private String letter; |
| 20 | 20 | |
| 21 | 21 | public int getType() { |
| ... | ... | @@ -42,6 +42,9 @@ public class IMFriendNoLetterInfo { |
| 42 | 42 | this.letter = SearchUtil.isAllEnglish(pinYin.substring(0, 1)) ? pinYin : "#"; |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | + if (this.letter.length() >= 2) { | |
| 46 | + this.letter = this.letter.substring(0, 1); | |
| 47 | + } | |
| 45 | 48 | } |
| 46 | 49 | |
| 47 | 50 | public String getId() { |
| ... | ... | @@ -69,11 +72,11 @@ public class IMFriendNoLetterInfo { |
| 69 | 72 | setLetterContent(userName); |
| 70 | 73 | } |
| 71 | 74 | |
| 72 | - public boolean isSelect() { | |
| 73 | - return isSelect; | |
| 75 | + public boolean isCantSelect() { | |
| 76 | + return isCantSelect; | |
| 74 | 77 | } |
| 75 | 78 | |
| 76 | - public void setSelect(boolean select) { | |
| 77 | - isSelect = select; | |
| 79 | + public void setCantSelect(boolean cantSelect) { | |
| 80 | + isCantSelect = cantSelect; | |
| 78 | 81 | } |
| 79 | 82 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/model/LetterComparator.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.model; | |
| 2 | + | |
| 3 | +import android.support.annotation.IntRange; | |
| 4 | +import android.support.annotation.NonNull; | |
| 5 | + | |
| 6 | + | |
| 7 | +import java.util.Comparator; | |
| 8 | + | |
| 9 | +public class LetterComparator implements Comparator<IMFriendNoLetterInfo> { | |
| 10 | + @Override | |
| 11 | + @IntRange(from = -1, to = 1) | |
| 12 | + public int compare(@NonNull IMFriendNoLetterInfo lObj, @NonNull IMFriendNoLetterInfo rObj) { | |
| 13 | + try { | |
| 14 | + if ("#".equals(lObj.getLetter()) && "#".equals(rObj.getLetter())) { | |
| 15 | + return 0; | |
| 16 | + } else if ("#".equals(lObj.getLetter())) { | |
| 17 | + return 1; | |
| 18 | + } else if ("#".equals(rObj.getLetter())) { | |
| 19 | + return -1; | |
| 20 | + } else { | |
| 21 | + return lObj.getLetter().compareTo(rObj.getLetter()); | |
| 22 | + } | |
| 23 | + } catch (Exception e) { | |
| 24 | + return 0; | |
| 25 | + } | |
| 26 | + } | |
| 27 | +} | |
| 0 | 28 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/model/RoleInfo.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.model; | |
| 2 | + | |
| 3 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | |
| 4 | + | |
| 5 | +import java.util.List; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 角色信息 | |
| 9 | + */ | |
| 10 | +public class RoleInfo { | |
| 11 | + private String uid; | |
| 12 | + private String userIcon; | |
| 13 | + private String userName; | |
| 14 | + private List<RoleNetBean.RoleListBean> roleList; | |
| 15 | + | |
| 16 | + public List<RoleNetBean.RoleListBean> getRoleList() { | |
| 17 | + return roleList; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setRoleList(List<RoleNetBean.RoleListBean> roleList) { | |
| 21 | + this.roleList = roleList; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getUid() { | |
| 25 | + return uid; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setUid(String uid) { | |
| 29 | + this.uid = uid; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public String getUserIcon() { | |
| 33 | + return userIcon; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setUserIcon(String userIcon) { | |
| 37 | + this.userIcon = userIcon; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public String getUserName() { | |
| 41 | + return userName; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setUserName(String userName) { | |
| 45 | + this.userName = userName; | |
| 46 | + } | |
| 47 | +} | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/netWork/ApiServiceXiaoJia.java
| ... | ... | @@ -3,6 +3,7 @@ package com.cnlive.strike.xiaojiaspeaker.netWork; |
| 3 | 3 | |
| 4 | 4 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyListBean; |
| 5 | 5 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.NetworkResultBean; |
| 6 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | |
| 6 | 7 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.SubscriptionBaseInfo; |
| 7 | 8 | |
| 8 | 9 | import java.util.Map; |
| ... | ... | @@ -16,6 +17,8 @@ import retrofit2.http.QueryMap; |
| 16 | 17 | * 小家音响的接口 |
| 17 | 18 | */ |
| 18 | 19 | public interface ApiServiceXiaoJia { |
| 20 | + @POST("Daren/sound/getSetRoleList.action") | |
| 21 | + Observable<Result<SubscriptionBaseInfo<RoleNetBean>>> getSetRoleList(@QueryMap() Map<String, String> maps); | |
| 19 | 22 | /** |
| 20 | 23 | * 获取家庭id |
| 21 | 24 | * sid Integer true sid | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/netWork/bean/RoleNetBean.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.netWork.bean; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 设置角色 | |
| 7 | + */ | |
| 8 | +public class RoleNetBean { | |
| 9 | + private List<RoleListBean> roleList; | |
| 10 | + private List<RoleUserListBean> roleUserList; | |
| 11 | + | |
| 12 | + public List<RoleListBean> getRoleList() { | |
| 13 | + return roleList; | |
| 14 | + } | |
| 15 | + | |
| 16 | + public void setRoleList(List<RoleListBean> roleList) { | |
| 17 | + this.roleList = roleList; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public List<RoleUserListBean> getRoleUserList() { | |
| 21 | + return roleUserList; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public void setRoleUserList(List<RoleUserListBean> roleUserList) { | |
| 25 | + this.roleUserList = roleUserList; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public static class RoleListBean { | |
| 29 | + /** | |
| 30 | + * allowUse : false | |
| 31 | + * id : 3 | |
| 32 | + * roleName : 爷爷 | |
| 33 | + */ | |
| 34 | + | |
| 35 | + private boolean allowUse; | |
| 36 | + private int id; | |
| 37 | + private String roleName; | |
| 38 | + private List<String> selectList; | |
| 39 | + | |
| 40 | + public List<String> getSelectList() { | |
| 41 | + return selectList; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setSelectList(List<String> selectList) { | |
| 45 | + this.selectList = selectList; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public boolean isAllowUse() { | |
| 49 | + return allowUse; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setAllowUse(boolean allowUse) { | |
| 53 | + this.allowUse = allowUse; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public int getId() { | |
| 57 | + return id; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setId(int id) { | |
| 61 | + this.id = id; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public String getRoleName() { | |
| 65 | + return roleName; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setRoleName(String roleName) { | |
| 69 | + this.roleName = roleName; | |
| 70 | + } | |
| 71 | + } | |
| 72 | + | |
| 73 | + public static class RoleUserListBean { | |
| 74 | + /** | |
| 75 | + * face : http://wjj.ys1.cnliveimg.com/769/img/2018/0416/head_c.png | |
| 76 | + * nick : 云测441 | |
| 77 | + * sid : 389271 | |
| 78 | + */ | |
| 79 | + | |
| 80 | + private String face; | |
| 81 | + private String nick; | |
| 82 | + private String sid; | |
| 83 | + | |
| 84 | + public String getFace() { | |
| 85 | + return face; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public void setFace(String face) { | |
| 89 | + this.face = face; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public String getNick() { | |
| 93 | + return nick; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void setNick(String nick) { | |
| 97 | + this.nick = nick; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public String getSid() { | |
| 101 | + return sid; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public void setSid(String sid) { | |
| 105 | + this.sid = sid; | |
| 106 | + } | |
| 107 | + } | |
| 108 | +} | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/activity/SetFriendsRoleActivity.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.ui.activity; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.support.v7.app.AppCompatActivity; | |
| 6 | +import android.os.Bundle; | |
| 7 | + | |
| 8 | +import com.cnlive.strike.xiaojiaspeaker.R; | |
| 9 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.SelectWifiFragment; | |
| 10 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.SetFriendsRoleFragment; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 设置用户角色 | |
| 14 | + */ | |
| 15 | +public class SetFriendsRoleActivity extends AppCompatActivity { | |
| 16 | + | |
| 17 | + @Override | |
| 18 | + protected void onCreate(Bundle savedInstanceState) { | |
| 19 | + super.onCreate(savedInstanceState); | |
| 20 | + setContentView(R.layout.activity_set_friends_role); | |
| 21 | + if (null != getIntent().getExtras()) { | |
| 22 | + String selectUid = getIntent().getExtras().getString("selectUid"); | |
| 23 | + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, SetFriendsRoleFragment.newInstance(selectUid)).commitAllowingStateLoss(); | |
| 24 | + } else { | |
| 25 | + finish(); | |
| 26 | + } | |
| 27 | + | |
| 28 | + } | |
| 29 | + | |
| 30 | + public static void startActivity(Activity activity, String selectUid) { | |
| 31 | + Intent intent = new Intent(activity, SetFriendsRoleActivity.class); | |
| 32 | + intent.putExtra("selectUid", selectUid); | |
| 33 | + activity.startActivity(intent); | |
| 34 | + } | |
| 35 | +} | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/AllRoleDetailAdapter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.ui.adapter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.support.annotation.NonNull; | |
| 6 | +import android.support.v7.widget.RecyclerView; | |
| 7 | +import android.util.Log; | |
| 8 | +import android.view.LayoutInflater; | |
| 9 | +import android.view.View; | |
| 10 | +import android.view.ViewGroup; | |
| 11 | + | |
| 12 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 13 | +import com.cnlive.strike.xiaojiaspeaker.R; | |
| 14 | +import com.cnlive.strike.xiaojiaspeaker.databinding.ItemListSetRoleCheckBoxBinding; | |
| 15 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | |
| 16 | +import com.cnlive.strike.xiaojiaspeaker.util.utilcode.util.GsonUtils; | |
| 17 | + | |
| 18 | +import java.util.ArrayList; | |
| 19 | +import java.util.HashMap; | |
| 20 | +import java.util.List; | |
| 21 | +import java.util.Map; | |
| 22 | + | |
| 23 | +public class AllRoleDetailAdapter extends RecyclerView.Adapter { | |
| 24 | + private Context context; | |
| 25 | + private List<RoleNetBean.RoleListBean> allRoleList; | |
| 26 | + private SetRoleAdapter setRoleAdapter; | |
| 27 | + private Map<String, Boolean> allowSelectMap; | |
| 28 | + private String TAG = "AllRoleDetailAdapter"; | |
| 29 | + | |
| 30 | + public AllRoleDetailAdapter(Context context, List<RoleNetBean.RoleListBean> allRoleList, SetRoleAdapter setRoleAdapter) { | |
| 31 | + this.context = context; | |
| 32 | + this.allRoleList = allRoleList; | |
| 33 | + this.setRoleAdapter = setRoleAdapter; | |
| 34 | + this.allowSelectMap = setRoleAdapter.getAllowSelectMap(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @NonNull | |
| 38 | + @Override | |
| 39 | + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { | |
| 40 | + LayoutInflater inflater = LayoutInflater.from(context); | |
| 41 | + ItemListSetRoleCheckBoxBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_list_set_role_check_box, viewGroup, false); | |
| 42 | + return new MyViewHolder(binding); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { | |
| 47 | + ItemListSetRoleCheckBoxBinding binding = ((MyViewHolder) viewHolder).getBinding(); | |
| 48 | + //设置名称 | |
| 49 | + binding.checkBox.setText(allRoleList.get(position).getRoleName()); | |
| 50 | + //设置不可选中的 | |
| 51 | + if (null != allRoleList.get(position).getSelectList()) { | |
| 52 | + if (allRoleList.get(position).getSelectList().contains(allRoleList.get(position).getId() + "")) { | |
| 53 | + binding.checkBox.setChecked(true); | |
| 54 | + } else { | |
| 55 | + binding.checkBox.setChecked(false); | |
| 56 | + } | |
| 57 | + } else { | |
| 58 | + binding.checkBox.setChecked(false); | |
| 59 | + } | |
| 60 | + //设置默认选中的 | |
| 61 | + if (!binding.checkBox.isChecked()) { | |
| 62 | + if (!setRoleAdapter.getAllowSelectMap().get(allRoleList.get(position).getId() + "")) { | |
| 63 | + binding.checkBox.setEnabled(false); | |
| 64 | + } else { | |
| 65 | + binding.checkBox.setEnabled(true); | |
| 66 | + } | |
| 67 | + } | |
| 68 | + } | |
| 69 | + | |
| 70 | + @Override | |
| 71 | + public int getItemCount() { | |
| 72 | + return allRoleList.size(); | |
| 73 | + } | |
| 74 | + | |
| 75 | + private class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { | |
| 76 | + public ItemListSetRoleCheckBoxBinding getBinding() { | |
| 77 | + return binding; | |
| 78 | + } | |
| 79 | + | |
| 80 | + private ItemListSetRoleCheckBoxBinding binding; | |
| 81 | + | |
| 82 | + public MyViewHolder(ItemListSetRoleCheckBoxBinding binding) { | |
| 83 | + super(binding.getRoot()); | |
| 84 | + this.binding = binding; | |
| 85 | + //item点击事件 | |
| 86 | + binding.llRoot.setOnClickListener(this); | |
| 87 | + } | |
| 88 | + | |
| 89 | + @Override | |
| 90 | + public void onClick(View view) { | |
| 91 | + if (view.getId() == R.id.ll_root) { | |
| 92 | + int position = getAdapterPosition(); | |
| 93 | + List<String> selectList = allRoleList.get(position).getSelectList(); | |
| 94 | + String currentRoleId = allRoleList.get(position).getId() + ""; | |
| 95 | + //先判断是否是后台初始传过来的 | |
| 96 | + if (setRoleAdapter.getInitNotAllowRoleId().contains(currentRoleId)) { | |
| 97 | + AlertUtil.showDeftToast(context, "该角色已占用!"); | |
| 98 | + return; | |
| 99 | + } | |
| 100 | + //判断点击这个东西在不在已存储的集合中 | |
| 101 | + if (!allowSelectMap.get(currentRoleId)) { | |
| 102 | + if (!selectList.contains(currentRoleId)) { | |
| 103 | + AlertUtil.showDeftToast(context, "该角色已占用!"); | |
| 104 | + return; | |
| 105 | + } | |
| 106 | + } | |
| 107 | + binding.checkBox.toggle(); | |
| 108 | + //开始设置全局状态 | |
| 109 | + if (binding.checkBox.isChecked()) { | |
| 110 | + //添加到选中的集合 | |
| 111 | + if (!selectList.contains(currentRoleId)) { | |
| 112 | + selectList.add(currentRoleId); | |
| 113 | + } | |
| 114 | + } else { | |
| 115 | + if (selectList.contains(currentRoleId)) { | |
| 116 | + selectList.remove(currentRoleId); | |
| 117 | + } | |
| 118 | + } | |
| 119 | + //设置全局不允许选择 | |
| 120 | + allowSelectMap.put(currentRoleId, !binding.checkBox.isChecked()); | |
| 121 | + setRoleAdapter.notifyDataSetChanged(); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + } | |
| 125 | + | |
| 126 | + public interface onAllRoleClickListener { | |
| 127 | + void onClick(int position); | |
| 128 | + } | |
| 129 | +} | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/SelectIMFriendAdapter.java
| ... | ... | @@ -4,15 +4,19 @@ import android.content.Context; |
| 4 | 4 | import android.databinding.DataBindingUtil; |
| 5 | 5 | import android.support.annotation.NonNull; |
| 6 | 6 | import android.support.v7.widget.RecyclerView; |
| 7 | +import android.text.TextUtils; | |
| 7 | 8 | import android.view.LayoutInflater; |
| 9 | +import android.view.View; | |
| 8 | 10 | import android.view.ViewGroup; |
| 9 | 11 | |
| 12 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 10 | 13 | import com.cnlive.strike.application.GlideApp; |
| 11 | 14 | import com.cnlive.strike.xiaojiaspeaker.R; |
| 12 | 15 | import com.cnlive.strike.xiaojiaspeaker.databinding.ItemListContactLetterGuideBinding; |
| 13 | 16 | import com.cnlive.strike.xiaojiaspeaker.databinding.ItemListSelectImContactBinding; |
| 14 | 17 | import com.cnlive.strike.xiaojiaspeaker.model.IMFriendHasLetterInfo; |
| 15 | 18 | |
| 19 | +import java.util.ArrayList; | |
| 16 | 20 | import java.util.HashMap; |
| 17 | 21 | import java.util.List; |
| 18 | 22 | |
| ... | ... | @@ -20,20 +24,64 @@ public class SelectIMFriendAdapter extends RecyclerView.Adapter { |
| 20 | 24 | private Context context; |
| 21 | 25 | private List<IMFriendHasLetterInfo> imFriendInfoList; |
| 22 | 26 | private HashMap<String, Boolean> hasSelectMap; |
| 27 | + //存储字母在列表中的位置 | |
| 28 | + private HashMap<String, Integer> contactLetterGuideMap; | |
| 29 | + private List<IMFriendHasLetterInfo> rawDataList; | |
| 30 | + private OnItemCheckBoxListener onItemCheckBoxListener; | |
| 31 | + private final int MAX_FRIENDS = 10;//最多10个人 | |
| 32 | + private String TAG = "SelectIMFriendAdapter"; | |
| 33 | + | |
| 34 | + public void setOnItemCheckBoxListener(OnItemCheckBoxListener onItemCheckBoxListener) { | |
| 35 | + this.onItemCheckBoxListener = onItemCheckBoxListener; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public String getSelectUid() { | |
| 39 | + String uids = ""; | |
| 40 | + if (null != hasSelectMap && null != rawDataList) { | |
| 41 | + for (int i = 0; i < rawDataList.size(); i++) { | |
| 42 | + if (hasSelectMap.get(rawDataList.get(i).getId())) { | |
| 43 | + uids += rawDataList.get(i).getId() + ","; | |
| 44 | + } | |
| 45 | + } | |
| 46 | + } | |
| 47 | + if (!TextUtils.isEmpty(uids)) { | |
| 48 | + uids = uids.substring(0, uids.length() - 1); | |
| 49 | + } | |
| 50 | + return uids; | |
| 51 | + } | |
| 23 | 52 | |
| 24 | 53 | public SelectIMFriendAdapter(Context context, List<IMFriendHasLetterInfo> imFriendInfoList) { |
| 25 | 54 | this.context = context; |
| 26 | 55 | this.imFriendInfoList = imFriendInfoList; |
| 56 | + rawDataList = new ArrayList<>(); | |
| 57 | + rawDataList.addAll(imFriendInfoList); | |
| 27 | 58 | hasSelectMap = new HashMap<>(); |
| 59 | + contactLetterGuideMap = new HashMap<>(); | |
| 28 | 60 | for (int i = 0; i < imFriendInfoList.size(); i++) { |
| 29 | - if (imFriendInfoList.get(i).isSelect()) { | |
| 30 | - hasSelectMap.put(imFriendInfoList.get(i).getId(), true); | |
| 31 | - } else { | |
| 32 | - hasSelectMap.put(imFriendInfoList.get(i).getId(), false); | |
| 61 | + hasSelectMap.put(imFriendInfoList.get(i).getId(), false); | |
| 62 | + //记录索引位置 | |
| 63 | + if (imFriendInfoList.get(i).getType() == IMFriendHasLetterInfo.LETTER_INDEX) { | |
| 64 | + contactLetterGuideMap.put(imFriendInfoList.get(i).getLetter(), i); | |
| 33 | 65 | } |
| 34 | 66 | } |
| 35 | 67 | } |
| 36 | 68 | |
| 69 | + public void searchItems(List<IMFriendHasLetterInfo> list) { | |
| 70 | + imFriendInfoList.clear(); | |
| 71 | + imFriendInfoList.addAll(list); | |
| 72 | + notifyDataSetChanged(); | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void resetItems() { | |
| 76 | + imFriendInfoList.clear(); | |
| 77 | + imFriendInfoList.addAll(rawDataList); | |
| 78 | + notifyDataSetChanged(); | |
| 79 | + } | |
| 80 | + | |
| 81 | + public HashMap<String, Integer> getContactLetterGuideMap() { | |
| 82 | + return contactLetterGuideMap; | |
| 83 | + } | |
| 84 | + | |
| 37 | 85 | @NonNull |
| 38 | 86 | @Override |
| 39 | 87 | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int type) { |
| ... | ... | @@ -55,17 +103,25 @@ public class SelectIMFriendAdapter extends RecyclerView.Adapter { |
| 55 | 103 | case IMFriendHasLetterInfo.USER_INFO: |
| 56 | 104 | ItemListSelectImContactBinding binding = ((MyViewHolder) viewHolder).getBinding(); |
| 57 | 105 | //设置联系人头像 |
| 58 | - GlideApp.with(context).load(imFriendInfoList.get(position).getUserIcon()).placeholder(R.drawable.touxiang_round).into(binding.ivIcon); | |
| 106 | + GlideApp.with(context).load(imFriendInfoList.get(position).getUserIcon()).placeholder(R.drawable.touxiang).into(binding.ivIcon); | |
| 59 | 107 | //设置联系人名称 |
| 60 | 108 | binding.tvName.setText(imFriendInfoList.get(position).getUserName()); |
| 61 | - //设置是否选中 | |
| 62 | - binding.checkBox.setChecked(imFriendInfoList.get(position).isSelect()); | |
| 109 | + //设置是否可以进行选择 | |
| 110 | + if (imFriendInfoList.get(position).isCantSelect()) { | |
| 111 | + binding.checkBox.setEnabled(false); | |
| 112 | + } else { | |
| 113 | + binding.checkBox.setEnabled(true); | |
| 114 | + } | |
| 115 | + //初始化选中状态 | |
| 116 | + if (hasSelectMap.get(imFriendInfoList.get(position).getId())) { | |
| 117 | + binding.checkBox.setChecked(true); | |
| 118 | + } else { | |
| 119 | + binding.checkBox.setChecked(false); | |
| 120 | + } | |
| 63 | 121 | break; |
| 64 | 122 | case IMFriendHasLetterInfo.LETTER_INDEX: |
| 65 | 123 | ItemListContactLetterGuideBinding letterGuideBinding = ((MyViewLetterHolder) viewHolder).getBinding(); |
| 66 | - if (imFriendInfoList.get(position).getLetter().length() >= 2) { | |
| 67 | - letterGuideBinding.tvLetter.setText(imFriendInfoList.get(position).getLetter().substring(0, 1)); | |
| 68 | - } | |
| 124 | + letterGuideBinding.tvLetter.setText(imFriendInfoList.get(position).getLetter()); | |
| 69 | 125 | break; |
| 70 | 126 | } |
| 71 | 127 | |
| ... | ... | @@ -81,7 +137,8 @@ public class SelectIMFriendAdapter extends RecyclerView.Adapter { |
| 81 | 137 | return imFriendInfoList.size(); |
| 82 | 138 | } |
| 83 | 139 | |
| 84 | - private class MyViewHolder extends RecyclerView.ViewHolder { | |
| 140 | + | |
| 141 | + private class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { | |
| 85 | 142 | public ItemListSelectImContactBinding getBinding() { |
| 86 | 143 | return binding; |
| 87 | 144 | } |
| ... | ... | @@ -91,7 +148,44 @@ public class SelectIMFriendAdapter extends RecyclerView.Adapter { |
| 91 | 148 | public MyViewHolder(ItemListSelectImContactBinding binding) { |
| 92 | 149 | super(binding.getRoot()); |
| 93 | 150 | this.binding = binding; |
| 151 | + //item点击事件 | |
| 152 | + binding.llRoot.setOnClickListener(this); | |
| 94 | 153 | } |
| 154 | + | |
| 155 | + @Override | |
| 156 | + public void onClick(View view) { | |
| 157 | + if (view.getId() == R.id.ll_root) { | |
| 158 | + //判断是否可以让用户点击 | |
| 159 | + if (!imFriendInfoList.get(getAdapterPosition()).isCantSelect()) { | |
| 160 | + //设置是否选中 | |
| 161 | + binding.checkBox.toggle(); | |
| 162 | + } else { | |
| 163 | + AlertUtil.showDeftToast(context, "该联系人不可选择"); | |
| 164 | + return; | |
| 165 | + } | |
| 166 | + hasSelectMap.put(imFriendInfoList.get(getAdapterPosition()).getId(), binding.checkBox.isChecked()); | |
| 167 | + int selectCount = 0; | |
| 168 | + //这里使用原数据进行检索操作,因为搜索与未搜索时,数据一直在变化 | |
| 169 | + for (IMFriendHasLetterInfo info : rawDataList) { | |
| 170 | + if (hasSelectMap.get(info.getId())) { | |
| 171 | + selectCount++; | |
| 172 | + } | |
| 173 | + } | |
| 174 | + if (binding.checkBox.isChecked()) { | |
| 175 | + if (selectCount > MAX_FRIENDS) { | |
| 176 | + AlertUtil.showDeftToast(context, "最多选" + MAX_FRIENDS + "个人"); | |
| 177 | + binding.checkBox.setChecked(false); | |
| 178 | + hasSelectMap.put(imFriendInfoList.get(getAdapterPosition()).getId(), binding.checkBox.isChecked()); | |
| 179 | + return; | |
| 180 | + } | |
| 181 | + } | |
| 182 | + //统计选中的按钮数量 | |
| 183 | + if (null != onItemCheckBoxListener) { | |
| 184 | + onItemCheckBoxListener.itemCheckCount(selectCount); | |
| 185 | + } | |
| 186 | + } | |
| 187 | + } | |
| 188 | + | |
| 95 | 189 | } |
| 96 | 190 | |
| 97 | 191 | private class MyViewLetterHolder extends RecyclerView.ViewHolder { |
| ... | ... | @@ -106,4 +200,79 @@ public class SelectIMFriendAdapter extends RecyclerView.Adapter { |
| 106 | 200 | this.binding = binding; |
| 107 | 201 | } |
| 108 | 202 | } |
| 203 | + | |
| 204 | + public interface OnItemCheckBoxListener { | |
| 205 | + void itemCheckCount(int count); | |
| 206 | + } | |
| 207 | + | |
| 208 | +// /** | |
| 209 | +// * 创建内部类MyFilter继承Filter类,并重写相关方法,实现数据的过滤 | |
| 210 | +// * | |
| 211 | +// * @author 邹奇 | |
| 212 | +// */ | |
| 213 | +// class MyFilter extends Filter { | |
| 214 | +// | |
| 215 | +// // 创建集合保存原始数据 | |
| 216 | +// List<IMFriendHasLetterInfo> completeDataList = new ArrayList<>(); | |
| 217 | +// | |
| 218 | +// public MyFilter(List<IMFriendHasLetterInfo> list) { | |
| 219 | +// this.completeDataList = list; | |
| 220 | +// } | |
| 221 | +// | |
| 222 | +// /** | |
| 223 | +// * 该方法返回搜索过滤后的数据 | |
| 224 | +// */ | |
| 225 | +// @Override | |
| 226 | +// protected FilterResults performFiltering(String constraint) { | |
| 227 | +// // 创建FilterResults对象 | |
| 228 | +// FilterResults results = new FilterResults(); | |
| 229 | +// | |
| 230 | +// /** | |
| 231 | +// * 没有搜索内容的话就还是给results赋值原始数据的值和大小 | |
| 232 | +// * 执行了搜索的话,根据搜索的规则过滤即可,最后把过滤后的数据的值和大小赋值给results | |
| 233 | +// * | |
| 234 | +// */ | |
| 235 | +// if (TextUtils.isEmpty(constraint)) { | |
| 236 | +// results.values = completeDataList; | |
| 237 | +// results.count = completeDataList.size(); | |
| 238 | +// } else { | |
| 239 | +// // 创建集合保存过滤后的数据 | |
| 240 | +// List<IMFriendHasLetterInfo> mList = new ArrayList<>(); | |
| 241 | +// // 遍历原始数据集合,根据搜索的规则过滤数据 | |
| 242 | +// for (IMFriendHasLetterInfo s : completeDataList) { | |
| 243 | +// if (s.getType()==IMFriendHasLetterInfo.LETTER_INDEX){ | |
| 244 | +// continue; | |
| 245 | +// } | |
| 246 | +// // 这里就是过滤规则的具体实现【规则有很多,大家可以自己决定怎么实现】 | |
| 247 | +// if (s.getUserName().indexOf(constraint)!=-1) { | |
| 248 | +// // 规则匹配的话就往集合中添加该数据 | |
| 249 | +// mList.add(s); | |
| 250 | +// } | |
| 251 | +// } | |
| 252 | +// results.values = mList; | |
| 253 | +// results.count = mList.size(); | |
| 254 | +// } | |
| 255 | +// | |
| 256 | +// // 返回FilterResults对象 | |
| 257 | +// return results; | |
| 258 | +// } | |
| 259 | +// | |
| 260 | +// /** | |
| 261 | +// * 该方法用来刷新用户界面,根据过滤后的数据重新展示列表 | |
| 262 | +// */ | |
| 263 | +// @Override | |
| 264 | +// protected void publishResults(CharSequence constraint, | |
| 265 | +// FilterResults results) { | |
| 266 | +// // 获取过滤后的数据 | |
| 267 | +// completeDataList = (List<String>) results.values; | |
| 268 | +// // 如果接口对象不为空,那么调用接口中的方法获取过滤后的数据,具体的实现在new这个接口的时候重写的方法里执行 | |
| 269 | +// if (listener != null) { | |
| 270 | +// listener.getFilterData(list); | |
| 271 | +// } | |
| 272 | +// // 刷新数据源显示 | |
| 273 | +// notifyDataSetChanged(); | |
| 274 | +// } | |
| 275 | +// | |
| 276 | +// } | |
| 277 | + | |
| 109 | 278 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/SetRoleAdapter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.ui.adapter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.support.annotation.NonNull; | |
| 6 | +import android.support.v7.widget.GridLayoutManager; | |
| 7 | +import android.support.v7.widget.RecyclerView; | |
| 8 | +import android.view.LayoutInflater; | |
| 9 | +import android.view.ViewGroup; | |
| 10 | + | |
| 11 | +import com.cnlive.strike.application.GlideApp; | |
| 12 | +import com.cnlive.strike.xiaojiaspeaker.R; | |
| 13 | +import com.cnlive.strike.xiaojiaspeaker.databinding.ItemListSetRoleBinding; | |
| 14 | +import com.cnlive.strike.xiaojiaspeaker.model.RoleInfo; | |
| 15 | + | |
| 16 | +import java.util.ArrayList; | |
| 17 | +import java.util.HashMap; | |
| 18 | +import java.util.List; | |
| 19 | +import java.util.Map; | |
| 20 | + | |
| 21 | +public class SetRoleAdapter extends RecyclerView.Adapter { | |
| 22 | + private Context context; | |
| 23 | + private List<RoleInfo> roleInfoList; | |
| 24 | + private Map<String, Boolean> allowSelectMap; | |
| 25 | + private AllRoleDetailAdapter adapter; | |
| 26 | + private List<Integer> initNotAllowRoleId;//服务器初始给的不允许点击的值 | |
| 27 | + | |
| 28 | + public Map<String, Boolean> getAllowSelectMap() { | |
| 29 | + return allowSelectMap; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public List<Integer> getInitNotAllowRoleId() { | |
| 33 | + return initNotAllowRoleId; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public SetRoleAdapter(Context context, List<RoleInfo> roleInfoList) { | |
| 37 | + this.context = context; | |
| 38 | + this.roleInfoList = roleInfoList; | |
| 39 | + this.allowSelectMap = new HashMap<>(); | |
| 40 | + initNotAllowRoleId = new ArrayList<>(); | |
| 41 | + for (int i = 0; i < roleInfoList.get(0).getRoleList().size(); i++) { | |
| 42 | + allowSelectMap.put(roleInfoList.get(0).getRoleList().get(i).getId() + "", roleInfoList.get(0).getRoleList().get(i).isAllowUse()); | |
| 43 | + if (!roleInfoList.get(0).getRoleList().get(i).isAllowUse()) { | |
| 44 | + initNotAllowRoleId.add(roleInfoList.get(0).getRoleList().get(i).getId()); | |
| 45 | + } | |
| 46 | + } | |
| 47 | + } | |
| 48 | + | |
| 49 | + @NonNull | |
| 50 | + @Override | |
| 51 | + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { | |
| 52 | + LayoutInflater inflater = LayoutInflater.from(context); | |
| 53 | + ItemListSetRoleBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_list_set_role, viewGroup, false); | |
| 54 | + return new MyViewHolder(binding); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { | |
| 59 | + ItemListSetRoleBinding binding = ((MyViewHolder) viewHolder).getBinding(); | |
| 60 | + binding.tvName.setText(roleInfoList.get(position).getUserName()); | |
| 61 | + GlideApp.with(context).load(roleInfoList.get(position).getUserIcon()).placeholder(R.drawable.touxiang).into(binding.ivIcon); | |
| 62 | + //设置适配器 | |
| 63 | + adapter = new AllRoleDetailAdapter(context, roleInfoList.get(position).getRoleList(), this); | |
| 64 | + binding.rvRoleList.setLayoutManager(new GridLayoutManager(context, 4)); | |
| 65 | + binding.rvRoleList.setAdapter(adapter); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + public int getItemCount() { | |
| 70 | + return roleInfoList.size(); | |
| 71 | + } | |
| 72 | + | |
| 73 | + private class MyViewHolder extends RecyclerView.ViewHolder { | |
| 74 | + public ItemListSetRoleBinding getBinding() { | |
| 75 | + return binding; | |
| 76 | + } | |
| 77 | + | |
| 78 | + private ItemListSetRoleBinding binding; | |
| 79 | + | |
| 80 | + public MyViewHolder(ItemListSetRoleBinding binding) { | |
| 81 | + super(binding.getRoot()); | |
| 82 | + this.binding = binding; | |
| 83 | + //item点击事件 | |
| 84 | + } | |
| 85 | + } | |
| 86 | +} | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/fragment/SetFriendsRoleFragment.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.ui.fragment; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.support.annotation.Nullable; | |
| 5 | +import android.support.v4.content.ContextCompat; | |
| 6 | +import android.view.View; | |
| 7 | + | |
| 8 | +import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | |
| 9 | +import com.cnlive.libs.base.util.StatusBarUtil; | |
| 10 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 11 | +import com.cnlive.strike.xiaojiaspeaker.R; | |
| 12 | +import com.cnlive.strike.xiaojiaspeaker.commonInfo.CommInfo; | |
| 13 | +import com.cnlive.strike.xiaojiaspeaker.databinding.FragmentSetFriendRoleBinding; | |
| 14 | +import com.cnlive.strike.xiaojiaspeaker.frame.presenter.SetFriendsRolePresenter; | |
| 15 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.SetFriendsRoleView; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 设置角色关系 | |
| 19 | + */ | |
| 20 | +public class SetFriendsRoleFragment extends MvpBindingFragment<SetFriendsRoleView, SetFriendsRolePresenter, Object, FragmentSetFriendRoleBinding> { | |
| 21 | + private String selectUid; | |
| 22 | + | |
| 23 | + public static SetFriendsRoleFragment newInstance(String selectUid) { | |
| 24 | + SetFriendsRoleFragment fragment = new SetFriendsRoleFragment(); | |
| 25 | + Bundle bundle = new Bundle(); | |
| 26 | + bundle.putString("selectUid", selectUid); | |
| 27 | + fragment.setArguments(bundle); | |
| 28 | + return fragment; | |
| 29 | + } | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + protected int getLayoutId() { | |
| 33 | + return R.layout.fragment_set_friend_role; | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public void onActivityCreated(@Nullable Bundle savedInstanceState) { | |
| 38 | + super.onActivityCreated(savedInstanceState); | |
| 39 | + StatusBarUtil.setStatusBarWrite(getActivity()); | |
| 40 | + StatusBarUtil2.setColor(getActivity(), ContextCompat.getColor(getActivity(), R.color.white), 0); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 45 | + super.onViewCreated(view, savedInstanceState); | |
| 46 | + initTopBar(); | |
| 47 | + if (null != getArguments()) { | |
| 48 | + selectUid = getArguments().getString("selectUid"); | |
| 49 | + getPresenter().getSetRoleList(getActivity(), selectUid, CommInfo.getFamilyId(getActivity())); | |
| 50 | + } else { | |
| 51 | + getActivity().finish(); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + | |
| 55 | + private void initTopBar() { | |
| 56 | + if (null != binding) { | |
| 57 | + binding.topbar.setTitle("设置角色").setTextColor(ContextCompat.getColor(getActivity(), R.color.color_282828)); | |
| 58 | + //设置返回按钮 | |
| 59 | + binding.topbar.addLeftImageButton(R.drawable.icon_back, R.id.left_back).setOnClickListener(new View.OnClickListener() { | |
| 60 | + @Override | |
| 61 | + public void onClick(View view) { | |
| 62 | + if (null != getActivity()) { | |
| 63 | + getActivity().finish(); | |
| 64 | + } | |
| 65 | + } | |
| 66 | + }); | |
| 67 | + } | |
| 68 | + } | |
| 69 | +} | ... | ... |
module_xiaojiaSoundBox/src/main/res/drawable-hdpi/check_normal_no_enable.png
0 → 100644
1.37 KB
module_xiaojiaSoundBox/src/main/res/drawable-hdpi/dd_xuanzhong.webp
0 → 100644
No preview for this file type
module_xiaojiaSoundBox/src/main/res/drawable-hdpi/icon_set_role_close.png
0 → 100644
785 Bytes
module_xiaojiaSoundBox/src/main/res/drawable-hdpi/touxiang_round.webp renamed to module_xiaojiaSoundBox/src/main/res/drawable-hdpi/touxiang.webp
No preview for this file type
module_xiaojiaSoundBox/src/main/res/drawable-xhdpi/check_normal_no_enable.png
0 → 100644
1.34 KB
module_xiaojiaSoundBox/src/main/res/drawable-xhdpi/icon_set_role_close.png
0 → 100644
955 Bytes
module_xiaojiaSoundBox/src/main/res/drawable-xhdpi/touxiang_round.webp renamed to module_xiaojiaSoundBox/src/main/res/drawable-xhdpi/touxiang.webp
No preview for this file type
module_xiaojiaSoundBox/src/main/res/drawable-xxhdpi/check_normal_no_enable.png
0 → 100644
2.74 KB
module_xiaojiaSoundBox/src/main/res/drawable-xxhdpi/icon_set_role_close.png
0 → 100644
1.31 KB
module_xiaojiaSoundBox/src/main/res/drawable/selector_btn_gray.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + <item android:drawable="@drawable/shape_btn_gray" android:state_pressed="false" /> | |
| 4 | + <item android:drawable="@drawable/shape_btn_press" android:state_pressed="true" /> | |
| 5 | + | |
| 6 | +</selector> | |
| 0 | 7 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/drawable/selector_check_box_text_color.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + <item android:color="@color/white" android:state_checked="true" /> | |
| 4 | + <item android:color="@color/color_B2B2B2" android:state_checked="false" android:state_enabled="false" /> | |
| 5 | + <item android:color="@color/black" android:state_checked="false" android:state_enabled="true" /> | |
| 6 | + | |
| 7 | +</selector> | |
| 0 | 8 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/drawable/selector_checkbox.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| 3 | - <item android:drawable="@drawable/check_normal" android:state_checked="false" /> | |
| 4 | - <item android:drawable="@drawable/check_press" android:state_checked="true" /> | |
| 3 | + <item android:drawable="@drawable/check_press" android:state_checked="true"/> | |
| 4 | + <item android:drawable="@drawable/check_normal" android:state_checked="false" android:state_enabled="true" /> | |
| 5 | + <item android:drawable="@drawable/check_normal_no_enable" android:state_checked="false" android:state_enabled="false" /> | |
| 5 | 6 | |
| 6 | 7 | </selector> |
| 7 | 8 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/drawable/selector_shape_check_box_bg.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + <item android:drawable="@drawable/shape_check_box_checked" android:state_checked="true" /> | |
| 4 | + <item android:drawable="@drawable/shape_check_box_normal" android:state_checked="false" android:state_enabled="true" /> | |
| 5 | + <item android:drawable="@drawable/shape_check_box_normal" android:state_checked="false" android:state_enabled="false" /> | |
| 6 | + | |
| 7 | +</selector> | |
| 0 | 8 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/drawable/shape_btn_gray.xml
0 → 100644
module_xiaojiaSoundBox/src/main/res/drawable/shape_check_box_checked.xml
0 → 100644
module_xiaojiaSoundBox/src/main/res/drawable/shape_check_box_normal.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + <corners android:radius="30dp" /> | |
| 4 | + <solid android:color="@color/white" /> | |
| 5 | + <stroke | |
| 6 | + android:width="1dp" | |
| 7 | + android:color="@color/color_B2B2B2" /> | |
| 8 | +</shape> | |
| 0 | 9 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/layout/activity_set_friends_role.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout> | |
| 3 | + | |
| 4 | + <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 6 | + xmlns:tools="http://schemas.android.com/tools" | |
| 7 | + android:layout_width="match_parent" | |
| 8 | + android:layout_height="match_parent" | |
| 9 | + tools:context=".ui.activity.SelectWifiActivity"> | |
| 10 | + | |
| 11 | + <RelativeLayout | |
| 12 | + android:id="@+id/fragment_container" | |
| 13 | + android:layout_width="match_parent" | |
| 14 | + android:layout_height="match_parent"></RelativeLayout> | |
| 15 | + </RelativeLayout> | |
| 16 | +</layout> | |
| 0 | 17 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/layout/fragment_select_im_friend.xml
module_xiaojiaSoundBox/src/main/res/layout/fragment_set_friend_role.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout> | |
| 3 | + | |
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | + android:layout_width="match_parent" | |
| 6 | + android:layout_height="match_parent" | |
| 7 | + android:background="@color/color_F2F2F2" | |
| 8 | + android:orientation="vertical"> | |
| 9 | + | |
| 10 | + <com.qmuiteam.qmui.widget.QMUITopBar | |
| 11 | + android:id="@+id/topbar" | |
| 12 | + android:layout_width="match_parent" | |
| 13 | + android:layout_height="?attr/qmui_topbar_height" /> | |
| 14 | + | |
| 15 | + <FrameLayout | |
| 16 | + android:layout_width="match_parent" | |
| 17 | + android:layout_height="50dp" | |
| 18 | + android:background="@color/color_F7B054"> | |
| 19 | + | |
| 20 | + <TextView | |
| 21 | + android:layout_width="260dp" | |
| 22 | + android:layout_height="wrap_content" | |
| 23 | + android:layout_gravity="center" | |
| 24 | + android:text="对已选用户设置角色,确立亲情关系" | |
| 25 | + android:textColor="@color/white" | |
| 26 | + android:textSize="16sp" /> | |
| 27 | + | |
| 28 | + <LinearLayout | |
| 29 | + android:layout_width="wrap_content" | |
| 30 | + android:layout_height="match_parent" | |
| 31 | + android:layout_gravity="right" | |
| 32 | + android:clickable="true" | |
| 33 | + android:gravity="center" | |
| 34 | + android:paddingRight="10dp"> | |
| 35 | + | |
| 36 | + <ImageView | |
| 37 | + android:layout_width="25dp" | |
| 38 | + android:layout_height="25dp" | |
| 39 | + android:background="@drawable/icon_set_role_close" /> | |
| 40 | + </LinearLayout> | |
| 41 | + </FrameLayout> | |
| 42 | + <!-- --> | |
| 43 | + <LinearLayout | |
| 44 | + android:layout_width="match_parent" | |
| 45 | + android:layout_height="0dp" | |
| 46 | + android:layout_weight="1"> | |
| 47 | + | |
| 48 | + <android.support.v7.widget.RecyclerView | |
| 49 | + android:id="@+id/rv_friends_role" | |
| 50 | + android:layout_width="match_parent" | |
| 51 | + android:layout_height="match_parent" /> | |
| 52 | + </LinearLayout> | |
| 53 | + | |
| 54 | + <Button | |
| 55 | + android:id="@+id/btn_next" | |
| 56 | + android:layout_width="match_parent" | |
| 57 | + android:layout_height="45dp" | |
| 58 | + android:layout_margin="30dp" | |
| 59 | + android:background="@drawable/selector_btn_green" | |
| 60 | + android:text="下一步" | |
| 61 | + android:textColor="@color/white" | |
| 62 | + android:textSize="17sp" | |
| 63 | + android:textStyle="bold" /> | |
| 64 | + <!-- 结尾--> | |
| 65 | + </LinearLayout> | |
| 66 | +</layout> | |
| 0 | 67 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/layout/item_list_select_im_contact.xml
| ... | ... | @@ -2,9 +2,11 @@ |
| 2 | 2 | <layout> |
| 3 | 3 | |
| 4 | 4 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 5 | + android:id="@+id/ll_root" | |
| 5 | 6 | android:layout_width="match_parent" |
| 6 | 7 | android:layout_height="65dp" |
| 7 | 8 | android:background="@color/white" |
| 9 | + android:clickable="true" | |
| 8 | 10 | android:gravity="center_vertical"> |
| 9 | 11 | |
| 10 | 12 | <LinearLayout |
| ... | ... | @@ -30,14 +32,13 @@ |
| 30 | 32 | |
| 31 | 33 | <CheckBox |
| 32 | 34 | android:id="@+id/checkBox" |
| 33 | - style="@style/CustomCheckboxTheme" | |
| 34 | 35 | android:layout_width="21dp" |
| 35 | 36 | android:layout_height="21dp" |
| 36 | 37 | android:layout_marginLeft="10dp" |
| 37 | 38 | android:layout_marginRight="20dp" |
| 39 | + android:background="@drawable/selector_checkbox" | |
| 40 | + android:button="@null" | |
| 38 | 41 | android:clickable="false" |
| 39 | - android:enabled="false" | |
| 40 | - android:focusable="false" | |
| 41 | - android:focusableInTouchMode="false" /> | |
| 42 | + android:focusable="false" /> | |
| 42 | 43 | </LinearLayout> |
| 43 | 44 | </layout> |
| 44 | 45 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/layout/item_list_set_role.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout> | |
| 3 | + | |
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | + android:id="@+id/ll_root" | |
| 6 | + android:layout_width="match_parent" | |
| 7 | + android:layout_height="wrap_content" | |
| 8 | + android:clickable="true" | |
| 9 | + android:orientation="vertical"> | |
| 10 | + | |
| 11 | + <LinearLayout | |
| 12 | + android:layout_width="match_parent" | |
| 13 | + android:layout_height="wrap_content" | |
| 14 | + android:layout_marginBottom="20dp" | |
| 15 | + android:background="@color/white" | |
| 16 | + android:orientation="vertical"> | |
| 17 | + | |
| 18 | + <LinearLayout | |
| 19 | + android:layout_width="match_parent" | |
| 20 | + android:layout_height="50dp" | |
| 21 | + android:gravity="center_vertical"> | |
| 22 | + | |
| 23 | + <ImageView | |
| 24 | + android:id="@+id/iv_icon" | |
| 25 | + android:layout_width="40dp" | |
| 26 | + android:layout_height="40dp" | |
| 27 | + android:layout_marginLeft="10dp" /> | |
| 28 | + | |
| 29 | + <TextView | |
| 30 | + android:id="@+id/tv_name" | |
| 31 | + android:layout_width="wrap_content" | |
| 32 | + android:layout_height="wrap_content" | |
| 33 | + android:layout_marginLeft="10dp" | |
| 34 | + android:maxLines="1" | |
| 35 | + android:text="黄昏下的枯树" /> | |
| 36 | + </LinearLayout> | |
| 37 | + | |
| 38 | + <android.support.v7.widget.RecyclerView | |
| 39 | + android:id="@+id/rv_role_list" | |
| 40 | + android:layout_width="match_parent" | |
| 41 | + android:layout_height="wrap_content" /> | |
| 42 | + </LinearLayout> | |
| 43 | + </LinearLayout> | |
| 44 | +</layout> | |
| 0 | 45 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/layout/item_list_set_role_check_box.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout> | |
| 3 | + | |
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | + android:id="@+id/ll_root" | |
| 6 | + android:layout_width="wrap_content" | |
| 7 | + android:layout_height="wrap_content" | |
| 8 | + android:clickable="true" | |
| 9 | + android:orientation="vertical"> | |
| 10 | + | |
| 11 | + <CheckBox | |
| 12 | + android:id="@+id/checkBox" | |
| 13 | + android:layout_width="61dp" | |
| 14 | + android:layout_height="24dp" | |
| 15 | + android:layout_margin="10dp" | |
| 16 | + android:background="@drawable/selector_shape_check_box_bg" | |
| 17 | + android:button="@null" | |
| 18 | + android:clickable="false" | |
| 19 | + android:focusable="false" | |
| 20 | + android:gravity="center" | |
| 21 | + android:text="爸爸" | |
| 22 | + android:textColor="@drawable/selector_check_box_text_color" | |
| 23 | + android:textSize="13sp" /> | |
| 24 | + </LinearLayout> | |
| 25 | +</layout> | |
| 0 | 26 | \ No newline at end of file | ... | ... |
module_xiaojiaSoundBox/src/main/res/values/colors.xml
| ... | ... | @@ -35,4 +35,8 @@ |
| 35 | 35 | <color name="line_15">#26EEEEEE</color> |
| 36 | 36 | <color name="color_EB3D3F">#EB3D3F</color> |
| 37 | 37 | <color name="color_656565">#656565</color> |
| 38 | + <color name="color_F7B054">#F7B054</color> | |
| 39 | + <color name="btn_close">#D3D3D3</color> | |
| 40 | + <color name="color_73DC41">#73DC41</color> | |
| 41 | + <color name="color_B2B2B2">#B2B2B2</color> | |
| 38 | 42 | </resources> | ... | ... |