Package net.solosky.maplefetion.bean

Examples of net.solosky.maplefetion.bean.Buddy


    @Override
    public synchronized Buddy getBuddyByUserId(int userId)
    {
      Iterator<Buddy> it = this.buddyList.values().iterator();
      while(it.hasNext()) {
        Buddy buddy = it.next();
        if(buddy.getUserId()==userId)
          return buddy;
      }
      return null;
    }
View Full Code Here


     */
  public synchronized Collection<Buddy> getBuddyListByCord(Cord cord)
  {
    ArrayList<Buddy> list = new ArrayList<Buddy>();
    Iterator<Buddy> it = this.buddyList.values().iterator();
    Buddy buddy = null;
    String [] buddyCordIds = null;
    while(it.hasNext()) {
      buddy = it.next();
      if(buddy.getCordId()!=null){
        buddyCordIds = buddy.getCordId().split(";");
        for(String cid : buddyCordIds){
          if(cid.equals(Integer.toString(cord.getId()))){
            list.add(buddy);
          }
        }
View Full Code Here

    @Override
    public synchronized Collection<Buddy> getBuddyListWithoutCord()
    {
      ArrayList<Buddy> list = new ArrayList<Buddy>();
    Iterator<Buddy> it = this.buddyList.values().iterator();
    Buddy buddy = null;
    String  buddyCordId = null;
    while(it.hasNext()) {
      buddy = it.next();
      buddyCordId = buddy.getCordId();
      if(buddyCordId==null || buddyCordId.length()==0) {
        list.add(buddy);
      }
    }
    return list;
View Full Code Here

    public synchronized Collection<Buddy> getBuddyListByRelation(Relation relation)
    {
      ArrayList<Buddy> list = new ArrayList<Buddy>();
      Iterator<Buddy> it = this.buddyList.values().iterator();
      while(it.hasNext()) {
        Buddy buddy = it.next();
        if(buddy.getRelation()==relation)
          list.add(buddy);
      }
      return list;
    }
View Full Code Here

   
    //可能部分好友已经获取到了手机号,特别是没有开通飞信的好友手机号码就是已知的
    //为了提高效率,这里先遍历好友,查看是否有好友的手机号码和给定的号码相同
    Iterator<Buddy> it = this.getFetionStore().getBuddyList().iterator();
    while(it.hasNext()){
      Buddy buddy = it.next();
      if(buddy.getMobile()==mobile){  //找到了好友,直接通知监听器
        if(listener!=null){
          listener.fireEevent(new FindBuddySuccessEvent(buddy));
          return;
        }
      }
View Full Code Here

          Iterator it = list.iterator();
         
        while(it.hasNext()) {
            Element e = (Element) it.next();
            String uri = e.getAttributeValue("uri");
            Buddy buddy = store.getBuddyByUri(uri);
            if(buddy!=null) {
              BeanHelper.setValue(buddy, "relation", Relation.BUDDY)//之前是什么状态呢。。。 TODO ..先暂时设置为好友关系
              context.getFetionStore().flushBuddy(buddy);
            }
          }
View Full Code Here

  {
    Element root = XMLHelper.build(response.getBody().toSendString());
       Element el = XMLHelper.find(root, "/results/contacts/contact");
      
       if(el!=null) {
         Buddy buddy = this.context.getFetionStore().getBuddyByUserId(Integer.parseInt(el.getAttributeValue("user-id")));
         BeanHelper.toBean(Buddy.class, buddy, el);
         context.getFetionStore().flushBuddy(buddy);
       }
      
       //Version control
View Full Code Here

        List recvList = XMLHelper.findAll(e, "/schedule-sms/receivers/*receiver");    //接收者
        Iterator rit =recvList.iterator();
        while(rit.hasNext()){
          Element el = (Element) rit.next();
          String uri = el.getAttributeValue("uri");
          Buddy buddy = store.getBuddyByUri(uri);
          if(buddy!=null){
            recieverList.add(buddy);
          }else if(context.getFetionUser().getUri().equals(uri)){    //可能是用户自己
            recieverList.add(context.getFetionUser());
          }else{
View Full Code Here

      it = list.iterator();
      while(it.hasNext()) {
        Element e = (Element) it.next();
        String uri = e.getAttributeValue("u");
       
        Buddy b = UriHelper.createBuddy(uri);
        b.setUserId(Integer.parseInt(e.getAttributeValue("i")));
        b.setLocalName(e.getAttributeValue("n"));
        b.setUri(e.getAttributeValue("u"));
        b.setCordId(e.getAttributeValue("l"));
        b.setRelation(Relation.valueOf(Integer.parseInt(e.getAttributeValue("r"))));
       
        store.addBuddy(b);
      }
     
      //处理 chat-friend..
        //这个chat-friend具体是什么含义我也没搞得太清楚,目前猜测里面的名单可能和用户是陌生人关系
      list = XMLHelper.findAll(root, "/results/user-info/contact-list/chat-friends/*c");
      it = list.iterator();
        while(it.hasNext()){
          Element e = (Element) it.next();
          Buddy b = UriHelper.createBuddy(e.getAttributeValue("u"));
        b.setUserId(Integer.parseInt(e.getAttributeValue("i")));
        b.setUri(e.getAttributeValue("u"));
            b.setRelation(Relation.STRANGER);
            store.addBuddy(b);
        }
       
        //处理Blacklist
        list = XMLHelper.findAll(root, "/results/user-info/contact-list/blacklist/*k");
      it = list.iterator();
        while(it.hasNext()){
          Element e = (Element) it.next();
          String uri = e.getAttributeValue("u");
          Buddy b = store.getBuddyByUri(uri);
          if(b!=null) {
            b.setRelation(Relation.BANNED);
          }
        }
       
       
        //处理Crendeticals
View Full Code Here

    //所以这里做个判断,如果原来的好友存在,直接删除掉
    int statusCode = Integer.parseInt(element.getAttributeValue("status-code"));
    switch(statusCode) {
    case 200:
      int userId = Integer.parseInt(element.getAttributeValue("user-id"));
      Buddy buddy = store.getBuddyByUserId(userId);
      if(buddy!=null){
        store.deleteBuddy(buddy);
      }
      buddy = new Buddy();
      BeanHelper.toBean(Buddy.class, buddy, element);
     
      store.addBuddy(buddy);
     
      //更新联系人版本信息
View Full Code Here

TOP

Related Classes of net.solosky.maplefetion.bean.Buddy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.