コード例 #1
0
  /**
   * 保存好友列表. 请在后台操作。
   *
   * @param customerVos
   * @return 作者:fighter <br>
   *     创建时间:2013-5-31<br>
   *     修改时间:<br>
   */
  public boolean saveFriendList(List<CustomerVo> customerVos) {
    Log.d(TAG, "saveFriendList()");
    try {
      friendListVo = new FriendListVo();
      friendListVo.setUid(userInfoVo.getUid());
      friendListVo.setUpdateTime(System.currentTimeMillis() + "");

      StringBuffer buffer = new StringBuffer();
      int index = customerVos.size();
      for (int i = 0; i < index; i++) {
        CustomerVo customerVo = customerVos.get(i);
        customerVo.setFriend("1");
        buffer.append("'").append(customerVo.getUid()).append("'");
        if (i == (index - 1)) {
          continue;
        }
        buffer.append(",");
      }
      String friends = buffer.toString();

      friendListVo.setFriends(friends);
      finalDb.delete(friendListVo);
      finalDb.save(friendListVo);
      finalDb.deleteByWhere(CustomerVo.class, "uid in (" + friends + ")");
      finalDb.saveList(customerVos);
      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
コード例 #2
0
  private boolean saveFriendListDb(String cvos) {
    Log.d(TAG, "saveFriendListDb()");
    try {
      friendListVo = new FriendListVo();
      friendListVo.setUid(userInfoVo.getUid());
      friendListVo.setUpdateTime(System.currentTimeMillis() + "");

      friendListVo.setFriends(cvos);
      finalDb.update(friendListVo);
      return true;
    } catch (Exception e) {
      return false;
    }
  }
コード例 #3
0
 /**
  * 获取好友列表信息
  *
  * @return 作者:fighter <br>
  *     创建时间:2013-5-31<br>
  *     修改时间:<br>
  */
 public synchronized List<CustomerVo> getFriendList() {
   Log.d(TAG, "getFriendList()");
   if (customerVos != null) {
     return customerVos;
   }
   if (friendListVo != null) {
     try {
       List<CustomerVo> cVos =
           finalDb.findAllByWhere(CustomerVo.class, "uid in(" + friendListVo.getFriends() + ")");
       if (cVos != null) {
         Collections.sort(cVos, pinyinComparator);
       } else {
         cVos = new ArrayList<CustomerVo>();
       }
       checkFriendListIsUpdate();
       this.customerVos = cVos;
       return this.customerVos;
     } catch (Exception e) {
       return null;
     }
   } else {
     return null;
   }
 }