今天完成两个匹配基于昨天那个匹配方式修改一些数据就可以了
结果图:
代码:
//恋爱匹配 private void loveUser(List<MyMeetUser> list) { List<MyMeetUser> love_user=new ArrayList<>(); for (int i=0;i<list.size();i++) { MyMeetUser myMeetUser=list.get(i); if(myMeetUser.getObjectId().equals(meUserId)) { continue; } if(myMeetUser.isSex()!=meUser.isSex()) { love_user.add(myMeetUser); } } final List<MyMeetUser> love_list=new ArrayList<>(); if(CommonUtils.isEmpty(love_user)) { for(int i=0;i<love_user.size();i++) { MyMeetUser myMeetUser=love_user.get(i); if(MyMeetUser) int age=Math.abs(myMeetUser.getAge()-meUser.getAge()); if(age<=2) { love_id.add(myMeetUser.getObjectId()); } } } final List<String> love_id=new ArrayList<>(); if(CommonUtils.isEmpty(love_user)) { for(int i=0;i<love_user.size();i++) { MyMeetUser myMeetUser=love_user.get(i); int age=Math.abs(myMeetUser.getAge()-meUser.getAge()); if(age<=2) { love_id.add(myMeetUser.getObjectId()); } } if(love_id.size()>0) { rxJavaParingResult(new OnRxJavaResultListener() { @Override public void rxJavaParingResult() { int r=mRandom.nextInt(love_id.size()); onPairResultListener.OnPairListener(love_id.get(r)); } }); } else { onPairResultListener.OnPairFailListener(); } } else { onPairResultListener.OnPairFailListener(); } } //5.4灵魂匹配 private void soulUser(final List<MyMeetUser> list) { List<String> list_objectId=new ArrayList<>(); for(int i=0;i<list.size();i++) { MyMeetUser myMeetUser=list.get(i); if(myMeetUser.getObjectId().equals(meUserId)) { continue; } if(myMeetUser.getConstellation().equals(meUser.getConstellation())) { list_objectId.add(myMeetUser.getObjectId()); } if(myMeetUser.getAge()==meUser.getAge()) { list_objectId.add(myMeetUser.getObjectId()); } if(myMeetUser.getHobby().equals(meUser.getHobby())) { list_objectId.add(myMeetUser.getObjectId()); } if(myMeetUser.getStatus().equals(meUser.getStatus())) { list_objectId.add(myMeetUser.getObjectId()); } } // Map<String,Integer> map=new HashMap<>(); for(String str:list_objectId) { Integer i=1; if(map.get(str)!=null) { i=map.get(str)+1; } map.put(str,i); } final List<String> soul_list=mapComperTo(4,map); if(CommonUtils.isEmpty(soul_list)) { rxJavaParingResult(new OnRxJavaResultListener() { @Override public void rxJavaParingResult() { int r=mRandom.nextInt( soul_list.size()); onPairResultListener.OnPairListener(soul_list.get(r)); } }); } else { onPairResultListener.OnPairFailListener(); } }