/** * 保存好友列表. 请在后台操作。 * * @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; } }
/** * 更新好友列表. * * @param customerVos * @return 作者:fighter <br> * 创建时间:2013-5-31<br> * 修改时间:<br> */ public boolean updateFriendList(List<CustomerVo> customerVos) { Log.d(TAG, "updateFriendList()"); String friends = JSON.toJSONString(customerVos); try { finalDb.deleteByWhere(CustomerVo.class, "uid != '" + userInfoVo.getUid() + "'"); finalDb.saveList(customerVos); } catch (Exception e) { return false; } return saveFriendListDb(friends); }