Commit 1fbabddd416c2ace65fe74af4b8991a923eb36f9
1 parent
8e0ed956
1 修改设置联系人角色
Showing
8 changed files
with
125 additions
and
12 deletions
config.gradle
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/SetFriendsRolePresenter.java
| ... | ... | @@ -13,6 +13,7 @@ import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; |
| 13 | 13 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; |
| 14 | 14 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.APIBaseInfo; |
| 15 | 15 | import com.cnlive.strike.xiaojiaspeaker.netWork.result.SubscriptionRequest; |
| 16 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | |
| 16 | 17 | import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; |
| 17 | 18 | |
| 18 | 19 | import java.util.HashMap; |
| ... | ... | @@ -24,6 +25,56 @@ public class SetFriendsRolePresenter extends MvpBasePresenter<SetFriendsRoleView |
| 24 | 25 | |
| 25 | 26 | private String TAG = "SetFriendsRolePresenter"; |
| 26 | 27 | |
| 28 | + public void invitFamilyMember(Context context, String contactsInvite) { | |
| 29 | + if (null == getView()) { | |
| 30 | + return; | |
| 31 | + } | |
| 32 | + QMUITipDialogUtil.loadingDialog(context, "请稍后", true); | |
| 33 | + getView().showLoadingView(); | |
| 34 | + Map<String, String> map = new HashMap<>(); | |
| 35 | + map.put("type", "2");//联系人邀请 | |
| 36 | + map.put("contactsInvite", contactsInvite); | |
| 37 | + Logic.create(map) | |
| 38 | + .action(new Logic.Action<Map<String, String>, APIBaseInfo>() { | |
| 39 | + @Override | |
| 40 | + public Disposable action(Map<String, String> paramsMap, DataCallback<APIBaseInfo> dataCallback) { | |
| 41 | + return SubscriptionRequest.service(ApiServiceXiaoJia.class, api -> api.invitFamilyMember(paramsMap)).subscribe(context, dataCallback); | |
| 42 | + } | |
| 43 | + }).<APIBaseInfo>event() | |
| 44 | + .setSuccessCallback(new SuccessCallback<APIBaseInfo>() { | |
| 45 | + @Override | |
| 46 | + public void onSuccess(APIBaseInfo baseInfo) { | |
| 47 | + Log.e(TAG, "onSuccess: "); | |
| 48 | + | |
| 49 | + if (null == getView()) { | |
| 50 | + return; | |
| 51 | + } | |
| 52 | + QMUITipDialogUtil.dismessDialog(); | |
| 53 | + } | |
| 54 | + }) | |
| 55 | + .setFailureCallback(new FailureCallback() { | |
| 56 | + @Override | |
| 57 | + public void onFailure(int i, String s) { | |
| 58 | + //显示重试 | |
| 59 | + Log.e(TAG, "onFailure: " + s); | |
| 60 | + if (null == getView()) { | |
| 61 | + return; | |
| 62 | + } | |
| 63 | + QMUITipDialogUtil.dismessDialog(); | |
| 64 | + QMUITipDialogUtil.failedDialog(context, s, 1); | |
| 65 | + } | |
| 66 | + }) | |
| 67 | + | |
| 68 | + .start(); | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * 获取用户角色 | |
| 73 | + * | |
| 74 | + * @param context | |
| 75 | + * @param sids | |
| 76 | + * @param familyId | |
| 77 | + */ | |
| 27 | 78 | public void getSetRoleList(Context context, String sids, String familyId) { |
| 28 | 79 | if (null == getView()) { |
| 29 | 80 | return; | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SelectIMFriendView.java
| ... | ... | @@ -297,7 +297,7 @@ public class SelectIMFriendView implements MvpView, LetterBarView.OnLetterSelect |
| 297 | 297 | //获取选择的uid |
| 298 | 298 | if (null != adapter) { |
| 299 | 299 | String selectUids = adapter.getSelectUid(); |
| 300 | - SetFriendsRoleActivity.startActivity(getContext(), selectUids); | |
| 300 | + SetFriendsRoleActivity.startActivity(getContext(), selectUids,currentSelectFamilyId); | |
| 301 | 301 | |
| 302 | 302 | } |
| 303 | 303 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SetFriendsRoleView.java
| ... | ... | @@ -4,8 +4,10 @@ import android.app.Activity; |
| 4 | 4 | import android.support.v4.content.ContextCompat; |
| 5 | 5 | import android.support.v7.widget.GridLayoutManager; |
| 6 | 6 | import android.support.v7.widget.LinearLayoutManager; |
| 7 | +import android.text.TextUtils; | |
| 7 | 8 | import android.view.View; |
| 8 | 9 | |
| 10 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 9 | 11 | import com.cnlive.strike.xiaojiaspeaker.R; |
| 10 | 12 | import com.cnlive.strike.xiaojiaspeaker.model.RoleInfo; |
| 11 | 13 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; |
| ... | ... | @@ -20,7 +22,7 @@ public class SetFriendsRoleView implements MvpView { |
| 20 | 22 | private SetFriendsRoleFragment fragment; |
| 21 | 23 | private List<RoleInfo> roleInfoList; |
| 22 | 24 | private SetRoleAdapter adapter; |
| 23 | - private String currentSelFamilyId; | |
| 25 | + private String currentSelFamilyId; | |
| 24 | 26 | |
| 25 | 27 | public void setCurrentSelFamilyId(String currentSelFamilyId) { |
| 26 | 28 | this.currentSelFamilyId = currentSelFamilyId; |
| ... | ... | @@ -60,19 +62,29 @@ public class SetFriendsRoleView implements MvpView { |
| 60 | 62 | } |
| 61 | 63 | } |
| 62 | 64 | //设置适配器 |
| 63 | - adapter = new SetRoleAdapter(getContext(), roleInfoList); | |
| 65 | + adapter = new SetRoleAdapter(getContext(), roleInfoList, currentSelFamilyId); | |
| 64 | 66 | fragment.binding.rvFriendsRole.setLayoutManager(new LinearLayoutManager(getContext())); |
| 65 | 67 | fragment.binding.rvFriendsRole.setAdapter(adapter); |
| 66 | 68 | //设置点击 |
| 67 | 69 | adapter.setOnSelectListener(new SetRoleAdapter.OnSelectListener() { |
| 68 | 70 | @Override |
| 69 | 71 | public void onSelect(int roleId) { |
| 70 | - | |
| 72 | + //判断用户角色是都全部设置 | |
| 73 | + if (adapter.isPeopleAllSetRole()) { | |
| 74 | + nextBtnCanClick(); | |
| 75 | + } else { | |
| 76 | + nextBtnCanNotClick(); | |
| 77 | + } | |
| 71 | 78 | } |
| 72 | 79 | |
| 73 | 80 | @Override |
| 74 | 81 | public void onCancel() { |
| 75 | - | |
| 82 | + //判断用户角色是都全部设置 | |
| 83 | + if (adapter.isPeopleAllSetRole()) { | |
| 84 | + nextBtnCanClick(); | |
| 85 | + } else { | |
| 86 | + nextBtnCanNotClick(); | |
| 87 | + } | |
| 76 | 88 | } |
| 77 | 89 | }); |
| 78 | 90 | //关闭提示 |
| ... | ... | @@ -82,6 +94,20 @@ public class SetFriendsRoleView implements MvpView { |
| 82 | 94 | fragment.binding.flTipView.setVisibility(View.GONE); |
| 83 | 95 | } |
| 84 | 96 | }); |
| 97 | + //一键邀请 | |
| 98 | + fragment.binding.btnNext.setOnClickListener(new View.OnClickListener() { | |
| 99 | + @Override | |
| 100 | + public void onClick(View v) { | |
| 101 | + if (null != adapter) { | |
| 102 | + String result = adapter.getRoleSetResult(); | |
| 103 | + if (!TextUtils.isEmpty(result)) { | |
| 104 | + fragment.getPresenter().invitFamilyMember(getContext(), result); | |
| 105 | + } else { | |
| 106 | + AlertUtil.showDeftToast(getContext(), "发送参数异常"); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + } | |
| 110 | + }); | |
| 85 | 111 | } |
| 86 | 112 | |
| 87 | 113 | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/netWork/ApiServiceXiaoJia.java
| ... | ... | @@ -123,5 +123,27 @@ public interface ApiServiceXiaoJia { |
| 123 | 123 | */ |
| 124 | 124 | @GET("/Daren/sound/getFamilyMember.action") |
| 125 | 125 | Observable<Result<APIBaseInfo<XiaoJiaContactInfo>>> getFamilyMember(@QueryMap() Map<String, String> maps); |
| 126 | + | |
| 127 | + /** | |
| 128 | + * 邀请家庭成员 | |
| 129 | + * "type":"2", //1-二维码邀请 2-联系人邀请 | |
| 130 | + * "contactsInvite":[ | |
| 131 | + * { | |
| 132 | + * "familyId":"1111", //家庭Id | |
| 133 | + * "sid":105102771, //用户sid | |
| 134 | + * "roleId":1 //家庭成员身份 1-爸爸 2-妈妈 3-爷爷 4-奶奶 5-外公 6-外婆 7-哥哥 8-弟弟 9-姐姐 10-妹妹 | |
| 135 | + * }, | |
| 136 | + * { | |
| 137 | + * "familyId":"1111", | |
| 138 | + * "sid":105102772, | |
| 139 | + * "roleId":1 | |
| 140 | + * } | |
| 141 | + * ] | |
| 142 | + * | |
| 143 | + * @param maps | |
| 144 | + * @return | |
| 145 | + */ | |
| 146 | + @POST("/Daren/sound/familyGroupInviteYD.action") | |
| 147 | + Observable<Result<APIBaseInfo>> invitFamilyMember(@QueryMap() Map<String, String> maps); | |
| 126 | 148 | } |
| 127 | 149 | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/activity/SetFriendsRoleActivity.java
| ... | ... | @@ -20,16 +20,18 @@ public class SetFriendsRoleActivity extends AppCompatActivity { |
| 20 | 20 | setContentView(R.layout.activity_set_friends_role); |
| 21 | 21 | if (null != getIntent().getExtras()) { |
| 22 | 22 | String selectUid = getIntent().getExtras().getString("selectUid"); |
| 23 | - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, SetFriendsRoleFragment.newInstance(selectUid)).commitAllowingStateLoss(); | |
| 23 | + String currentSelectFamilyId= getIntent().getExtras().getString("currentSelectFamilyId"); | |
| 24 | + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, SetFriendsRoleFragment.newInstance(selectUid,currentSelectFamilyId)).commitAllowingStateLoss(); | |
| 24 | 25 | } else { |
| 25 | 26 | finish(); |
| 26 | 27 | } |
| 27 | 28 | |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | - public static void startActivity(Activity activity, String selectUid) { | |
| 31 | + public static void startActivity(Activity activity, String selectUid,String currentSelectFamilyId) { | |
| 31 | 32 | Intent intent = new Intent(activity, SetFriendsRoleActivity.class); |
| 32 | 33 | intent.putExtra("selectUid", selectUid); |
| 34 | + intent.putExtra("currentSelectFamilyId", currentSelectFamilyId); | |
| 33 | 35 | activity.startActivity(intent); |
| 34 | 36 | } |
| 35 | 37 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/SetRoleAdapter.java
| ... | ... | @@ -16,6 +16,7 @@ import com.cnlive.strike.xiaojiaspeaker.databinding.ItemListSetRoleBinding; |
| 16 | 16 | import com.cnlive.strike.xiaojiaspeaker.model.RoleInfo; |
| 17 | 17 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.InvitFamilyBean; |
| 18 | 18 | import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; |
| 19 | +import com.cnlive.strike.xiaojiaspeaker.util.GsonUtil; | |
| 19 | 20 | |
| 20 | 21 | import java.util.ArrayList; |
| 21 | 22 | import java.util.HashMap; |
| ... | ... | @@ -67,10 +68,19 @@ public class SetRoleAdapter extends RecyclerView.Adapter { |
| 67 | 68 | */ |
| 68 | 69 | public String getRoleSetResult() { |
| 69 | 70 | String result = ""; |
| 71 | + if (TextUtils.isEmpty(currentSelectFamilyId)) { | |
| 72 | + return result; | |
| 73 | + } | |
| 70 | 74 | List<InvitFamilyBean> invitFamilyBeanList = new ArrayList<>(); |
| 71 | 75 | for (int i = 0; i < roleInfoList.size(); i++) { |
| 72 | 76 | InvitFamilyBean bean = new InvitFamilyBean(); |
| 73 | - bean.setFamilyId(roleInfoList.get(i).getUid()); | |
| 77 | + bean.setFamilyId(currentSelectFamilyId); | |
| 78 | + bean.setRoleId(Integer.parseInt(roleInfoList.get(i).getSelectId())); | |
| 79 | + bean.setSid(Integer.parseInt(roleInfoList.get(i).getUid())); | |
| 80 | + invitFamilyBeanList.add(bean); | |
| 81 | + } | |
| 82 | + if (null != invitFamilyBeanList && invitFamilyBeanList.size() > 0) { | |
| 83 | + return GsonUtil.GsonString(invitFamilyBeanList); | |
| 74 | 84 | } |
| 75 | 85 | return result; |
| 76 | 86 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/fragment/SetFriendsRoleFragment.java
| ... | ... | @@ -20,7 +20,7 @@ import com.cnlive.strike.xiaojiaspeaker.frame.view.SetFriendsRoleView; |
| 20 | 20 | public class SetFriendsRoleFragment extends MvpBindingFragment<SetFriendsRoleView, SetFriendsRolePresenter, Object, FragmentSetFriendRoleBinding> { |
| 21 | 21 | private String selectUid; |
| 22 | 22 | |
| 23 | - public static SetFriendsRoleFragment newInstance(String selectUid,String currentSelFamilyId) { | |
| 23 | + public static SetFriendsRoleFragment newInstance(String selectUid, String currentSelFamilyId) { | |
| 24 | 24 | SetFriendsRoleFragment fragment = new SetFriendsRoleFragment(); |
| 25 | 25 | Bundle bundle = new Bundle(); |
| 26 | 26 | bundle.putString("selectUid", selectUid); |
| ... | ... | @@ -47,8 +47,10 @@ public class SetFriendsRoleFragment extends MvpBindingFragment<SetFriendsRoleVie |
| 47 | 47 | initTopBar(); |
| 48 | 48 | if (null != getArguments()) { |
| 49 | 49 | selectUid = getArguments().getString("selectUid"); |
| 50 | - String currentSelFamilyId=getArguments().getString("currentSelFamilyId"); | |
| 51 | - | |
| 50 | + String currentSelFamilyId = getArguments().getString("currentSelFamilyId"); | |
| 51 | + if (null != getMvpView()) { | |
| 52 | + getMvpView().setCurrentSelFamilyId(currentSelFamilyId); | |
| 53 | + } | |
| 52 | 54 | getPresenter().getSetRoleList(getActivity(), selectUid, XiaoJIaCommInfo.getFamilyId(getActivity())); |
| 53 | 55 | } else { |
| 54 | 56 | getActivity().finish(); | ... | ... |